Merges bugfixes from trunk.
authorPekka Riikonen <priikone@silcnet.org>
Sat, 13 Apr 2002 06:18:39 +0000 (06:18 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Sat, 13 Apr 2002 06:18:39 +0000 (06:18 +0000)
103 files changed:
CHANGES
TODO
TODO-1.0
apps/irssi/docs/help/in/cmode.in
apps/irssi/docs/help/in/cumode.in
apps/irssi/docs/help/in/umode.in
apps/irssi/src/fe-common/silc/module-formats.c
apps/irssi/src/silc/core/client_ops.c
apps/irssi/src/silc/core/client_ops.h
apps/irssi/src/silc/core/silc-core.c
apps/irssi/src/silc/core/silc-servers.c
apps/silcd/command.c
apps/silcd/command.h
apps/silcd/command_reply.c
apps/silcd/command_reply.h
apps/silcd/idlist.c
apps/silcd/idlist.h
apps/silcd/packet_receive.c
apps/silcd/packet_receive.h
apps/silcd/packet_send.c
apps/silcd/packet_send.h
apps/silcd/protocol.c
apps/silcd/server.c
apps/silcd/server.h
apps/silcd/server_internal.h
apps/silcd/server_util.c
apps/silcd/server_util.h
apps/silcd/serverconfig.c
apps/silcd/silcd.c
config.guess
config.sub
doc/Makefile.am.pre
doc/draft-riikonen-silc-commands-03.nroff
doc/draft-riikonen-silc-flags-payloads-00.nroff
doc/draft-riikonen-silc-ke-auth-05.nroff
doc/draft-riikonen-silc-pp-05.nroff
doc/draft-riikonen-silc-spec-05.nroff
doc/example_silcd.conf.in
includes/silcincludes.h
includes/silcversion.h
includes/silcwin32.h
lib/.cvsignore [deleted file]
lib/doc/intro_reference.html
lib/silcclient/Makefile.am
lib/silcclient/client.c
lib/silcclient/client.h
lib/silcclient/client_channel.c
lib/silcclient/client_ftp.c
lib/silcclient/client_internal.h
lib/silcclient/client_notify.c
lib/silcclient/client_ops_example.c
lib/silcclient/client_prvmsg.c
lib/silcclient/client_resume.c [deleted file]
lib/silcclient/command.c
lib/silcclient/command.h
lib/silcclient/command_reply.c
lib/silcclient/command_reply.h
lib/silcclient/idlist.c
lib/silcclient/idlist.h
lib/silcclient/protocol.c
lib/silcclient/silcclient.h
lib/silccore/silcauth.c
lib/silccore/silcauth.h
lib/silccore/silcchannel.c
lib/silccore/silcchannel.h
lib/silccore/silccommand.c
lib/silccore/silccommand.h
lib/silccore/silcid.c
lib/silccore/silcid.h
lib/silccore/silcmode.h
lib/silccore/silcpacket.c
lib/silccore/silcpacket.h
lib/silccrypt/silccipher.c
lib/silccrypt/silccipher.h
lib/silccrypt/silchash.c
lib/silccrypt/silchash.h
lib/silccrypt/silchmac.c
lib/silccrypt/silchmac.h
lib/silccrypt/silcpkcs.c
lib/silccrypt/silcpkcs.h
lib/silcsftp/sftp_fs_memory.c
lib/silcske/silcske.c
lib/silcske/silcske.h
lib/silcutil/DIRECTORY
lib/silcutil/Makefile.am
lib/silcutil/beos/.cvsignore [deleted file]
lib/silcutil/os2/.cvsignore [deleted file]
lib/silcutil/silcbuffer.h
lib/silcutil/silcfileutil.c
lib/silcutil/silclist.h
lib/silcutil/silcschedule.c
lib/silcutil/silcschedule.h
lib/silcutil/silcsockconn.h
lib/silcutil/silcstrutil.c [deleted file]
lib/silcutil/silcstrutil.h [deleted file]
lib/silcutil/silctypes.h
lib/silcutil/silcutil.c
lib/silcutil/silcutil.h
lib/silcutil/symbian/.cvsignore [deleted file]
lib/silcutil/unix/.cvsignore [deleted file]
lib/silcutil/win32/.cvsignore [deleted file]
prepare
scripts/stripspaces.tcl [deleted file]

diff --git a/CHANGES b/CHANGES
index 089a3c93384d5dbef6efb2616e8c637d552091b2..baec17fa376157a42822b03842bdd5eff383b7c3 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,98 +1,3 @@
-Fri Apr 12 20:09:08 EEST 2002  Pekka Riikonen <priikone@silcnet.org>
-
-         Added resolve_cmd_ident field to the SilcClientEntry structure
-         too so that if the entry is for example being resolved so 
-         another command may attach to the same pending command reply
-         without requiring to resolve the same entry again.  Added
-          support for adding multiple pending commands for one
-         command idenfier.  Affected files lib/silcclient/command.[ch],
-         lib/silcclient/command_reply.[ch], lib/silcclient/idlist.h.
-
-Fri Apr 12 10:17:51 EEST 2002  Pekka Riikonen <priikone@silcnet.org>
-
-       * Defined that server receives WHOIS command reply for private
-         and secret channels too.  Updated protocol specs and the
-         code in server.  Affected file silcd/command.c.
-
-       * Defined <channel user mode list> argument to WHOIS command
-         reply for returning user modes on the channels.  The
-         channel list now doesn't include the user mode anymore but the
-         actual channel mode.  Updated protocol specs and the code in
-         client and server.  Affected files are silcd/command_reply.c,
-         silcd/command.c, silcd/server.c, irssi/src/silc/core/client_ops.c,
-         and lib/silcclient/command_reply.c.
-
-       * Save the channels list in WHOIS command reply in normal server
-         so that WHOIS always shows joined channels also in normal
-         server and not just on router.  Affected file is
-         silcd/command_reply.c.
-
-Thu Apr 11 22:29:33 EEST 2002  Pekka Riikonen <priikone@silcnet.org>
-
-       * Defined that server receives USERS command reply for private
-         and secret channels too.  Updated protocol specs and the
-         code in server.  Affected file silcd/command.c.
-
-Thu Apr 11 16:32:08 EEST 2002  Pekka Riikonen <priikone@silcnet.org>
-
-       * Changed the UMODE's mode mask argument to be optional.  If
-         not provided then the command merely returns the current mode
-         mask to the client.  Updated protocol specs and the server.
-         Affected file is silcd/command.c.
-
-       * Added SILC session detachment/resuming support.  It is possible
-         to detach by closing the network connection and then re-connect
-         and resume to the old client session.  Added DETACHED user
-         mode that server will set for detached client.  Added new
-         packet RESUME_CLIENT which is used to perform the resuming
-         process.  Added DETACH command.  Updated the protocol specs,
-         core library, client and server.  Protocol TODO #22.  Very
-         many affected files around the tree.
-
-Wed Apr 10 16:32:01 EEST 2002  Pekka Riikonen <priikone@silcnet.org>
-
-       * Changed the CMODE's mode mask argument to be optional.  If
-         not provided then the command merely returns the current mode
-         mask to the client.  Updated protocol specs and the server.
-         Affected file is silcd/command.c.
-
-       * Changed the Killer's Client ID in KILLED notify to be just
-         any ID payload since router server is allowed to kill as well.
-         Updated protocol specs, client libary and server.  Affected
-         files are lib/silcclient/client_notify.c, silcd/packet_receive.c,
-         and irssi/src/silc/core/client_ops.c.
-
-Tue Apr  9 17:15:42 EEST 2002  Pekka Riikonen <priikone@silcnet.org>
-
-       * Added new user modes ANONYMOUS for special anonymous servers
-         that may set the mode for client, and BLOCK_PRIVMSG which
-         client may set to block incoming private messages unless the
-         Private Message Key flag is set (using private keys to protect
-         private messages).  Updated protocol specs and code in client
-         and server and core library.  Protocol TODO #23.  Affected
-         files are lib/silccore/silcmode.h, silcd/server.[ch], 
-         irssi/src/silc/core/client_ops.c, silcd/packet_receive.c,
-         irssi/docs/help/in/umode.in, lib/silcclient/command.c.
-
-       * Added new channel user mode BLOCK_MESSAGES which the client
-         may set to itself to tell server not send channel messages.
-         Other packets such as channel key packets are still sent.
-         Protocol TODO #23.  Updated the protocol specs, client and
-         server.  Affected files are lib/silccore/silcmode.h,
-         irssi/docs/help/in/cumode.in, lib/silcclient/command.c,
-         lib/silcutil/silcutil.c, silcd/command.c, and
-         silcd/packet_send.c.
-
-Mon Apr  8 23:57:32 EEST 2002  Pekka Riikonen <priikone@silcnet.org>
-
-       * Redefined the Status Payload to include now two 8 bit fields,
-         instead of one 16 bit field.  This now makes it possible to
-         send list of errors.  Updated the protocol specs and the code
-         in core library, client library and server.  Protocol TODO #1.
-         Affected files are lib/silccore/silccommand.[ch],
-         lib/silcclient/command_reply.[ch], silcd/command.c,
-         silcd/command_reply.c and silcd/packet_receive.[ch].
-
 Mon Apr  8 19:57:40 CEST 2002  Johnny Mnemonic <johnny@themnemonic.org>
 
        * Added config parse status SILC_CONFIG_EPRINTLINE, this status
@@ -111,169 +16,16 @@ Mon Apr  8 19:57:40 CEST 2002  Johnny Mnemonic <johnny@themnemonic.org>
        * Drop root privileges when started in foreground.  Don't drop them
          if debugging also.  Affected file is silcd/silcd.c.
 
-Mon Apr  8 17:00:41 EEST 2002  Pekka Riikonen <priikone@silcnet.org>
-
-       * Added more IM-like features by introducing new user modes
-         for setting various presence information.  Added new modes:
-         INDISPOSED, BUSY, PAGE, HYPER and ROBOT.  Updated protocol
-          specs and code.  Protocol TODO #19. Affected files are 
-          lib/silccore/silcmode.h, irssi/src/silc/core/client_ops.c,
-         irssi/docs/help/in/umode.in and lib/silcclient/command.c.
-
-Sun Apr  7 17:07:59 EEST 2002  Pekka Riikonen <priikone@silcnet.org>
-
-       * Added STATS command to the protocol after all, to return
-         various statistical information about the network.  It can
-         be used by clients to retrieve statistical information, and
-         servers may use it to to fetch cell and network wide 
-         statistics from router.  Updated the protocol specs and
-         implemented it to the server.  Protocol TODO #16.
-         Affected files are lib/silccore/silccommand, silcd/command.[ch],
-         silcd/command_reply.[ch].
-
-Sat Apr  6 17:08:58 EEST 2002  Pekka Riikonen <priikone@silcnet.org>
-
-       * The LIST command reply in client libary now adds new channel
-         entry if the returned channel doesn't exist yet in cache, 
-         and returns the channel entry to the application in the
-         command_reply client operation.  Affected file is
-         lib/silcclient/command_reply.c.
-
-       * Changed the channel message payload's MAC generation to
-         include the IV in the MAC as well.  This way all relevant
-         parts of the channel message payload are authenticated also
-         with the channel message MAC (and not only by packet MAC).
-         Causes incompatibility with 1.0 protocol.  Protocol TODO #7.
-         Affected file is lib/silccore/silcchannel.c.
-
-       * Fixed the SKE to save the remote version, since the
-         silc_ske_parse_version mistakenly checked wrong version,
-         after it replaced the start payload.  Affected files are
-         lib/silcske/silcske.[ch].
-
-Fri Apr  5 16:03:03 EEST 2002  Pekka Riikonen <priikone@silcnet.org>
-
-       * Splitted lib/silcutil/silcutil.h into silcstrutil.h for
-         string utility functions.  Added there also new functions
-         silc_utf8_[encode/decode/valid] for UTF-8 string encoding.
-         Affected files lib/silcutil/silcstrutil.[ch].
-
-       * Renamed silc_*_pem functions to silc_pem_* functions.  Affected
-         files are lib/silcutil/silcstrutil.[ch].
-
-       * Defined that the security property fields in SKE SHOULD be
-         UTF-8 encoded, defined that version string MUST be US-ASCII
-         encoded, defined that passphrases sent in connection 
-         authentication protocol MUST be UTF-8 encoded.  Implemented
-         these to the client and server.  Defined also that other
-         passphrases sent in the protocol MUST be UTF-8 encoded.
-         Affected files are lib/silcske/silcske.c, 
-         lib/silcclient/protocol.c, silcd/protocol.c, 
-         silcd/serverconfig.c, and lib/silccore/silcauth.c.
-
-       * Changed the silc_client_close_connection interface to not
-         need the SilcSocketConnection which should not be visible
-         to application.  Affected files are lib/silcclient/client.c
-         and lib/silcclient/silcclient.h.
-
-       * Rewrote the text for Private Message Key Payload in the
-         protocol specification.  Protocol TODO #11.
-
-Wed Apr  3 16:24:51 EEST 2002  Pekka Riikonen <priikone@silcnet.org>
-
-       * Upgraded the protocol version to 1.1, updated protocol specs
-         and software.
-
-       * Added the nickname as new argument to NICK_CHANGE notify and
-         added it to protocol specs and implemented it to client and
-         server.  Protocol TODO #3.  Affected files are silcd/idlist.[ch],
-         silcd/command.c, silcd/packet_receive.c, packet_send.[ch], and
-         lib/silcclient/client_notify.c.
-
-       * Added the killer's client ID to the KILLED notify and added
-         it to protocol specs and implemented it to client and server.
-         Protocol TODO #13.  Affected files are silcd/command.c,
-         silcd/packet_receive.c, packet_send.[ch], 
-         lib/silcclient/client_notify.c, irssi/src/silc/core/client_ops.c.
-         The killer's client entry is now returned to application in
-         the `notify' client operation.
-
-       * Fixed the Max Argument fields that had too large value set
-         in the protocol specs.  Protocol TODO #14.
+Wed Apr  3 12:36:05 CEST 2002  Pekka Riikonen <priikone@silcnet.org>
 
-       * Added the LEAVE command reply to return the ID of parted
-         channel.  Updated protocol specs and implemented it to the
-         client and server.  Protocol TODO #15.  Affected files are
-         silcd/command.c, lib/silcclient/command_reply.c.  The channel
-         entry is now returned to application in the `command_reply'
-         client operation.
-
-       * Rewrote the version SKE version checking in client libary
-         and in server to use the silc_parse_version_string.  Affected
-         files are lib/silcclient/protocol.c, silcd/protocol.c.
-
-       * Added SILC_STATUS_ERR_NO_CHANNEL_FOPRIV error status to few
-         commands that was missing it, and updated protocol specs and
-         the server implementation.  Protocol TODO #10.  The affected
-         file is silcd/command.c.
-
-       * Defined new message flags SILC_MESSAGE_FLAG_REPLY to be
-         generic reply to a generic request (REQUEST flag), and
-         SILC_MESSAGE_FLAG_DATA to send any kind of data in a generic
-         way.  A draft-riikonen-silc-flags-payloads-00.txt is written
-         to define the payload for DATA flag.  Added the flags to
-         the implementation.  Protocol TODO #9.  Affected file is
-         lib/silccore/silcchannel.h.
-
-         Changed the client library to return the message length
-         to application as well in the channel_message and private_message
-         client operations.  Affected files are 
-         lib/silcclient/client_prvmsg, lib/silcclient/client_channel.c,
-         lib/silcclient/silcclient.h, irssi/src/silc/core/client_ops.c,
-         and lib/silcclient/client_ops_example.c.
-
-       * Added two new channel modes: SILC_CMODE_SILENCE_USERS
-         and SILC_CMODE_SILENCE_OPERS which can be used to moderate
-         the channel.  Updated protocol specs and impelemented this
-         to client and server.  Protocol TODO #6.  Affected files are
-         silcd/packet_receive.c, server_util.c, lib/silcclient/command.c,
-         lib/silcclient/client_channel.c, lib/silccore/silcmode.h.
-
-         Added new options m and M to CMODE command in Irssi SILC
-         client to set these modes.
-
-       * Deprecated all administrative commands from SILC protocol
-         since they are highly implementation specific commands.
-         Updated protocol specs.  Moved the old commands in 
-         implementations to private range of command types.  Affected
-         files are silcd/command.c, lib/silcclient/command.c and
-         lib/silcclient/command_reply.c.  Protocol TODO #8.
-
-       * Fixed a bug in server where sending unknown command crashes
-         the server.  Affected file silcd/command.c.
-
-Wed Apr  3 09:57:47 CEST 2002  Pekka Riikonen <priikone@silcnet.org>
-
-       * Added SILC_PROTOCOLVERSION macro to check protocol version
-         of a socket connection.  The affected file is 
-         lib/silcutil/silcsockconn.h.
-
-       * Added better error logging in rekey protocol.  Affected file
-         silcd/protocol.c.
+        * Added better error logging in rekey protocol.  Affected file
+          silcd/protocol.c.
 
-       * Do not check public key types in SKE during rekey.  Affected
-         file lib/silcske/payload.c.
+        * Do not check public key types in SKE during rekey.  Affected
+          file lib/silcske/payload.c.
 
-       * Fixed the rekey protocol with PFS, which was totally broken.
-         Affected file silcd/protocol.c.
-
-Tue Apr  2 14:55:06 CEST 2002  Pekka Riikonen <priikone@silcnet.org>
-
-       * Some client implementations quit network by doing first LEAVE
-         and then immediately SIGNOFF (like Bombyx).  We now do check 
-         after a short time after LEAVE notify and check whether the 
-         client is still valid after LEAVE, and if not we remove it from 
-         cache.  Affected file is lib/silcclient/client_notify.c.
+        * Fixed the rekey protocol with PFS, which was totally broken.
+          Affected file silcd/protocol.c.
 
 Tue Apr  2 13:39:04 CEST 2002  Johnny Mnemonic <johnny@themnemonic.org>
 
@@ -287,22 +39,8 @@ Mon Apr  1 20:15:10 CEST 2002  Johnny Mnemonic <johnny@themnemonic.org>
 
        * ROBOdoc documented lib/silcutil/silcutil.h.
 
-Sat Mar 30 21:06:45 EET 2002  Pekka Riikonen <priikone@silcnet.org>
-
-       * Optimized even more the SilcPacketContext structure.  Now
-         totally saved 16 bytes of memory per context after optimization.
-         Affected files are lib/silccore/silcpacket.[ch].
-
-       * Made strict checks for valid SILC IDs.  Affected file is
-         lib/silccore/silcid.c.
-
 Sat Mar 30 18:15:55 EET 2002  Pekka Riikonen <priikone@silcnet.org>
 
-       * Changed the object argument for silc_cipher_register,
-         silc_hash_register, silc_hmac_register and silc_pkcs_register
-         to const.  Affected files are lib/silccrypt/silccipher.[ch],
-         silchash.[ch], silchmac.[ch] and silcpkcs.[ch].
-
        * Changed the silc_get_username and silc_get_real_name to
          never fail.  Affected file lib/silcutil/unix/silcunixutil.c.
 
@@ -316,15 +54,6 @@ Sat Mar 30 18:15:55 EET 2002  Pekka Riikonen <priikone@silcnet.org>
          get_home_dir to Irssi routines.  Affected files are
          irssi/src/core/misc.[ch] and irssi/src/core/core.c.
 
-Fri Mar 29 21:55:41 EET 2002  Pekka Riikonen <priikone@silcnet.org>
-
-       * Made some structure optimizations.  SFTP memory FS MemFSEntry
-         entry structure.  Optimized SilcTask structure.  Optimized
-         SilcPacketContext structure.
-
-         Affected files lib/silcsftp/sftp_fs_memory.c,
-         lib/silcutil/silcschedule.c, lib/silccore/silcpacket.h.
-
 Fri Mar 29 10:41:07 EET 2002  Pekka Riikonen <priikone@silcnet.org>
 
        * And yet again reverted back the config thing since Johnny
diff --git a/TODO b/TODO
index afa8ad7445eb2783a697ae0979c0098f038b241b..75f219f1e16414625d628a6785840c860eda6cc6 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,6 +1,9 @@
 TODO/bugs in Irssi SILC client
 ==============================
 
+ o Does not show ops and normal users on JOIN correctly, perhaps some
+   theme issue (Fix this to 0.8.x).
+
  o /cumode for unknown nick does not give any error message (Fix this to
    1.0).
 
@@ -14,10 +17,12 @@ TODO/bugs In SILC Client Library
    set the key only if application wishes to set (accept the key) it
    (Do this to 1.0).
 
- o Remove conn->current_channel.
-
  o Additions to do after protocol version 1.1:
 
+       o Fix the NICK_CHANGE notify handling not to create new entry
+         for the changed client, but take the nickname from the notify
+         (removes need for resolving as well).  Protocol TODO entry 3.
+
        o Add support for list of errors in command replies.  Protocol
          TODO entry 1.
 
@@ -42,6 +47,7 @@ TODO/bugs In SILC Server
 
        o JOIN (check that joining is allowed)
        o SIGNOFF (maybe should check that notifier owns the client)
+       o KILLED (check that killling is allowed (Protocol TODO #13))
 
  o Backup router related issues (Fix this to 1.0):
 
@@ -106,6 +112,18 @@ Current protocol version is 1.0.  However, it is far from being perfect,
 and needs to include additional features.  Following protocol TODO entries
 describe new stuff to be added to protocol versions 1.x.
 
+ 1. Re-define the Status Payload: it is now 16 bits, split it into two
+    8 bits fields.  First field includes status types from 0 - 9 and
+    10 - n *if* it is not an list of errors.  If it is list of errors then
+    the first field includes 1, 2 and/or 3, and the second field includes
+    the error status 10 - n.  This way it is possible to send multiple
+    errors (list of errors) and we have a way to tell the receiver that
+    there will be other errors as well.  The second field is used only
+    if there is list of errors.  If normal status, or normal (single)
+    error status the second field is set to zero, and must be ignored.
+    Hence, the status works same way as now except for list of errors.
+    To be included in protocol version 1.1.
+
  2. Define that WHOIS and IDENTIFY commands must send list of errors
     if multiple Client ID (or Channel ID and Server ID for IDENTIFY) was
     requested and was not found.  Each unfound entry must cause an error
@@ -113,6 +131,13 @@ describe new stuff to be added to protocol versions 1.x.
     *after* sending successfully found entries (this way receiver may
     ignore them).  To be included in protocol version 1.1.
 
+ 3. Define the NICK_CHANGE notify to send the changed nickname as a new
+    third argument.  This will make the NICK_CHANGE notify handling easier
+    in the receiver's end (client primarily) since it removes the
+    requirement that receiver must resolve (using IDENTIFY or WHOIS) the
+    new Client ID received in the notify (because of the new nickname is
+    unknown).  To be included in protocol version 1.1.
+
  4. Add "request parameters" or similar to the WHOIS command, which can
     be used to request various parameters (something not returned by
     standard WHOIS command) about clients (info that could be fetched
@@ -123,23 +148,49 @@ describe new stuff to be added to protocol versions 1.x.
     new features without always making the command incompatible to previous
     version.  To be included in protocol version 1.1.
 
- 17. Cell wide channel founder support, and permanent channels when
-     founder mode set.
-
- 20. Services support?
-
- 21. Subscription/IRC's notify kind support?
-
- o Inviting and banning by public key should be made possible.  To be
-   included in protocol version 1.2.
-
- o UTF-8 support/requirement for nicknames & channel names.  UTF-8 support
-   in terminals and OS's are so hazy that this matter is left for
-   consideration in next version of the protocol (1.2).  For good UTF-8
-   reference and tutorial see: http://www.cl.cam.ac.uk/~mgk25/unicode.html.
-   What should CLI application do if it receives nickname that it cannot
-   display without messing up the terminal?  If UTF-8 is mandatory in
-   SILC then SILC clients cannot be allowed to start on terminals that do
-   not support UTF-8 (which renders 98% of users unable to use CLI SILC
-   app without hacking their environment).  See also site
-   http://gratrix.net/unicode/
+ 5. Inviting and banning by public key should be made possible.  To be
+    included in protocol version 1.x.
+
+ 6. Add perhaps SILENCE_USERS, SILENCE_OPERS channel user modes which
+    can be used to silence (moderate) normal users and opers (this set
+    only by founder).  To be included in protocol version 1.1.
+
+ 7. Channel Message Payload needs slight redesining to include the IV
+    field to the MAC generation of the payload.  It is authenticated
+    by the packet's MAC but not by the payload's MAC.  Since the IV
+    belongs to the payload, its integrity should be protected by the
+    payload MAC and not alone by packet MAC.  To be included in protocol 
+    version 1.1.
+
+ 8. Remove the administrative commands from the protocol all together.
+    It does not make sense for the protocol to define how a server is
+    reconnected or shutdown, since they are implementation and 
+    configuration issues.  Besides protocol provides only limited set of
+    administrative commands and cannot define all that one could imagine.
+    To be included in protocol version 1.1.
+
+ 9. Add SILC_MESAGE_FLAG_REPLY for being other side to the
+    SILC_MESSAGE_FLAG_REQUEST.  Add generic SILC_MESSAGE_FLAG_DATA, which
+    can include generic payload, which can include generic data.  The
+    payload definition is left out for now.  To be included in protocol
+    version 1.1.
+
+ 10. Check command reply error status types in various commands,
+     specifically NO_FOPRIV is missing from many commands.  To be 
+     included in protocol version 1.1.
+
+ 11. Change the wording in Private Message Key Payload definition to
+     describe the problems of trusting the payload, and to indicate that
+     the receiver may not accept the key in the payload, and to describe
+     other means of distributing a key.
+
+ 13. Add the killer's client ID to the KILLED notify.  To be included in 
+     protocol version 1.1.
+
+ 14. The length of Arguments Num field in Notify Payload and Command
+     Payload enforces that total of 256 arguments can be associated
+     to a such payload.  However, command-xx draft specified much higher
+     values, and these should be fixed.
+
+ 15. The LEAVE command reply should return the Channel ID of the channel
+     that was parted.
index 1dfbaf494ecf55786e56d21fe4e10a9d55d18f20..afda54a93b5b1cba192eff44076874341fab1851 100644 (file)
--- a/TODO-1.0
+++ b/TODO-1.0
@@ -67,7 +67,7 @@ least could be done.
 
          These naturally cause the overal memory consumption to grow
          but would take away many allocations that can be done several
-         times in a second (see also ~/silcpacket).
+         times in a second.
 
        o Move the actual file descriptor task callback (the callback that
          handles the incoming data, outgoing data etc, that is implemnted
@@ -90,6 +90,23 @@ least could be done.
          SILC_BUFFER_LEN macro can do the same.  These would save
          totally 8 bytes of memory per buffer.
 
+       o Scheduler can be optimized for FD tasks by changing the fd_queue
+         to SilcHashTable instead of using linked list.  We need to do
+         one-to-one mapping of FD to task and hash table is more efficient
+         for this usage.
+
+         Also redefine the silc_select to perhaps return a separate
+         structure of the events that actually occurred, instead of
+         returning the events in the fd_list which is then traversed
+         in the generic code to find the changed events.  This can be
+         made faster by having own struct which includes only the
+         changed events, thus the tarversing is faster since the whole
+         fd_list is not traversed anymore (it is still traversed in the
+         silc_select but at least it removes one extra tarversing later
+         for the same list).
+
+         Other task queues should be changed to use SilcList.
+
  o Optimizations in Server
 
        o Remove the big switch statement from the function 
@@ -122,20 +139,18 @@ least could be done.
 
  o Rewrite SilcProtocol to be SilcFSM (see ~/silcfsm).
 
- o Do some scheduler optimizations and interface changes (see 
-   ~/silcschedule).
-
- o Change the lib/silccore/silcpacket.[ch] interfaces (see ~/silcpacket).
-
- o Add abstract SilcStream and SilcSocketStream (see ~/silcstream).
-
- o Change some of the SILC Net interfaces (see ~/silcnet).
+ o Change SILC_TASK_CALLBACK to non-static, and remove the macro
+   SILC_TASK_CALLBACK_GLOBAL.
 
  o Add DSS support.
 
  o SILC RNG does not implement random seed files, and they should be
    implemented.
 
+ o Add SILC scheduler's internal routines into a table of implementation
+   function pointers, that the generic code then takes as extern from
+   implementation.  These are the silc_schedule_internal_* routines.
+
  o Cipher optimizations (asm, that this) at least for i386 would be nice.
 
  o Add builtin SOCKS and HTTP Proxy support, well the SOCKS at least.
@@ -152,5 +167,3 @@ least could be done.
        o Something needs to be thought to the logging globals as well, 
          like silc_debug etc.  They won't work on EPOC.  Perhaps logging
          and debugging is to be disabled on EPOC.
-
- o Check whether we can fully comply with RFC 2779.
index b9e49b81ec652fe01370e8a0ffc00bf8dd2411de..4370809edcd99d912e4aed7176d89159b4dd53f3 100644 (file)
@@ -13,12 +13,6 @@ option(s).  The following modes are available:
     i               Set/unset channel as invite only channel
     t               Set/unset that only channel operator or 
                     founder may set channel topic
-    m               Set/unset user silencing.  Normal users
-                    are not able to talk on channel.  Only
-                    channel founder may set this mode
-    M               Set/unset operator silencing.  Operators
-                    are not able to talk on channel.  Only
-                    channel founder may set this mode
     l <limit>       Set/unset channel's user limit
     a <passphrase>  Set/unset passphrase for channel that must
                     be provided when joining to the channel.
index 03d249654368a891cda476045e8a6f13cffedab0..9bba22f3feb98fe8c0906f0af4d5728c929a5cf0 100644 (file)
@@ -31,13 +31,4 @@ are available:
         Set/unset channel operator.  Requires that 
         you are channel operator or channel founder.
 
-    b <nickname>[@<server>]
-
-        Set/unset channel message blocking.  Client
-        may set this mode only to itself.  When set
-        the server will not send channel message to
-        to the client.  This mode can be used to block
-        unwanted messages if desired.
-
-
 See also: CMODE, UMODE
index 757fcfc9cf12868c23a548daf19e0617c69570ca..a833a0d0243a88293eddb86913a579a31e0a9dae 100644 (file)
@@ -11,16 +11,5 @@ modes are available:
     s        Unset server operator privileges
     r        Unset router operator privileges
     g        Set/unset to be gone (or use /AWAY command)
-    i        Set/unset to be indisposed
-    b        Set/unset to be busy
-    p        Set/unset to await paging
-    h        Set/unset to be hyper active
-    t        Set/unset to be actually robot
-    P        Set/unset to block incoming private messages.
-             If set then only private message secured with
-             private message keys are delivered.  Other
-             private messages server automatically discards.
-             This can be used to block unwanted private
-             messages.
 
 See also: CMODE, CUMODE, AWAY
index a886132904715ac1ede6f8100a27073f2d4c1cbb..6ac3306f20b9d3efe41801fcaab49fa664a86fc2 100644 (file)
@@ -43,10 +43,10 @@ FORMAT_REC fecommon_silc_formats[] = {
        { "ban_list", "channel {channel $0} ban list: $1", 2, { 0, 0 } },
        { "no_ban_list", "channel {channel $0} ban list not set", 1, { 0 } },
        { "inviting", "Inviting {nick $0} to channel {channel $1}", 2, { 0, 0 } },
-       { "kicked_you", "You have been kicked off channel {channel $0} by {nick $1} ($2)", 3, { 0, 0, 0 } },
-       { "kicked", "{nick $0} has been kicked off channel {channel $1} by {nick $2} ($3)", 4, { 0, 0, 0, 0 } },
-       { "killed_you", "You have been killed from the SILC Network by {nick $0} ($1)", 2, { 0, 0 } },
-       { "killed", "{nick $0} has been killed from the SILC Network by {nick $1} ($2)", 3, { 0, 0, 0 } },
+       { "kicked_you", "You have been kicked off channel {channel $0} by {nick $1} ($2)", 3, { 0, 0 } },
+       { "kicked", "{nick $0} has been kicked off channel {channel $1} by {nick $2} ($3)", 4, { 0, 0, 0 } },
+       { "killed_you", "You have been killed from the SILC Network", 0 },
+       { "killed", "{nick $0} has been killed from the SILC Network ($1)", 2, { 0, 0 } },
 
        /* WHOIS, WHOWAS and USERS (alias WHO) messages */
        { NULL, "Who Queries", 0 },
index 5a5ee7b54ca127dfeadd24424f798b4a1bac6665..16415900889e9d758e0eb05ad89f1f77f0ee7bfd 100644 (file)
@@ -81,8 +81,7 @@ void silc_say_error(char *msg, ...)
 
 void silc_channel_message(SilcClient client, SilcClientConnection conn,
                          SilcClientEntry sender, SilcChannelEntry channel,
-                         SilcMessageFlags flags, const unsigned char *message,
-                         SilcUInt32 message_len)
+                         SilcMessageFlags flags, char *msg)
 {
   SILC_SERVER_REC *server;
   SILC_NICK_REC *nick;
@@ -90,7 +89,7 @@ void silc_channel_message(SilcClient client, SilcClientConnection conn,
   
   SILC_LOG_DEBUG(("Start"));
 
-  if (!message)
+  if (!msg)
     return;
 
   server = conn == NULL ? NULL : conn->context;
@@ -109,13 +108,13 @@ void silc_channel_message(SilcClient client, SilcClientConnection conn,
   if (flags & SILC_MESSAGE_FLAG_ACTION)
     printformat_module("fe-common/silc", server, channel->channel_name,
                       MSGLEVEL_ACTIONS, SILCTXT_CHANNEL_ACTION, 
-                       nick == NULL ? "[<unknown>]" : nick->nick, message);
+                       nick == NULL ? "[<unknown>]" : nick->nick, msg);
   else if (flags & SILC_MESSAGE_FLAG_NOTICE)
     printformat_module("fe-common/silc", server, channel->channel_name,
                       MSGLEVEL_NOTICES, SILCTXT_CHANNEL_NOTICE, 
-                       nick == NULL ? "[<unknown>]" : nick->nick, message);
+                       nick == NULL ? "[<unknown>]" : nick->nick, msg);
   else
-    signal_emit("message public", 6, server, message,
+    signal_emit("message public", 6, server, msg,
                nick == NULL ? "[<unknown>]" : nick->nick,
                nick == NULL ? "" : nick->host == NULL ? "" : nick->host,
                chanrec->name, nick);
@@ -126,8 +125,7 @@ void silc_channel_message(SilcClient client, SilcClientConnection conn,
 
 void silc_private_message(SilcClient client, SilcClientConnection conn,
                          SilcClientEntry sender, SilcMessageFlags flags,
-                         const unsigned char *message,
-                         SilcUInt32 message_len)
+                         char *msg)
 {
   SILC_SERVER_REC *server;
   char userhost[256];
@@ -139,7 +137,7 @@ void silc_private_message(SilcClient client, SilcClientConnection conn,
   if (sender->username)
     snprintf(userhost, sizeof(userhost) - 1, "%s@%s",
             sender->username, sender->hostname);
-  signal_emit("message private", 4, server, message,
+  signal_emit("message private", 4, server, msg,
              sender->nickname ? sender->nickname : "[<unknown>]",
              sender->username ? userhost : NULL);
 }
@@ -319,7 +317,7 @@ void silc_notify(SilcClient client, SilcClientConnection conn,
       signal_emit("message topic", 5, server, channel->channel_name,
                  tmp, server_entry->server_name, 
                  server_entry->server_name);
-    } else if (idtype == SILC_ID_CHANNEL) {
+    } else {
       channel = (SilcChannelEntry)entry;
       signal_emit("message topic", 5, server, channel->channel_name,
                  tmp, channel->channel_name, channel->channel_name);
@@ -335,9 +333,6 @@ void silc_notify(SilcClient client, SilcClientConnection conn,
 
     client_entry = va_arg(va, SilcClientEntry);
     client_entry2 = va_arg(va, SilcClientEntry);
-
-    if (!strcmp(client_entry->nickname, client_entry2->nickname))
-      break;
     
     memset(userhost, 0, sizeof(userhost));
     snprintf(userhost, sizeof(userhost) - 1, "%s@%s",
@@ -388,7 +383,7 @@ void silc_notify(SilcClient client, SilcClientConnection conn,
                         MSGLEVEL_MODES, SILCTXT_CHANNEL_CMODE,
                         channel->channel_name, tmp ? tmp : "removed all",
                         server_entry->server_name);
-    } else if (idtype == SILC_ID_CHANNEL) {
+    } else {
       channel2 = (SilcChannelEntry)entry;
       printformat_module("fe-common/silc", server, channel->channel_name,
                         MSGLEVEL_MODES, SILCTXT_CHANNEL_CMODE,
@@ -442,7 +437,7 @@ void silc_notify(SilcClient client, SilcClientConnection conn,
                         channel->channel_name, client_entry2->nickname, 
                         tmp ? tmp : "removed all",
                         server_entry->server_name);
-    } else if (idtype == SILC_ID_CHANNEL) {
+    } else {
       channel2 = (SilcChannelEntry)entry;
       printformat_module("fe-common/silc", server, channel->channel_name,
                         MSGLEVEL_MODES, SILCTXT_CHANNEL_CUMODE,
@@ -521,27 +516,11 @@ void silc_notify(SilcClient client, SilcClientConnection conn,
 
     client_entry = va_arg(va, SilcClientEntry);
     tmp = va_arg(va, char *);
-    idtype = va_arg(va, int);
-    entry = va_arg(va, SilcClientEntry);
   
     if (client_entry == conn->local_entry) {
-      if (idtype == SILC_ID_CLIENT) {
-       client_entry2 = (SilcClientEntry)entry;
-       printformat_module("fe-common/silc", server, NULL,
-                          MSGLEVEL_CRAP, SILCTXT_CHANNEL_KILLED_YOU, 
-                          client_entry2 ? client_entry2->nickname : "",
-                          tmp ? tmp : "");
-      } else if (idtype == SILC_ID_SERVER) {
-       server_entry = (SilcServerEntry)entry;
-       printformat_module("fe-common/silc", server, NULL,
-                          MSGLEVEL_CRAP, SILCTXT_CHANNEL_KILLED_YOU, 
-                          server_entry->server_name, tmp ? tmp : "");
-      } else if (idtype == SILC_ID_CHANNEL) {
-       channel = (SilcChannelEntry)entry;
-       printformat_module("fe-common/silc", server, NULL,
-                          MSGLEVEL_CRAP, SILCTXT_CHANNEL_KILLED_YOU, 
-                          channel->channel_name, tmp ? tmp : "");
-      }
+      printformat_module("fe-common/silc", server, NULL,
+                        MSGLEVEL_CRAP, SILCTXT_CHANNEL_KILLED_YOU, 
+                        tmp ? tmp : "");
     } else {
       list1 = nicklist_get_same_unique(SERVER(server), client_entry);
       for (list_tmp = list1; list_tmp != NULL; list_tmp = 
@@ -551,26 +530,10 @@ void silc_notify(SilcClient client, SilcClientConnection conn,
        nicklist_remove(channel, nickrec);
       }
 
-      if (idtype == SILC_ID_CLIENT) {
-       client_entry2 = (SilcClientEntry)entry;
-       printformat_module("fe-common/silc", server, NULL,
-                          MSGLEVEL_CRAP, SILCTXT_CHANNEL_KILLED, 
-                          client_entry->nickname,
-                          client_entry2 ? client_entry2->nickname : "",
-                          tmp ? tmp : "");
-      } else if (idtype == SILC_ID_SERVER) {
-       server_entry = (SilcServerEntry)entry;
-       printformat_module("fe-common/silc", server, NULL,
-                          MSGLEVEL_CRAP, SILCTXT_CHANNEL_KILLED, 
-                          client_entry->nickname,
-                          server_entry->server_name, tmp ? tmp : "");
-      } else if (idtype == SILC_ID_CHANNEL) {
-       channel = (SilcChannelEntry)entry;
-       printformat_module("fe-common/silc", server, NULL,
-                          MSGLEVEL_CRAP, SILCTXT_CHANNEL_KILLED, 
-                          client_entry->nickname,
-                          channel->channel_name, tmp ? tmp : "");
-      }
+      printformat_module("fe-common/silc", server, NULL,
+                        MSGLEVEL_CRAP, SILCTXT_CHANNEL_KILLED, 
+                        client_entry->nickname,
+                        tmp ? tmp : "");
     }
     break;
 
@@ -628,48 +591,23 @@ void silc_notify(SilcClient client, SilcClientConnection conn,
    or connecting failed.  This is also the first time application receives
    the SilcClientConnection object which it should save somewhere. */
 
-void silc_connect(SilcClient client, SilcClientConnection conn,
-                 SilcClientConnectionStatus status)
+void silc_connect(SilcClient client, SilcClientConnection conn, int success)
 {
   SILC_SERVER_REC *server = conn->context;
 
-  if (!server) {
-    silc_client_close_connection(client, conn);
+  if (!server && !success) {
+    silc_client_close_connection(client, NULL, conn);
     return;
   }
 
-  switch (status) {
-  case SILC_CLIENT_CONN_SUCCESS:
-    /* We have successfully connected to server */
-    server->connected = TRUE;
-    signal_emit("event connected", 1, server);
-    break;
-
-  case SILC_CLIENT_CONN_SUCCESS_RESUME:
-    /* We have successfully resumed old detached session */
+  if (success) {
     server->connected = TRUE;
     signal_emit("event connected", 1, server);
-
-    /* If we resumed old session check whether we need to update 
-       our nickname */
-    if (strcmp(server->nick, conn->local_entry->nickname)) {
-      char *old;
-      old = g_strdup(server->nick);
-      server_change_nick(SERVER(server), conn->local_entry->nickname);
-      nicklist_rename_unique(SERVER(server), 
-                            conn->local_entry, server->nick,
-                            conn->local_entry, conn->local_entry->nickname);
-      signal_emit("message own_nick", 4, server, server->nick, old, "");
-      g_free(old);
-    }
-    break;
-
-  default:
+  } else {
     server->connection_lost = TRUE;
     if (server->conn)
       server->conn->context = NULL;
     server_disconnect(SERVER(server));
-    break;
   }
 }
 
@@ -681,9 +619,6 @@ void silc_disconnect(SilcClient client, SilcClientConnection conn)
 
   SILC_LOG_DEBUG(("Start"));
 
-  if (!server || server->connection_lost)
-    return;
-
   if (server->conn && server->conn->local_entry) {
     nicklist_rename_unique(SERVER(server),
                           server->conn->local_entry, server->nick,
@@ -749,9 +684,6 @@ static void silc_client_join_get_users(SilcClient client,
   SilcClientEntry founder = NULL;
   NICK_REC *ownnick;
 
-  SILC_LOG_DEBUG(("Start, channel %s, %d users", channel->channel_name,
-                 silc_hash_table_count(channel->user_list)));
-
   if (!clients)
     return;
 
@@ -772,7 +704,6 @@ static void silc_client_join_get_users(SilcClient client,
   ownnick = NICK(silc_nicklist_find(chanrec, conn->local_entry));
   nicklist_set_own(CHANNEL(chanrec), ownnick);
   signal_emit("channel joined", 1, chanrec);
-  chanrec->entry = channel;
 
   if (chanrec->topic)
     printformat_module("fe-common/silc", server, channel->channel_name,
@@ -859,7 +790,7 @@ silc_command_reply(SilcClient client, SilcClientConnection conn,
       char buf[1024], *nickname, *username, *realname, *nick;
       unsigned char *fingerprint;
       SilcUInt32 idle, mode;
-      SilcBuffer channels, user_modes;
+      SilcBuffer channels;
       SilcClientEntry client_entry;
       
       if (status == SILC_STATUS_ERR_NO_SUCH_NICK) {
@@ -904,7 +835,6 @@ silc_command_reply(SilcClient client, SilcClientConnection conn,
       mode = va_arg(vp, SilcUInt32);
       idle = va_arg(vp, SilcUInt32);
       fingerprint = va_arg(vp, unsigned char *);
-      user_modes = va_arg(vp, SilcBuffer);
       
       silc_parse_userfqdn(nickname, &nick, NULL);
       printformat_module("fe-common/silc", server, NULL, MSGLEVEL_CRAP,
@@ -915,20 +845,16 @@ silc_command_reply(SilcClient client, SilcClientConnection conn,
                         SILCTXT_WHOIS_REALNAME, realname);
       silc_free(nick);
 
-      if (channels && user_modes) {
-       SilcUInt32 *umodes;
+      if (channels) {
        SilcDList list = silc_channel_payload_parse_list(channels->data,
                                                         channels->len);
-       if (list && silc_get_mode_list(user_modes, silc_dlist_count(list),
-                                      &umodes)) {
+       if (list) {
          SilcChannelPayload entry;
-         int i = 0;
-
          memset(buf, 0, sizeof(buf));
          silc_dlist_start(list);
          while ((entry = silc_dlist_get(list)) != SILC_LIST_END) {
+           char *m = silc_client_chumode_char(silc_channel_get_mode(entry));
            SilcUInt32 name_len;
-           char *m = silc_client_chumode_char(umodes[i++]);
            char *name = silc_channel_get_name(entry, &name_len);
            
            if (m)
@@ -941,7 +867,6 @@ silc_command_reply(SilcClient client, SilcClientConnection conn,
          printformat_module("fe-common/silc", server, NULL, MSGLEVEL_CRAP,
                             SILCTXT_WHOIS_CHANNELS, buf);
          silc_channel_payload_list_free(list);
-         silc_free(umodes);
        }
       }
       
@@ -951,28 +876,12 @@ silc_command_reply(SilcClient client, SilcClientConnection conn,
        if ((mode & SILC_UMODE_SERVER_OPERATOR) ||
            (mode & SILC_UMODE_ROUTER_OPERATOR)) {
          strcat(buf, (mode & SILC_UMODE_SERVER_OPERATOR) ?
-                "Server Operator" :
+                "Server Operator " :
                 (mode & SILC_UMODE_ROUTER_OPERATOR) ?
-                "SILC Operator" : "[Unknown mode]");
+                "SILC Operator " : "[Unknown mode] ");
        }
        if (mode & SILC_UMODE_GONE)
-         strcat(buf, " [away]");
-       if (mode & SILC_UMODE_INDISPOSED)
-         strcat(buf, " [indisposed]");
-       if (mode & SILC_UMODE_BUSY)
-         strcat(buf, " [busy]");
-       if (mode & SILC_UMODE_PAGE)
-         strcat(buf, " [page to reach]");
-       if (mode & SILC_UMODE_HYPER)
-         strcat(buf, " [hyper active]");
-       if (mode & SILC_UMODE_ROBOT)
-         strcat(buf, " [robot]");
-       if (mode & SILC_UMODE_ANONYMOUS)
-         strcat(buf, " [anonymous]");
-       if (mode & SILC_UMODE_BLOCK_PRIVMSG)
-         strcat(buf, " [blocks private messages]");
-       if (mode & SILC_UMODE_DETACHED)
-         strcat(buf, " [detached]");
+         strcat(buf, "away");
 
        printformat_module("fe-common/silc", server, NULL, MSGLEVEL_CRAP,
                           SILCTXT_WHOIS_MODES, buf);
@@ -1262,20 +1171,8 @@ silc_command_reply(SilcClient client, SilcClientConnection conn,
        mode = silc_client_chumode_char(chu->mode);
        if (e->mode & SILC_UMODE_GONE)
          strcat(stat, "G");
-       else if (e->mode & SILC_UMODE_INDISPOSED)
-         strcat(stat, "I");
-       else if (e->mode & SILC_UMODE_BUSY)
-         strcat(stat, "B");
-       else if (e->mode & SILC_UMODE_PAGE)
-         strcat(stat, "P");
-       else if (e->mode & SILC_UMODE_HYPER)
-         strcat(stat, "H");
-       else if (e->mode & SILC_UMODE_ROBOT)
-         strcat(stat, "R");
-       else if (e->mode & SILC_UMODE_ANONYMOUS)
-         strcat(stat, "?");
        else
-         strcat(stat, "A");
+         strcat(stat, "H");
        if (mode)
          strcat(stat, mode);
 
@@ -1861,13 +1758,6 @@ int silc_key_agreement(SilcClient client, SilcClientConnection conn,
   return FALSE;
 }
 
-/* Notifies application that file transfer protocol session is being
-   requested by the remote client indicated by the `client_entry' from
-   the `hostname' and `port'. The `session_id' is the file transfer
-   session and it can be used to either accept or reject the file
-   transfer request, by calling the silc_client_file_receive or
-   silc_client_file_close, respectively. */
-
 void silc_ftp(SilcClient client, SilcClientConnection conn,
              SilcClientEntry client_entry, SilcUInt32 session_id,
              const char *hostname, SilcUInt16 port)
@@ -1899,37 +1789,6 @@ void silc_ftp(SilcClient client, SilcClientConnection conn,
                       client_entry->nickname, hostname, portstr);
 }
 
-/* Delivers SILC session detachment data indicated by `detach_data' to the
-   application.  If application has issued SILC_COMMAND_DETACH command
-   the client session in the SILC network is not quit.  The client remains
-   in the network but is detached.  The detachment data may be used later
-   to resume the session in the SILC Network.  The appliation is
-   responsible of saving the `detach_data', to for example in a file.
-
-   The detachment data can be given as argument to the functions
-   silc_client_connect_to_server, or silc_client_add_connection when
-   creating connection to remote server, inside SilcClientConnectionParams
-   structure.  If it is provided the client library will attempt to resume
-   the session in the network.  After the connection is created
-   successfully, the application is responsible of setting the user
-   interface for user into the same state it was before detaching (showing
-   same channels, channel modes, etc).  It can do this by fetching the
-   information (like joined channels) from the client library. */
-
-void
-silc_detach(SilcClient client, SilcClientConnection conn,
-            const unsigned char *detach_data, SilcUInt32 detach_data_len)
-{
-  char file[256];
-
-  /* Save the detachment data to file. */
-
-  memset(file, 0, sizeof(file));
-  snprintf(file, sizeof(file) - 1, "%s/session", get_irssi_dir());
-  silc_file_writefile(file, detach_data, detach_data_len);
-}
-
-
 /* SILC client operations */
 SilcClientOperations ops = {
   silc_say,
@@ -1946,5 +1805,4 @@ SilcClientOperations ops = {
   silc_failure,
   silc_key_agreement,
   silc_ftp,
-  silc_detach,
 };
index 60fda7ae1b9452001b67f9088a92738519e2614f..69682f69b8157ace526dfff601ebfcc159d3a70c 100644 (file)
@@ -27,14 +27,10 @@ void silc_say_error(char *msg, ...);
 void silc_channel_message(SilcClient client, SilcClientConnection conn,
                          SilcClientEntry sender, 
                          SilcChannelEntry channel, 
-                         SilcMessageFlags flags, 
-                         const unsigned char *message,
-                         SilcUInt32 message_len);
+                         SilcMessageFlags flags, char *msg);
 void silc_private_message(SilcClient client, SilcClientConnection conn,
                          SilcClientEntry sender, 
-                         SilcMessageFlags flags, 
-                         const unsigned char *message,
-                         SilcUInt32 message_len);
+                         SilcMessageFlags flags, char *msg);
 void silc_notify(SilcClient client, SilcClientConnection conn, 
                 SilcNotifyType type, ...);
 void silc_command(SilcClient client, SilcClientConnection conn, 
@@ -43,8 +39,7 @@ void silc_command(SilcClient client, SilcClientConnection conn,
 void silc_command_reply(SilcClient client, SilcClientConnection conn,
                        SilcCommandPayload cmd_payload, int success,
                        SilcCommand command, SilcCommandStatus status, ...);
-void silc_connect(SilcClient client, SilcClientConnection conn,
-                 SilcClientConnectionStatus status);
+void silc_connect(SilcClient client, SilcClientConnection conn, int success);
 void silc_disconnect(SilcClient client, SilcClientConnection conn);
 void silc_ask_passphrase(SilcClient client, SilcClientConnection conn,
                         SilcAskPassphrase completion, void *context);
@@ -64,8 +59,5 @@ int silc_key_agreement(SilcClient client, SilcClientConnection conn,
 void silc_ftp(SilcClient client, SilcClientConnection conn,
              SilcClientEntry client_entry, SilcUInt32 session_id,
              const char *hostname, SilcUInt16 port);
-void
-silc_detach(SilcClient client, SilcClientConnection conn,
-            const unsigned char *detach_data, SilcUInt32 detach_data_len);
 
 #endif
index 114f03af65d3a9e3e65e958c586f1901e3a0ffb1..6c9c7f2a2193dfe8e762a4e176215e4807841339 100644 (file)
@@ -166,7 +166,7 @@ static void silc_register_cipher(SilcClient client, const char *cipher)
   if (cipher) {
     for (i = 0; silc_default_ciphers[i].name; i++)
       if (!strcmp(silc_default_ciphers[i].name, cipher)) {
-       silc_cipher_register(&(silc_default_ciphers[i]));
+       silc_cipher_register((SilcCipherObject *)&silc_default_ciphers[i]);
        break;
       }
     
@@ -187,7 +187,7 @@ static void silc_register_hash(SilcClient client, const char *hash)
   if (hash) {
     for (i = 0; silc_default_hash[i].name; i++)
       if (!strcmp(silc_default_hash[i].name, hash)) {
-       silc_hash_register(&(silc_default_hash[i]));
+       silc_hash_register((SilcHashObject *)&silc_default_hash[i]);
        break;
       }
     
@@ -208,7 +208,7 @@ static void silc_register_hmac(SilcClient client, const char *hmac)
   if (hmac) {
     for (i = 0; silc_default_hmacs[i].name; i++)
       if (!strcmp(silc_default_hmacs[i].name, hmac)) {
-       silc_hmac_register(&(silc_default_hmacs[i]));
+       silc_hmac_register((SilcHmacObject *)&silc_default_hmacs[i]);
        break;
       }
     
index 835e20bc579345fdb42603f05ccc69eec238a2f4..7c3a69184d55f2e87f06a363bb0b7a7277491eca 100644 (file)
@@ -41,8 +41,6 @@
 #include "window-item-def.h"
 
 #include "fe-common/core/printtext.h"
-#include "fe-common/core/fe-channels.h"
-#include "fe-common/core/keyboard.h"
 #include "fe-common/silc/module-formats.h"
 
 #include "silc-commands.h"
@@ -56,11 +54,9 @@ static void silc_send_channel(SILC_SERVER_REC *server,
   SILC_CHANNEL_REC *rec;
   
   rec = silc_channel_find(server, channel);
-  if (rec == NULL || rec->entry == NULL) {
-    cmd_return_error(CMDERR_NOT_JOINED);
+  if (rec == NULL || rec->entry == NULL)
     return;
-  }
-
+  
   silc_client_send_channel_message(silc_client, server->conn, rec->entry, 
                                   NULL, 0, msg, strlen(msg), TRUE);
 }
@@ -196,37 +192,18 @@ static void send_message(SILC_SERVER_REC *server, char *target,
 static void sig_connected(SILC_SERVER_REC *server)
 {
   SilcClientConnection conn;
-  SilcClientConnectionParams params;
-  char file[256];
   int fd;
 
   if (!IS_SILC_SERVER(server))
     return;
 
-  /* Try to read detached session data and use it if found. */
-  memset(&params, 0, sizeof(params));
-  memset(file, 0, sizeof(file));
-  snprintf(file, sizeof(file) - 1, "%s/session", get_irssi_dir());
-  params.detach_data = silc_file_readfile(file, &params.detach_data_len);
-
-  /* Add connection to the client library */
-  conn = silc_client_add_connection(silc_client, &params,
+  conn = silc_client_add_connection(silc_client,
                                    server->connrec->address,
                                    server->connrec->port,
                                    server);
   server->conn = conn;
-
-  if (params.detach_data)
-    keyboard_entry_redirect(NULL,
-                           "-- Resuming old session, may take a while ...",
-                           ENTRY_REDIRECT_FLAG_HIDDEN, server);
-
-  silc_free(params.detach_data);
-  unlink(file);
-
+       
   fd = g_io_channel_unix_get_fd(net_sendbuffer_handle(server->handle));
-
-  /* Start key exchange with the server */
   silc_client_start_key_exchange(silc_client, conn, fd);
 
   server->ftp_sessions = silc_dlist_init();
@@ -244,8 +221,8 @@ static void sig_disconnected(SILC_SERVER_REC *server)
   silc_dlist_uninit(server->ftp_sessions);
 
   if (server->conn && server->conn->sock != NULL) {
-    silc_client_close_connection(silc_client, server->conn);
-
+    silc_client_close_connection(silc_client, NULL, server->conn);
+    
     /* SILC closes the handle */
     g_io_channel_unref(net_sendbuffer_handle(server->handle));
     net_sendbuffer_destroy(server->handle, FALSE);
@@ -348,7 +325,6 @@ char *silc_server_get_channels(SILC_SERVER_REC *server)
 /* SYNTAX: FILE CLOSE [<nickname>] */
 /* SYNTAX: FILE */
 /* SYNTAX: JOIN <channel> [<passphrase>] [-cipher <cipher>] [-hmac <hmac>] [-founder <-pubkey|passwd>] */
-/* SYNTAX: DETACH */
 
 void silc_command_exec(SILC_SERVER_REC *server,
                       const char *command, const char *args)
@@ -898,7 +874,6 @@ void silc_server_init(void)
   command_bind_silc("getkey", MODULE_NAME, (SIGNAL_FUNC) command_self);
   command_bind_silc("sconnect", MODULE_NAME, (SIGNAL_FUNC) command_sconnect);
   command_bind_silc("file", MODULE_NAME, (SIGNAL_FUNC) command_file);
-  command_bind_silc("detach", MODULE_NAME, (SIGNAL_FUNC) command_self);
 
   command_set_options("connect", "+silcnet");
 }
@@ -932,7 +907,6 @@ void silc_server_deinit(void)
   command_unbind("getkey", (SIGNAL_FUNC) command_self);
   command_unbind("sconnect", (SIGNAL_FUNC) command_sconnect);
   command_unbind("file", (SIGNAL_FUNC) command_file);
-  command_unbind("detach", (SIGNAL_FUNC) command_self);
 }
 
 void silc_server_free_ftp(SILC_SERVER_REC *server,
index 184382eaf0b3c14a34332b375cee4fa8d9468390..7000a9ad52b5be825a4b64b1cd0b705e46a338ae 100644 (file)
@@ -56,7 +56,8 @@ SilcServerCommand silc_command_list[] =
   SILC_SERVER_CMD(quit, QUIT, SILC_CF_LAG | SILC_CF_REG),
   SILC_SERVER_CMD(kill, KILL, SILC_CF_LAG_STRICT | SILC_CF_REG | SILC_CF_OPER),
   SILC_SERVER_CMD(info, INFO, SILC_CF_LAG | SILC_CF_REG),
-  SILC_SERVER_CMD(stats, STATS, SILC_CF_LAG | SILC_CF_REG),
+  SILC_SERVER_CMD(connect, CONNECT, 
+                 SILC_CF_LAG | SILC_CF_REG | SILC_CF_OPER),
   SILC_SERVER_CMD(ping, PING, SILC_CF_LAG | SILC_CF_REG),
   SILC_SERVER_CMD(oper, OPER, SILC_CF_LAG | SILC_CF_REG | SILC_CF_OPER),
   SILC_SERVER_CMD(join, JOIN, SILC_CF_LAG_STRICT | SILC_CF_REG),
@@ -66,20 +67,16 @@ SilcServerCommand silc_command_list[] =
   SILC_SERVER_CMD(cumode, CUMODE, SILC_CF_LAG | SILC_CF_REG),
   SILC_SERVER_CMD(kick, KICK, SILC_CF_LAG_STRICT | SILC_CF_REG),
   SILC_SERVER_CMD(ban, BAN, SILC_CF_LAG_STRICT | SILC_CF_REG),
-  SILC_SERVER_CMD(detach, DETACH, SILC_CF_LAG_STRICT | SILC_CF_REG),
+  SILC_SERVER_CMD(close, CLOSE,
+                 SILC_CF_LAG | SILC_CF_REG | SILC_CF_OPER),
+  SILC_SERVER_CMD(shutdown, SHUTDOWN, SILC_CF_LAG | SILC_CF_REG | 
+                 SILC_CF_OPER),
   SILC_SERVER_CMD(silcoper, SILCOPER,
                  SILC_CF_LAG | SILC_CF_REG | SILC_CF_SILC_OPER),
   SILC_SERVER_CMD(leave, LEAVE, SILC_CF_LAG_STRICT | SILC_CF_REG),
   SILC_SERVER_CMD(users, USERS, SILC_CF_LAG | SILC_CF_REG),
   SILC_SERVER_CMD(getkey, GETKEY, SILC_CF_LAG | SILC_CF_REG),
 
-  SILC_SERVER_CMD(connect, PRIV_CONNECT, 
-                 SILC_CF_LAG | SILC_CF_REG | SILC_CF_OPER),
-  SILC_SERVER_CMD(close, PRIV_CLOSE,
-                 SILC_CF_LAG | SILC_CF_REG | SILC_CF_OPER),
-  SILC_SERVER_CMD(shutdown, PRIV_SHUTDOWN, SILC_CF_LAG | SILC_CF_REG | 
-                 SILC_CF_OPER),
-
   { NULL, 0 },
 };
 
@@ -92,7 +89,7 @@ SilcServerCommand silc_command_list[] =
    of arguments. */
 #define SILC_SERVER_COMMAND_CHECK(command, context, min, max)                \
 do {                                                                         \
-  SilcUInt32 _argc;                                                          \
+  SilcUInt32 _argc;                                                                  \
                                                                              \
   SILC_LOG_DEBUG(("Start"));                                                 \
                                                                              \
@@ -208,7 +205,7 @@ void silc_server_command_process(SilcServer server,
     if (cmd->cmd == command)
       break;
 
-  if (!cmd || !cmd->cb) {
+  if (cmd == NULL) {
     silc_server_command_send_status_reply(ctx, command,
                                          SILC_STATUS_ERR_UNKNOWN_COMMAND);
     silc_server_command_free(ctx);
@@ -396,7 +393,7 @@ silc_server_command_send_status_reply(SilcServerCommandContext cmd,
   SILC_LOG_DEBUG(("Sending command status %d", status));
 
   buffer = 
-    silc_command_reply_payload_encode_va(command, status, 0,
+    silc_command_reply_payload_encode_va(command, status, 
                                         silc_command_get_ident(cmd->payload),
                                         0);
   silc_server_packet_send(cmd->server, cmd->sock,
@@ -421,7 +418,7 @@ silc_server_command_send_status_data(SilcServerCommandContext cmd,
   SILC_LOG_DEBUG(("Sending command status %d", status));
 
   buffer = 
-    silc_command_reply_payload_encode_va(command, status, 0,
+    silc_command_reply_payload_encode_va(command, status, 
                                         silc_command_get_ident(cmd->payload),
                                         1, arg_type, arg, arg_len);
   silc_server_packet_send(cmd->server, cmd->sock,
@@ -440,10 +437,16 @@ silc_server_command_pending_error_check(SilcServerCommandContext cmd,
                                        SilcServerCommandReplyContext cmdr,
                                        SilcCommand command)
 {
+  SilcCommandStatus status;
+
   if (!cmd->pending || !cmdr)
     return FALSE;
 
-  if (!silc_command_get_status(cmdr->payload, NULL, NULL)) {
+  SILC_GET16_MSB(status, silc_argument_get_arg_type(cmdr->args, 1, NULL));
+  if (status != SILC_STATUS_OK &&
+      status != SILC_STATUS_LIST_START &&
+      status != SILC_STATUS_LIST_ITEM &&
+      status != SILC_STATUS_LIST_END) {
     SilcBuffer buffer;
 
     /* Send the same command reply payload */
@@ -701,7 +704,7 @@ silc_server_command_whois_send_reply(SilcServerCommandContext cmd,
   SilcServer server = cmd->server;
   char *tmp;
   int i, k, len, valid_count;
-  SilcBuffer packet, idp, channels, umode_list = NULL;
+  SilcBuffer packet, idp, channels;
   SilcClientEntry entry;
   SilcCommandStatus status;
   SilcUInt16 ident = silc_command_get_ident(cmd->payload);
@@ -782,12 +785,7 @@ silc_server_command_whois_send_reply(SilcServerCommandContext cmd,
       strncat(uh, hsock->hostname, len);
     }
 
-    if (cmd->sock->type == SILC_SOCKET_TYPE_CLIENT)
-      channels = silc_server_get_client_channel_list(server, entry, FALSE, 
-                                                    FALSE, &umode_list);
-    else
-      channels = silc_server_get_client_channel_list(server, entry, TRUE, 
-                                                    TRUE, &umode_list);
+    channels = silc_server_get_client_channel_list(server, entry);
 
     if (entry->data.fingerprint[0] != 0 && entry->data.fingerprint[1] != 0)
       fingerprint = entry->data.fingerprint;
@@ -802,7 +800,7 @@ silc_server_command_whois_send_reply(SilcServerCommandContext cmd,
 
     packet = 
       silc_command_reply_payload_encode_va(SILC_COMMAND_WHOIS,
-                                          status, 0, ident, 9
+                                          status, ident, 8
                                           2, idp->data, idp->len,
                                           3, nh, strlen(nh),
                                           4, uh, strlen(uh),
@@ -813,10 +811,7 @@ silc_server_command_whois_send_reply(SilcServerCommandContext cmd,
                                           7, mode, 4,
                                           8, idle, 4,
                                           9, fingerprint,
-                                          fingerprint ? 20 : 0,
-                                          10, umode_list ? umode_list->data :
-                                          NULL, umode_list ? umode_list->len :
-                                          0);
+                                          fingerprint ? 20 : 0);
 
     silc_server_packet_send(server, cmd->sock, SILC_PACKET_COMMAND_REPLY,
                            0, packet->data, packet->len, FALSE);
@@ -825,10 +820,6 @@ silc_server_command_whois_send_reply(SilcServerCommandContext cmd,
     silc_buffer_free(idp);
     if (channels)
       silc_buffer_free(channels);
-    if (umode_list) {
-      silc_buffer_free(umode_list);
-      umode_list = NULL;
-    }
 
     k++;
   }
@@ -1167,7 +1158,7 @@ silc_server_command_whowas_send_reply(SilcServerCommandContext cmd,
       
     packet = 
       silc_command_reply_payload_encode_va(SILC_COMMAND_WHOWAS,
-                                          status, 0, ident, 4, 
+                                          status, ident, 4, 
                                           2, idp->data, idp->len,
                                           3, nh, strlen(nh),
                                           4, uh, strlen(uh),
@@ -1826,7 +1817,7 @@ silc_server_command_identify_send_reply(SilcServerCommandContext cmd,
 
       if (!entry->username) {
        packet = silc_command_reply_payload_encode_va(SILC_COMMAND_IDENTIFY,
-                                                     status, 0, ident, 2,
+                                                     status, ident, 2,
                                                      2, idp->data, idp->len, 
                                                      3, nh, strlen(nh));
       } else {
@@ -1839,7 +1830,7 @@ silc_server_command_identify_send_reply(SilcServerCommandContext cmd,
        }
        
        packet = silc_command_reply_payload_encode_va(SILC_COMMAND_IDENTIFY,
-                                                     status, 0, ident, 3,
+                                                     status, ident, 3,
                                                      2, idp->data, idp->len, 
                                                      3, nh, strlen(nh),
                                                      4, uh, strlen(uh));
@@ -1877,7 +1868,7 @@ silc_server_command_identify_send_reply(SilcServerCommandContext cmd,
       idp = silc_id_payload_encode(entry->id, SILC_ID_SERVER);
       packet = 
        silc_command_reply_payload_encode_va(SILC_COMMAND_IDENTIFY,
-                                            status, 0, ident, 2,
+                                            status, ident, 2,
                                             2, idp->data, idp->len, 
                                             3, entry->server_name, 
                                             entry->server_name ? 
@@ -1914,7 +1905,7 @@ silc_server_command_identify_send_reply(SilcServerCommandContext cmd,
       idp = silc_id_payload_encode(entry->id, SILC_ID_CHANNEL);
       packet = 
        silc_command_reply_payload_encode_va(SILC_COMMAND_IDENTIFY,
-                                            status, 0, ident, 2,
+                                            status, ident, 2,
                                             2, idp->data, idp->len, 
                                             3, entry->channel_name, 
                                             entry->channel_name ? 
@@ -2026,11 +2017,6 @@ SILC_SERVER_CMD_FUNC(nick)
                                   cmd->server->md5hash, nick,
                                   &new_id)) {
     nickfail++;
-    if (nickfail > 9) {
-      silc_server_command_send_status_reply(cmd, SILC_COMMAND_NICK,
-                                           SILC_STATUS_ERR_BAD_NICKNAME);
-      goto out;
-    }
     snprintf(&nick[strlen(nick) - 1], 1, "%d", nickfail);
   }
 
@@ -2041,7 +2027,7 @@ SILC_SERVER_CMD_FUNC(nick)
     silc_server_send_notify_nick_change(server, server->router->connection, 
                                        server->server_type == SILC_SERVER ? 
                                        FALSE : TRUE, client->id,
-                                       new_id, nick);
+                                       new_id);
 
   oidp = silc_id_payload_encode(client->id, SILC_ID_CLIENT);
 
@@ -2065,16 +2051,14 @@ SILC_SERVER_CMD_FUNC(nick)
 
   /* Send NICK_CHANGE notify to the client's channels */
   silc_server_send_notify_on_channels(server, NULL, client, 
-                                     SILC_NOTIFY_TYPE_NICK_CHANGE, 3,
+                                     SILC_NOTIFY_TYPE_NICK_CHANGE, 2,
                                      oidp->data, oidp->len, 
-                                     nidp->data, nidp->len,
-                                     client->nickname, 
-                                     strlen(client->nickname));
+                                     nidp->data, nidp->len);
 
  send_reply:
   /* Send the new Client ID as reply command back to client */
   packet = silc_command_reply_payload_encode_va(SILC_COMMAND_NICK, 
-                                               SILC_STATUS_OK, 0, ident, 1, 
+                                               SILC_STATUS_OK, ident, 1, 
                                                2, nidp->data, nidp->len);
   silc_server_packet_send(cmd->server, cmd->sock, SILC_PACKET_COMMAND_REPLY,
                          0, packet->data, packet->len, FALSE);
@@ -2149,7 +2133,7 @@ silc_server_command_list_send_reply(SilcServerCommandContext cmd,
     /* Send the reply */
     packet = 
       silc_command_reply_payload_encode_va(SILC_COMMAND_LIST, 
-                                          status, 0, ident, 4,
+                                          status, ident, 4,
                                           2, idp->data, idp->len,
                                           3, entry->channel_name, 
                                           strlen(entry->channel_name),
@@ -2188,7 +2172,7 @@ silc_server_command_list_send_reply(SilcServerCommandContext cmd,
     /* Send the reply */
     packet = 
       silc_command_reply_payload_encode_va(SILC_COMMAND_LIST, 
-                                          status, 0, ident, 4,
+                                          status, ident, 4,
                                           2, idp->data, idp->len,
                                           3, entry->channel_name, 
                                           strlen(entry->channel_name),
@@ -2374,7 +2358,7 @@ SILC_SERVER_CMD_FUNC(topic)
   /* Send the topic to client as reply packet */
   idp = silc_id_payload_encode(channel_id, SILC_ID_CHANNEL);
   packet = silc_command_reply_payload_encode_va(SILC_COMMAND_TOPIC, 
-                                               SILC_STATUS_OK, 0, ident, 2, 
+                                               SILC_STATUS_OK, ident, 2, 
                                                2, idp->data, idp->len,
                                                3, channel->topic, 
                                                channel->topic ? 
@@ -2469,7 +2453,7 @@ SILC_SERVER_CMD_FUNC(invite)
     }
 
     /* Get the client entry */
-    dest = silc_server_get_client_resolve(server, dest_id, FALSE, &resolve);
+    dest = silc_server_get_client_resolve(server, dest_id, &resolve);
     if (!dest) {
       if (server->server_type != SILC_SERVER || !resolve) {
        silc_server_command_send_status_reply(
@@ -2498,8 +2482,7 @@ SILC_SERVER_CMD_FUNC(invite)
     }
     
     /* Get route to the client */
-    dest_sock = silc_server_get_client_route(server, NULL, 0, dest_id, 
-                                            &idata, NULL);
+    dest_sock = silc_server_get_client_route(server, NULL, 0, dest_id, &idata);
     if (!dest_sock) {
       silc_server_command_send_status_reply(cmd, SILC_COMMAND_INVITE,
                                            SILC_STATUS_ERR_NO_SUCH_CLIENT_ID);
@@ -2595,7 +2578,7 @@ SILC_SERVER_CMD_FUNC(invite)
   if (add || del)
     packet = 
       silc_command_reply_payload_encode_va(SILC_COMMAND_INVITE,
-                                          SILC_STATUS_OK, 0, ident, 2,
+                                          SILC_STATUS_OK, ident, 2,
                                           2, tmp, len,
                                           3, channel->invite_list,
                                           channel->invite_list ?
@@ -2603,7 +2586,7 @@ SILC_SERVER_CMD_FUNC(invite)
   else
     packet = 
       silc_command_reply_payload_encode_va(SILC_COMMAND_INVITE,
-                                          SILC_STATUS_OK, 0, ident, 1,
+                                          SILC_STATUS_OK, ident, 1,
                                           2, tmp, len);
   silc_server_packet_send(server, cmd->sock, SILC_PACKET_COMMAND_REPLY, 0, 
                          packet->data, packet->len, FALSE);
@@ -2657,7 +2640,7 @@ SILC_SERVER_CMD_FUNC(quit)
   if (cmd->sock->type != SILC_SOCKET_TYPE_CLIENT)
     goto out;
 
-  /* Get message */
+  /* Get destination ID */
   tmp = silc_argument_get_arg_type(cmd->args, 1, &len);
   if (len > 128)
     tmp = NULL;
@@ -2669,8 +2652,8 @@ SILC_SERVER_CMD_FUNC(quit)
 
   /* We quit the connection with little timeout */
   silc_schedule_task_add(server->schedule, sock->sock,
-                        silc_server_command_quit_cb, (void *)q,
-                        0, 200000, SILC_TASK_TIMEOUT, SILC_TASK_PRI_LOW);
+                    silc_server_command_quit_cb, (void *)q,
+                    0, 200000, SILC_TASK_TIMEOUT, SILC_TASK_PRI_LOW);
 
  out:
   silc_server_command_free(cmd);
@@ -2741,15 +2724,61 @@ SILC_SERVER_CMD_FUNC(kill)
   /* Get comment */
   comment = silc_argument_get_arg_type(cmd->args, 2, &tmp_len2);
   if (tmp_len2 > 128)
-    tmp_len2 = 128;
+    comment = NULL;
 
   /* Send reply to the sender */
   silc_server_command_send_status_reply(cmd, SILC_COMMAND_KILL,
                                        SILC_STATUS_OK);
 
-  /* Now do the killing */
-  silc_server_kill_client(server, remote_client, comment, client->id,
-                         SILC_ID_CLIENT);
+  /* Send the KILL notify packets. First send it to the channel, then
+     to our primary router and then directly to the client who is being
+     killed right now. */
+
+  /* Send KILLED notify to the channels. It is not sent to the client
+     as it will be sent differently destined directly to the client and not
+     to the channel. */
+  silc_server_send_notify_on_channels(server, remote_client, 
+                                     remote_client, SILC_NOTIFY_TYPE_KILLED,
+                                     comment ? 2 : 1,
+                                     tmp, tmp_len,
+                                     comment, comment ? tmp_len2 : 0);
+
+  /* Send KILLED notify to primary route */
+  if (!server->standalone)
+    silc_server_send_notify_killed(server, server->router->connection, TRUE,
+                                  remote_client->id, comment);
+
+  /* Send KILLED notify to the client directly */
+  silc_server_send_notify_killed(server, remote_client->connection ? 
+                                remote_client->connection : 
+                                remote_client->router->connection, FALSE,
+                                remote_client->id, comment);
+
+  /* Remove the client from all channels. This generates new keys to the
+     channels as well. */
+  silc_server_remove_from_channels(server, NULL, remote_client, FALSE, 
+                                  NULL, TRUE);
+
+  /* Remove the client entry, If it is locally connected then we will also
+     disconnect the client here */
+  if (remote_client->connection) {
+    /* Remove locally conneted client */
+    SilcSocketConnection sock = remote_client->connection;
+    silc_server_free_client_data(server, sock, remote_client, FALSE, NULL);
+    silc_server_close_connection(server, sock);
+  } else {
+    /* Update statistics */
+    if (remote_client->connection)
+      server->stat.my_clients--;
+    if (server->server_type == SILC_ROUTER)
+      server->stat.cell_clients--;
+    SILC_OPER_STATS_UPDATE(remote_client, server, SILC_UMODE_SERVER_OPERATOR);
+    SILC_OPER_STATS_UPDATE(remote_client, router, SILC_UMODE_ROUTER_OPERATOR);
+
+    /* Remove remote client */
+    silc_idlist_del_client(local ? server->local_list :
+                          server->global_list, remote_client);
+  }
 
  out:
   silc_server_command_free(cmd);
@@ -2899,7 +2928,7 @@ SILC_SERVER_CMD_FUNC(info)
 
   /* Send the reply */
   packet = silc_command_reply_payload_encode_va(SILC_COMMAND_INFO,
-                                               SILC_STATUS_OK, 0, ident, 3,
+                                               SILC_STATUS_OK, ident, 3,
                                                2, idp->data, idp->len,
                                                3, server_name, 
                                                strlen(server_name),
@@ -2955,102 +2984,6 @@ SILC_SERVER_CMD_FUNC(ping)
   silc_server_command_free(cmd);
 }
 
-/* Server side of command STATS. */
-
-SILC_SERVER_CMD_FUNC(stats)
-{
-  SilcServerCommandContext cmd = (SilcServerCommandContext)context;
-  SilcServer server = cmd->server;
-  SilcServerID *server_id;
-  unsigned char *tmp;
-  SilcUInt32 tmp_len;
-  SilcBuffer packet, stats;
-  SilcUInt16 ident = silc_command_get_ident(cmd->payload);
-  SilcUInt32 uptime;
-
-  SILC_SERVER_COMMAND_CHECK(SILC_COMMAND_STATS, cmd, 1, 1);
-
-  /* Get Server ID */
-  tmp = silc_argument_get_arg_type(cmd->args, 1, &tmp_len);
-  if (!tmp) {
-    silc_server_command_send_status_reply(cmd, SILC_COMMAND_INFO,
-                                         SILC_STATUS_ERR_NO_SERVER_ID);
-    goto out;
-  }
-  server_id = silc_id_payload_parse_id(tmp, tmp_len, NULL);
-  if (!server_id)
-    goto out;
-
-  /* The ID must be ours */
-  if (!SILC_ID_SERVER_COMPARE(server->id, server_id)) {
-    silc_server_command_send_status_reply(cmd, SILC_COMMAND_INFO,
-                                         SILC_STATUS_ERR_NO_SUCH_SERVER);
-    silc_free(server_id);
-    goto out;
-  }
-  silc_free(server_id);
-
-  /* If we are router then just send everything we got. If we are normal
-     server then we'll send this to our router to get all the latest
-     statistical information. */
-  if (!cmd->pending && server->server_type != SILC_ROUTER && 
-      !server->standalone) {
-    /* Send request to our router */
-    SilcBuffer idp = silc_id_payload_encode(server->router->id, 
-                                           SILC_ID_SERVER);
-    packet = silc_command_payload_encode_va(SILC_COMMAND_STATS, 
-                                           ++server->cmd_ident, 1,
-                                           1, idp->data, idp->len);
-    silc_server_packet_send(server, server->router->connection,
-                           SILC_PACKET_COMMAND, 0, packet->data,
-                           packet->len, FALSE);
-
-    /* Reprocess this packet after received reply from router */
-    silc_server_command_pending(server, SILC_COMMAND_STATS, 
-                               server->cmd_ident,
-                               silc_server_command_stats,
-                               silc_server_command_dup(cmd));
-    cmd->pending = TRUE;
-    silc_buffer_free(packet);
-    silc_buffer_free(idp);
-    goto out;
-  }
-
-  /* Send our reply to sender */
-  uptime = time(NULL) - server->starttime;
-
-  stats = silc_buffer_alloc_size(60);
-  silc_buffer_format(stats,
-                    SILC_STR_UI_INT(server->starttime),
-                    SILC_STR_UI_INT(uptime),
-                    SILC_STR_UI_INT(server->stat.my_clients),
-                    SILC_STR_UI_INT(server->stat.my_channels),
-                    SILC_STR_UI_INT(server->stat.my_server_ops),
-                    SILC_STR_UI_INT(server->stat.my_router_ops),
-                    SILC_STR_UI_INT(server->stat.cell_clients),
-                    SILC_STR_UI_INT(server->stat.cell_channels),
-                    SILC_STR_UI_INT(server->stat.cell_servers),
-                    SILC_STR_UI_INT(server->stat.clients),
-                    SILC_STR_UI_INT(server->stat.channels),
-                    SILC_STR_UI_INT(server->stat.servers),
-                    SILC_STR_UI_INT(server->stat.routers),
-                    SILC_STR_UI_INT(server->stat.server_ops),
-                    SILC_STR_UI_INT(server->stat.router_ops),
-                    SILC_STR_END);
-
-  packet = silc_command_reply_payload_encode_va(SILC_COMMAND_STATS, 
-                                               SILC_STATUS_OK, 0, ident, 2,
-                                               2, tmp, tmp_len,
-                                               3, stats->data, stats->len);
-  silc_server_packet_send(server, cmd->sock, SILC_PACKET_COMMAND_REPLY,
-                         0, packet->data, packet->len, FALSE);
-  silc_buffer_free(packet);
-  silc_buffer_free(stats);
-
- out:
-  silc_server_command_free(cmd);
-}
-
 /* Internal routine to join channel. The channel sent to this function
    has been either created or resolved from ID lists. This joins the sent
    client to the channel. */
@@ -3086,8 +3019,7 @@ static void silc_server_command_join_channel(SilcServer server,
   if (cmd->sock->type == SILC_SOCKET_TYPE_CLIENT) {
     client = (SilcClientEntry)sock->user_data;
   } else {
-    client = silc_server_get_client_resolve(server, client_id, FALSE, 
-                                           &resolve);
+    client = silc_server_get_client_resolve(server, client_id, &resolve);
     if (!client) {
       if (cmd->pending)
        goto out;
@@ -3267,9 +3199,7 @@ static void silc_server_command_join_channel(SilcServer server,
 
   if (!(channel->mode & SILC_CHANNEL_MODE_PRIVKEY)) {
     tmp = silc_id_id2str(channel->id, SILC_ID_CHANNEL);
-    keyp = silc_channel_key_payload_encode(silc_id_get_len(channel->id,
-                                                          SILC_ID_CHANNEL), 
-                                          tmp,
+    keyp = silc_channel_key_payload_encode(SILC_ID_CHANNEL_LEN, tmp, 
                                           strlen(channel->channel_key->
                                                  cipher->name),
                                           channel->channel_key->cipher->name,
@@ -3279,7 +3209,7 @@ static void silc_server_command_join_channel(SilcServer server,
 
   reply = 
     silc_command_reply_payload_encode_va(SILC_COMMAND_JOIN,
-                                        SILC_STATUS_OK, 0, ident, 13,
+                                        SILC_STATUS_OK, ident, 13,
                                         2, channel->channel_name,
                                         strlen(channel->channel_name),
                                         3, chidp->data, chidp->len,
@@ -3534,7 +3464,8 @@ SILC_SERVER_CMD_FUNC(join)
 
   /* Check whether the channel was created by our router */
   if (cmd->pending && context2) {
-    SilcServerCommandReplyContext reply = context2;
+    SilcServerCommandReplyContext reply = 
+      (SilcServerCommandReplyContext)context2;
 
     if (silc_command_get(reply->payload) == SILC_COMMAND_JOIN) {
       tmp = silc_argument_get_arg_type(reply->args, 6, NULL);
@@ -3600,15 +3531,13 @@ SILC_SERVER_CMD_FUNC(motd)
       
       motd[motd_len] = 0;
       packet = silc_command_reply_payload_encode_va(SILC_COMMAND_MOTD,
-                                                   SILC_STATUS_OK, 0, 
-                                                   ident, 2,
+                                                   SILC_STATUS_OK, ident, 2,
                                                    2, idp, idp->len,
                                                    3, motd, motd_len);
     } else {
       /* No motd */
       packet = silc_command_reply_payload_encode_va(SILC_COMMAND_MOTD,
-                                                   SILC_STATUS_OK, 0, 
-                                                   ident, 1,
+                                                   SILC_STATUS_OK, ident, 1,
                                                    2, idp, idp->len);
     }
 
@@ -3684,7 +3613,7 @@ SILC_SERVER_CMD_FUNC(motd)
 
     idp = silc_id_payload_encode(server->id_entry->id, SILC_ID_SERVER);
     packet = silc_command_reply_payload_encode_va(SILC_COMMAND_MOTD,
-                                                 SILC_STATUS_OK, 0, ident, 2,
+                                                 SILC_STATUS_OK, ident, 2,
                                                  2, idp, idp->len,
                                                  3, entry->motd,
                                                  entry->motd ? 
@@ -3709,60 +3638,43 @@ SILC_SERVER_CMD_FUNC(umode)
   SilcServer server = cmd->server;
   SilcClientEntry client = (SilcClientEntry)cmd->sock->user_data;
   SilcBuffer packet;
-  unsigned char *tmp_mask, m[4];
-  SilcUInt32 mask = 0;
+  unsigned char *tmp_mask;
+  SilcUInt32 mask;
   SilcUInt16 ident = silc_command_get_ident(cmd->payload);
-  bool set_mask = FALSE;
 
   if (cmd->sock->type != SILC_SOCKET_TYPE_CLIENT)
     goto out;
 
-  SILC_SERVER_COMMAND_CHECK(SILC_COMMAND_UMODE, cmd, 1, 2);
+  SILC_SERVER_COMMAND_CHECK(SILC_COMMAND_UMODE, cmd, 2, 2);
 
   /* Get the client's mode mask */
   tmp_mask = silc_argument_get_arg_type(cmd->args, 2, NULL);
-  if (tmp_mask) {
-    SILC_GET32_MSB(mask, tmp_mask);
-    set_mask = TRUE;
+  if (!tmp_mask) {
+    silc_server_command_send_status_reply(cmd, SILC_COMMAND_UMODE,
+                                         SILC_STATUS_ERR_NOT_ENOUGH_PARAMS);
+    goto out;
   }
+  SILC_GET32_MSB(mask, tmp_mask);
 
-  if (set_mask) {
-    /* Check that mode changing is allowed. */
-    if (!silc_server_check_umode_rights(server, client, mask)) {
-      silc_server_command_send_status_reply(cmd, SILC_COMMAND_UMODE,
-                                           SILC_STATUS_ERR_PERM_DENIED);
-      goto out;
-    }
-
-    /* Anonymous mode cannot be set by client */
-    if (mask & SILC_UMODE_ANONYMOUS) {
-      if (!(client->mode & SILC_UMODE_ANONYMOUS)) {
-       silc_server_command_send_status_reply(cmd, SILC_COMMAND_UMODE,
-                                             SILC_STATUS_ERR_PERM_DENIED);
-       goto out;
-      }
-    } else {
-      if (client->mode & SILC_UMODE_ANONYMOUS) {
-       silc_server_command_send_status_reply(cmd, SILC_COMMAND_UMODE,
-                                             SILC_STATUS_ERR_PERM_DENIED);
-       goto out;
-      }
-    }
+  /* Check that mode changing is allowed. */
+  if (!silc_server_check_umode_rights(server, client, mask)) {
+    silc_server_command_send_status_reply(cmd, SILC_COMMAND_UMODE,
+                                         SILC_STATUS_ERR_PERM_DENIED);
+    goto out;
+  }
 
-    /* Change the mode */
-    client->mode = mask;
+  /* Change the mode */
+  client->mode = mask;
 
-    /* Send UMODE change to primary router */
-    if (!server->standalone)
-      silc_server_send_notify_umode(server, server->router->connection, TRUE,
-                                   client->id, client->mode);
-  }
+  /* Send UMODE change to primary router */
+  if (!server->standalone)
+    silc_server_send_notify_umode(server, server->router->connection, TRUE,
+                                 client->id, client->mode);
 
   /* Send command reply to sender */
-  SILC_PUT32_MSB(client->mode, m);
   packet = silc_command_reply_payload_encode_va(SILC_COMMAND_UMODE,
-                                               SILC_STATUS_OK, 0, ident, 1,
-                                               2, m, sizeof(m));
+                                               SILC_STATUS_OK, ident, 1,
+                                               2, tmp_mask, 4);
   silc_server_packet_send(server, cmd->sock, SILC_PACKET_COMMAND_REPLY, 0, 
                          packet->data, packet->len, FALSE);
   silc_buffer_free(packet);
@@ -3779,17 +3691,16 @@ SILC_SERVER_CMD_FUNC(cmode)
   SilcServer server = cmd->server;
   SilcClientEntry client = (SilcClientEntry)cmd->sock->user_data;
   SilcIDListData idata = (SilcIDListData)client;
-  SilcChannelID *channel_id = NULL;
+  SilcChannelID *channel_id;
   SilcChannelEntry channel;
   SilcChannelClientEntry chl;
   SilcBuffer packet, cidp;
   unsigned char *tmp, *tmp_id, *tmp_mask;
   char *cipher = NULL, *hmac = NULL, *passphrase = NULL;
-  SilcUInt32 mode_mask = 0, tmp_len, tmp_len2;
+  SilcUInt32 mode_mask, tmp_len, tmp_len2;
   SilcUInt16 ident = silc_command_get_ident(cmd->payload);
-  bool set_mask = FALSE;
 
-  SILC_SERVER_COMMAND_CHECK(SILC_COMMAND_CMODE, cmd, 1, 7);
+  SILC_SERVER_COMMAND_CHECK(SILC_COMMAND_CMODE, cmd, 2, 7);
 
   /* Get Channel ID */
   tmp_id = silc_argument_get_arg_type(cmd->args, 1, &tmp_len2);
@@ -3807,10 +3718,12 @@ SILC_SERVER_CMD_FUNC(cmode)
 
   /* Get the channel mode mask */
   tmp_mask = silc_argument_get_arg_type(cmd->args, 2, &tmp_len);
-  if (tmp_mask) {
-    SILC_GET32_MSB(mode_mask, tmp_mask);
-    set_mask = TRUE;
+  if (!tmp_mask) {
+    silc_server_command_send_status_reply(cmd, SILC_COMMAND_CMODE,
+                                         SILC_STATUS_ERR_NOT_ENOUGH_PARAMS);
+    goto out;
   }
+  SILC_GET32_MSB(mode_mask, tmp_mask);
 
   /* Get channel entry */
   channel = silc_idlist_find_channel_by_id(server->local_list, 
@@ -3833,27 +3746,9 @@ SILC_SERVER_CMD_FUNC(cmode)
   }
 
   /* Check that client has rights to change any requested channel modes */
-  if (set_mask && !silc_server_check_cmode_rights(server, channel, chl, 
-                                                 mode_mask)) {
+  if (!silc_server_check_cmode_rights(server, channel, chl, mode_mask)) {
     silc_server_command_send_status_reply(cmd, SILC_COMMAND_CMODE,
-                                         (chl->mode == 0 ? 
-                                          SILC_STATUS_ERR_NO_CHANNEL_PRIV :
-                                          SILC_STATUS_ERR_NO_CHANNEL_FOPRIV));
-    goto out;
-  }
-
-  /* If mode mask was not sent as argument then merely return the current
-     mode mask to the sender. */
-  if (!set_mask) {
-    unsigned char m[4];
-    SILC_PUT32_MSB(channel->mode, m);
-    packet = silc_command_reply_payload_encode_va(SILC_COMMAND_CMODE,
-                                                 SILC_STATUS_OK, 0, ident, 2,
-                                                 2, tmp_id, tmp_len2,
-                                                 3, m, sizeof(m));
-    silc_server_packet_send(server, cmd->sock, SILC_PACKET_COMMAND_REPLY, 0,
-                           packet->data, packet->len, FALSE);
-    silc_buffer_free(packet);
+                                         SILC_STATUS_ERR_NO_CHANNEL_PRIV);
     goto out;
   }
 
@@ -3922,13 +3817,15 @@ SILC_SERVER_CMD_FUNC(cmode)
       }
 
       /* Save the passphrase */
-      passphrase = channel->passphrase = silc_memdup(tmp, strlen(tmp));
+      passphrase = channel->passphrase = strdup(tmp);
     }
   } else {
     if (channel->mode & SILC_CHANNEL_MODE_PASSPHRASE) {
       /* Passphrase mode is unset. remove the passphrase */
-      silc_free(channel->passphrase);
-      channel->passphrase = NULL;
+      if (channel->passphrase) {
+       silc_free(channel->passphrase);
+       channel->passphrase = NULL;
+      }
     }
   }
 
@@ -4150,17 +4047,17 @@ SILC_SERVER_CMD_FUNC(cmode)
 
   /* Send command reply to sender */
   packet = silc_command_reply_payload_encode_va(SILC_COMMAND_CMODE,
-                                               SILC_STATUS_OK, 0, ident, 2,
+                                               SILC_STATUS_OK, ident, 2,
                                                2, tmp_id, tmp_len2,
                                                3, tmp_mask, 4);
   silc_server_packet_send(server, cmd->sock, SILC_PACKET_COMMAND_REPLY, 0, 
                          packet->data, packet->len, FALSE);
     
   silc_buffer_free(packet);
+  silc_free(channel_id);
   silc_buffer_free(cidp);
 
  out:
-  silc_free(channel_id);
   silc_server_command_free(cmd);
 }
 
@@ -4276,23 +4173,23 @@ SILC_SERVER_CMD_FUNC(cumode)
      but themselves. */
   if (chl->mode & SILC_CHANNEL_UMODE_CHANFO && client != target_client) {
     silc_server_command_send_status_reply(cmd, SILC_COMMAND_CUMODE,
-                                         SILC_STATUS_ERR_NO_CHANNEL_FOPRIV);
+                                         SILC_STATUS_ERR_NO_CHANNEL_PRIV);
     goto out;
   }
 
   if (target_mask & SILC_CHANNEL_UMODE_CHANFO) {
-    if (target_client != client) {
-      silc_server_command_send_status_reply(cmd, SILC_COMMAND_CUMODE,
-                                           SILC_STATUS_ERR_NOT_YOU);
-      goto out;
-    }
-
     if (!(chl->mode & SILC_CHANNEL_UMODE_CHANFO)) {
       /* The client tries to claim the founder rights. */
       unsigned char *tmp_auth;
       SilcUInt32 tmp_auth_len, auth_len;
       void *auth;
       
+      if (target_client != client) {
+       silc_server_command_send_status_reply(cmd, SILC_COMMAND_CUMODE,
+                                             SILC_STATUS_ERR_NOT_YOU);
+       goto out;
+      }
+
       if (!(channel->mode & SILC_CHANNEL_MODE_FOUNDER_AUTH) ||
          !channel->founder_key || !idata->public_key ||
          !silc_pkcs_public_key_compare(channel->founder_key, 
@@ -4367,31 +4264,6 @@ SILC_SERVER_CMD_FUNC(cumode)
     }
   }
 
-  if (target_mask & SILC_CHANNEL_UMODE_BLOCK_MESSAGES) {
-    if (target_client != client) {
-      silc_server_command_send_status_reply(cmd, SILC_COMMAND_CUMODE,
-                                           SILC_STATUS_ERR_NOT_YOU);
-      goto out;
-    }
-
-    if (!(chl->mode & SILC_CHANNEL_UMODE_BLOCK_MESSAGES)) {
-      chl->mode |= SILC_CHANNEL_UMODE_BLOCK_MESSAGES;
-      notify = TRUE;
-    }
-  } else {
-    if (chl->mode & SILC_CHANNEL_UMODE_BLOCK_MESSAGES) {
-      if (target_client != client) {
-       silc_server_command_send_status_reply(cmd, SILC_COMMAND_CUMODE,
-                                             SILC_STATUS_ERR_NOT_YOU);
-       goto out;
-      }
-
-      chl->mode &= ~SILC_CHANNEL_UMODE_BLOCK_MESSAGES;
-      notify = TRUE;
-    }
-  }
-
-
   idp = silc_id_payload_encode(client->id, SILC_ID_CLIENT);
   tmp_id = silc_argument_get_arg_type(cmd->args, 3, &tmp_len);
 
@@ -4415,7 +4287,7 @@ SILC_SERVER_CMD_FUNC(cumode)
 
   /* Send command reply to sender */
   packet = silc_command_reply_payload_encode_va(SILC_COMMAND_CUMODE,
-                                               SILC_STATUS_OK, 0, ident, 3,
+                                               SILC_STATUS_OK, ident, 3,
                                                2, tmp_mask, 4,
                                                3, tmp_ch_id, tmp_ch_len,
                                                4, tmp_id, tmp_len);
@@ -4668,61 +4540,6 @@ SILC_SERVER_CMD_FUNC(oper)
   silc_server_command_free(cmd);
 }
 
-SILC_TASK_CALLBACK(silc_server_command_detach_cb)
-{
-  QuitInternal q = (QuitInternal)context;
-  SilcClientEntry client = (SilcClientEntry)q->sock->user_data;
-
-  /* If there is pending outgoing data for the client then purge it
-     to the network before closing connection. */
-  silc_server_packet_queue_purge(q->server, q->sock);
-
-  /* Close the connection on our side */
-  client->router = NULL;
-  client->connection = NULL;
-  q->sock->user_data = NULL;
-  silc_server_close_connection(q->server, q->sock);
-
-  silc_free(q);
-}
-
-/* Server side of DETACH command.  Detached the client from the network
-   by closing the connection but preserving the session. */
-
-SILC_SERVER_CMD_FUNC(detach)
-{
-  SilcServerCommandContext cmd = (SilcServerCommandContext)context;
-  SilcServer server = cmd->server;
-  SilcClientEntry client = (SilcClientEntry)cmd->sock->user_data;
-  QuitInternal q;
-
-  if (cmd->sock->type != SILC_SOCKET_TYPE_CLIENT)
-    goto out;
-
-  SILC_SERVER_COMMAND_CHECK(SILC_COMMAND_DETACH, cmd, 0, 0);
-
-  /* Send the user mode notify to notify that client is detached */
-  client->mode |= SILC_UMODE_DETACHED;
-  client->data.status &= ~SILC_IDLIST_STATUS_RESUMED;
-  if (!server->standalone)
-    silc_server_send_notify_umode(server, server->router->connection,
-                                 server->server_type == SILC_SERVER ?
-                                 FALSE : TRUE, client->id, client->mode);
-
-  q = silc_calloc(1, sizeof(*q));
-  q->server = server;
-  q->sock = cmd->sock;
-  silc_schedule_task_add(server->schedule, 0, silc_server_command_detach_cb,
-                        q, 0, 200000, SILC_TASK_TIMEOUT, SILC_TASK_PRI_LOW);
-
-  /* Send reply to the sender */
-  silc_server_command_send_status_reply(cmd, SILC_COMMAND_DETACH,
-                                       SILC_STATUS_OK);
-
- out:
-  silc_server_command_free(cmd);
-}
-
 /* Server side of SILCOPER command. Client uses this comand to obtain router
    operator privileges to this router. */
 
@@ -4821,6 +4638,61 @@ SILC_SERVER_CMD_FUNC(silcoper)
   silc_server_command_free(cmd);
 }
 
+/* Server side command of CONNECT. Connects us to the specified remote
+   server or router. */
+
+SILC_SERVER_CMD_FUNC(connect)
+{
+  SilcServerCommandContext cmd = (SilcServerCommandContext)context;
+  SilcServer server = cmd->server;
+  SilcClientEntry client = (SilcClientEntry)cmd->sock->user_data;
+  unsigned char *tmp, *host;
+  SilcUInt32 tmp_len;
+  SilcUInt32 port = SILC_PORT;
+
+  SILC_SERVER_COMMAND_CHECK(SILC_COMMAND_CONNECT, cmd, 1, 2);
+
+  if (!client || cmd->sock->type != SILC_SOCKET_TYPE_CLIENT)
+    goto out;
+
+  /* Check whether client has the permissions. */
+  if (client->mode == SILC_UMODE_NONE) {
+    silc_server_command_send_status_reply(cmd, SILC_COMMAND_CONNECT,
+                                         SILC_STATUS_ERR_NO_SERVER_PRIV);
+    goto out;
+  }
+
+  if (server->server_type == SILC_ROUTER && 
+      client->mode & SILC_UMODE_SERVER_OPERATOR) {
+    silc_server_command_send_status_reply(cmd, SILC_COMMAND_CONNECT,
+                                         SILC_STATUS_ERR_NO_ROUTER_PRIV);
+    goto out;
+  }
+
+  /* Get the remote server */
+  host = silc_argument_get_arg_type(cmd->args, 1, &tmp_len);
+  if (!host) {
+    silc_server_command_send_status_reply(cmd, SILC_COMMAND_CONNECT,
+                                         SILC_STATUS_ERR_NOT_ENOUGH_PARAMS);
+    goto out;
+  }
+
+  /* Get port */
+  tmp = silc_argument_get_arg_type(cmd->args, 2, &tmp_len);
+  if (tmp)
+    SILC_GET32_MSB(port, tmp);
+
+  /* Create the connection. It is done with timeout and is async. */
+  silc_server_create_connection(server, host, port);
+
+  /* Send reply to the sender */
+  silc_server_command_send_status_reply(cmd, SILC_COMMAND_CONNECT,
+                                       SILC_STATUS_OK);
+
+ out:
+  silc_server_command_free(cmd);
+}
+
 /* Server side of command BAN. This is used to manage the ban list of the
    channel. To add clients and remove clients from the ban list. */
 
@@ -4929,7 +4801,7 @@ SILC_SERVER_CMD_FUNC(ban)
   /* Send the reply back to the client */
   packet = 
     silc_command_reply_payload_encode_va(SILC_COMMAND_BAN,
-                                        SILC_STATUS_OK, 0, ident, 2,
+                                        SILC_STATUS_OK, ident, 2,
                                         2, id, id_len,
                                         3, channel->ban_list, 
                                         channel->ban_list ? 
@@ -4944,6 +4816,111 @@ SILC_SERVER_CMD_FUNC(ban)
   silc_server_command_free(cmd);
 }
 
+/* Server side command of CLOSE. Closes connection to a specified server. */
+SILC_SERVER_CMD_FUNC(close)
+{
+  SilcServerCommandContext cmd = (SilcServerCommandContext)context;
+  SilcServer server = cmd->server;
+  SilcClientEntry client = (SilcClientEntry)cmd->sock->user_data;
+  SilcServerEntry server_entry;
+  SilcSocketConnection sock;
+  unsigned char *tmp;
+  SilcUInt32 tmp_len;
+  unsigned char *name;
+  SilcUInt32 port = SILC_PORT;
+
+  SILC_SERVER_COMMAND_CHECK(SILC_COMMAND_CLOSE, cmd, 1, 2);
+
+  if (!client || cmd->sock->type != SILC_SOCKET_TYPE_CLIENT)
+    goto out;
+
+  /* Check whether client has the permissions. */
+  if (client->mode == SILC_UMODE_NONE) {
+    silc_server_command_send_status_reply(cmd, SILC_COMMAND_CLOSE,
+                                         SILC_STATUS_ERR_NO_SERVER_PRIV);
+    goto out;
+  }
+
+  /* Get the remote server */
+  name = silc_argument_get_arg_type(cmd->args, 1, &tmp_len);
+  if (!name) {
+    silc_server_command_send_status_reply(cmd, SILC_COMMAND_CLOSE,
+                                         SILC_STATUS_ERR_NOT_ENOUGH_PARAMS);
+    goto out;
+  }
+
+  /* Get port */
+  tmp = silc_argument_get_arg_type(cmd->args, 2, &tmp_len);
+  if (tmp)
+    SILC_GET32_MSB(port, tmp);
+
+  server_entry = silc_idlist_find_server_by_conn(server->local_list,
+                                                name, port, FALSE, NULL);
+  if (!server_entry)
+    server_entry = silc_idlist_find_server_by_conn(server->global_list,
+                                                  name, port, FALSE, NULL);
+  if (!server_entry) {
+    silc_server_command_send_status_reply(cmd, SILC_COMMAND_CLOSE,
+                                         SILC_STATUS_ERR_NO_SERVER_ID);
+    goto out;
+  }
+
+  /* Send reply to the sender */
+  silc_server_command_send_status_reply(cmd, SILC_COMMAND_CLOSE,
+                                       SILC_STATUS_OK);
+
+  /* Close the connection to the server */
+  sock = (SilcSocketConnection)server_entry->connection;
+
+  /* If we shutdown primary router connection manually then don't trigger
+     any reconnect or backup router connections, by setting the router
+     to NULL here. */
+  if (server->router == server_entry) {
+    server->id_entry->router = NULL;
+    server->router = NULL;
+    server->standalone = TRUE;
+  }
+  silc_server_free_sock_user_data(server, sock, NULL);
+  silc_server_close_connection(server, sock);
+  
+ out:
+  silc_server_command_free(cmd);
+}
+
+/* Server side command of SHUTDOWN. Shutdowns the server and closes all
+   active connections. */
+SILC_SERVER_CMD_FUNC(shutdown)
+{
+  SilcServerCommandContext cmd = (SilcServerCommandContext)context;
+  SilcServer server = cmd->server;
+  SilcClientEntry client = (SilcClientEntry)cmd->sock->user_data;
+
+  SILC_SERVER_COMMAND_CHECK(SILC_COMMAND_SHUTDOWN, cmd, 0, 0);
+
+  if (!client || cmd->sock->type != SILC_SOCKET_TYPE_CLIENT)
+    goto out;
+
+  /* Check whether client has the permission. */
+  if (client->mode == SILC_UMODE_NONE) {
+    silc_server_command_send_status_reply(cmd, SILC_COMMAND_SHUTDOWN,
+                                         SILC_STATUS_ERR_NO_SERVER_PRIV);
+    goto out;
+  }
+
+  /* Send reply to the sender */
+  silc_server_command_send_status_reply(cmd, SILC_COMMAND_SHUTDOWN,
+                                       SILC_STATUS_OK);
+
+  /* Then, gracefully, or not, bring the server down. */
+  silc_server_stop(server);
+  exit(0);
+
+ out:
+  silc_server_command_free(cmd);
+}
 /* Server side command of LEAVE. Removes client from a channel. */
 
 SILC_SERVER_CMD_FUNC(leave)
@@ -4998,8 +4975,8 @@ SILC_SERVER_CMD_FUNC(leave)
                                  server->server_type == SILC_ROUTER ?
                                  TRUE : FALSE, channel, id_entry->id);
 
-  silc_server_command_send_status_data(cmd, SILC_COMMAND_LEAVE,
-                                      SILC_STATUS_OK, 2, tmp, len);
+  silc_server_command_send_status_reply(cmd, SILC_COMMAND_LEAVE,
+                                       SILC_STATUS_OK);
 
   /* Remove client from channel */
   if (!silc_server_remove_from_one_channel(server, sock, channel, id_entry,
@@ -5075,7 +5052,7 @@ SILC_SERVER_CMD_FUNC(users)
     channel = silc_idlist_find_channel_by_name(server->local_list, 
                                               channel_name, NULL);
 
-  if (!channel || channel->disabled || !channel->users_resolved) {
+  if (!channel || channel->disabled) {
     if (server->server_type != SILC_ROUTER && !server->standalone &&
        !cmd->pending) {
       SilcBuffer tmpbuf;
@@ -5115,13 +5092,20 @@ SILC_SERVER_CMD_FUNC(users)
   }
 
   /* If the channel is private or secret do not send anything, unless the
-     user requesting this command is on the channel or is server */
+     user requesting this command is on the channel. */
   if (cmd->sock->type == SILC_SOCKET_TYPE_CLIENT) {
     if (channel->mode & (SILC_CHANNEL_MODE_PRIVATE | SILC_CHANNEL_MODE_SECRET)
        && !silc_server_client_on_channel(cmd->sock->user_data, channel, 
                                          NULL)) {
       silc_server_command_send_status_reply(cmd, SILC_COMMAND_USERS,
-                                           SILC_STATUS_ERR_NOT_ON_CHANNEL);
+                                           SILC_STATUS_ERR_NO_SUCH_CHANNEL);
+      goto out;
+    }
+  } else {
+    if (channel->mode & 
+       (SILC_CHANNEL_MODE_PRIVATE | SILC_CHANNEL_MODE_SECRET)) {
+      silc_server_command_send_status_reply(cmd, SILC_COMMAND_USERS,
+                                           SILC_STATUS_ERR_NO_SUCH_CHANNEL);
       goto out;
     }
   }
@@ -5136,7 +5120,7 @@ SILC_SERVER_CMD_FUNC(users)
   /* Send reply */
   idp = silc_id_payload_encode(channel->id, SILC_ID_CHANNEL);
   packet = silc_command_reply_payload_encode_va(SILC_COMMAND_USERS,
-                                               SILC_STATUS_OK, 0, ident, 4,
+                                               SILC_STATUS_OK, ident, 4,
                                                2, idp->data, idp->len,
                                                3, lc, 4,
                                                4, client_id_list->data,
@@ -5204,15 +5188,14 @@ SILC_SERVER_CMD_FUNC(getkey)
                                             client_id, TRUE, NULL);
     
     if ((!client && !cmd->pending && !server->standalone) ||
-       (client && !client->connection && !cmd->pending &&
-        !(client->mode & SILC_UMODE_DETACHED)) ||
+       (client && !client->connection && !cmd->pending) ||
        (client && !client->data.public_key && !cmd->pending)) {
       SilcBuffer tmpbuf;
       SilcUInt16 old_ident;
       SilcSocketConnection dest_sock;
       
       dest_sock = silc_server_get_client_route(server, NULL, 0, 
-                                              client_id, NULL, NULL);
+                                              client_id, NULL);
       if (!dest_sock)
        goto out;
       
@@ -5332,7 +5315,7 @@ SILC_SERVER_CMD_FUNC(getkey)
 
   tmp = silc_argument_get_arg_type(cmd->args, 1, &tmp_len);
   packet = silc_command_reply_payload_encode_va(SILC_COMMAND_GETKEY,
-                                               SILC_STATUS_OK, 0, ident, 
+                                               SILC_STATUS_OK, ident, 
                                                pkdata ? 2 : 1,
                                                2, tmp, tmp_len,
                                                3, pkdata, pklen);
@@ -5350,166 +5333,3 @@ SILC_SERVER_CMD_FUNC(getkey)
   silc_free(server_id);
   silc_server_command_free(cmd);
 }
-
-
-/* Private range commands, specific to this implementation */
-
-/* Server side command of CONNECT. Connects us to the specified remote
-   server or router. */
-
-SILC_SERVER_CMD_FUNC(connect)
-{
-  SilcServerCommandContext cmd = (SilcServerCommandContext)context;
-  SilcServer server = cmd->server;
-  SilcClientEntry client = (SilcClientEntry)cmd->sock->user_data;
-  unsigned char *tmp, *host;
-  SilcUInt32 tmp_len;
-  SilcUInt32 port = SILC_PORT;
-
-  SILC_SERVER_COMMAND_CHECK(SILC_COMMAND_PRIV_CONNECT, cmd, 1, 2);
-
-  if (!client || cmd->sock->type != SILC_SOCKET_TYPE_CLIENT)
-    goto out;
-
-  /* Check whether client has the permissions. */
-  if (client->mode == SILC_UMODE_NONE) {
-    silc_server_command_send_status_reply(cmd, SILC_COMMAND_PRIV_CONNECT,
-                                         SILC_STATUS_ERR_NO_SERVER_PRIV);
-    goto out;
-  }
-
-  if (server->server_type == SILC_ROUTER && 
-      client->mode & SILC_UMODE_SERVER_OPERATOR) {
-    silc_server_command_send_status_reply(cmd, SILC_COMMAND_PRIV_CONNECT,
-                                         SILC_STATUS_ERR_NO_ROUTER_PRIV);
-    goto out;
-  }
-
-  /* Get the remote server */
-  host = silc_argument_get_arg_type(cmd->args, 1, &tmp_len);
-  if (!host) {
-    silc_server_command_send_status_reply(cmd, SILC_COMMAND_PRIV_CONNECT,
-                                         SILC_STATUS_ERR_NOT_ENOUGH_PARAMS);
-    goto out;
-  }
-
-  /* Get port */
-  tmp = silc_argument_get_arg_type(cmd->args, 2, &tmp_len);
-  if (tmp)
-    SILC_GET32_MSB(port, tmp);
-
-  /* Create the connection. It is done with timeout and is async. */
-  silc_server_create_connection(server, host, port);
-
-  /* Send reply to the sender */
-  silc_server_command_send_status_reply(cmd, SILC_COMMAND_PRIV_CONNECT,
-                                       SILC_STATUS_OK);
-
- out:
-  silc_server_command_free(cmd);
-}
-
-/* Server side command of CLOSE. Closes connection to a specified server. */
-SILC_SERVER_CMD_FUNC(close)
-{
-  SilcServerCommandContext cmd = (SilcServerCommandContext)context;
-  SilcServer server = cmd->server;
-  SilcClientEntry client = (SilcClientEntry)cmd->sock->user_data;
-  SilcServerEntry server_entry;
-  SilcSocketConnection sock;
-  unsigned char *tmp;
-  SilcUInt32 tmp_len;
-  unsigned char *name;
-  SilcUInt32 port = SILC_PORT;
-
-  SILC_SERVER_COMMAND_CHECK(SILC_COMMAND_PRIV_CLOSE, cmd, 1, 2);
-
-  if (!client || cmd->sock->type != SILC_SOCKET_TYPE_CLIENT)
-    goto out;
-
-  /* Check whether client has the permissions. */
-  if (client->mode == SILC_UMODE_NONE) {
-    silc_server_command_send_status_reply(cmd, SILC_COMMAND_PRIV_CLOSE,
-                                         SILC_STATUS_ERR_NO_SERVER_PRIV);
-    goto out;
-  }
-
-  /* Get the remote server */
-  name = silc_argument_get_arg_type(cmd->args, 1, &tmp_len);
-  if (!name) {
-    silc_server_command_send_status_reply(cmd, SILC_COMMAND_PRIV_CLOSE,
-                                         SILC_STATUS_ERR_NOT_ENOUGH_PARAMS);
-    goto out;
-  }
-
-  /* Get port */
-  tmp = silc_argument_get_arg_type(cmd->args, 2, &tmp_len);
-  if (tmp)
-    SILC_GET32_MSB(port, tmp);
-
-  server_entry = silc_idlist_find_server_by_conn(server->local_list,
-                                                name, port, FALSE, NULL);
-  if (!server_entry)
-    server_entry = silc_idlist_find_server_by_conn(server->global_list,
-                                                  name, port, FALSE, NULL);
-  if (!server_entry) {
-    silc_server_command_send_status_reply(cmd, SILC_COMMAND_PRIV_CLOSE,
-                                         SILC_STATUS_ERR_NO_SERVER_ID);
-    goto out;
-  }
-
-  /* Send reply to the sender */
-  silc_server_command_send_status_reply(cmd, SILC_COMMAND_PRIV_CLOSE,
-                                       SILC_STATUS_OK);
-
-  /* Close the connection to the server */
-  sock = (SilcSocketConnection)server_entry->connection;
-
-  /* If we shutdown primary router connection manually then don't trigger
-     any reconnect or backup router connections, by setting the router
-     to NULL here. */
-  if (server->router == server_entry) {
-    server->id_entry->router = NULL;
-    server->router = NULL;
-    server->standalone = TRUE;
-  }
-  silc_server_free_sock_user_data(server, sock, NULL);
-  silc_server_close_connection(server, sock);
-  
- out:
-  silc_server_command_free(cmd);
-}
-
-/* Server side command of SHUTDOWN. Shutdowns the server and closes all
-   active connections. */
-SILC_SERVER_CMD_FUNC(shutdown)
-{
-  SilcServerCommandContext cmd = (SilcServerCommandContext)context;
-  SilcServer server = cmd->server;
-  SilcClientEntry client = (SilcClientEntry)cmd->sock->user_data;
-
-  SILC_SERVER_COMMAND_CHECK(SILC_COMMAND_PRIV_SHUTDOWN, cmd, 0, 0);
-
-  if (!client || cmd->sock->type != SILC_SOCKET_TYPE_CLIENT)
-    goto out;
-
-  /* Check whether client has the permission. */
-  if (client->mode == SILC_UMODE_NONE) {
-    silc_server_command_send_status_reply(cmd, SILC_COMMAND_PRIV_SHUTDOWN,
-                                         SILC_STATUS_ERR_NO_SERVER_PRIV);
-    goto out;
-  }
-
-  /* Send reply to the sender */
-  silc_server_command_send_status_reply(cmd, SILC_COMMAND_PRIV_SHUTDOWN,
-                                       SILC_STATUS_OK);
-
-  /* Then, gracefully, or not, bring the server down. */
-  silc_server_stop(server);
-  exit(0);
-
- out:
-  silc_server_command_free(cmd);
-}
index 229a37597f81fab7f037398662907e168c37df97..95fbcdd2443e579c303aa711882fe84b31556cfb 100644 (file)
@@ -130,24 +130,24 @@ SILC_SERVER_CMD_FUNC(invite);
 SILC_SERVER_CMD_FUNC(quit);
 SILC_SERVER_CMD_FUNC(kill);
 SILC_SERVER_CMD_FUNC(info);
-SILC_SERVER_CMD_FUNC(stats);
+SILC_SERVER_CMD_FUNC(connect);
 SILC_SERVER_CMD_FUNC(ping);
 SILC_SERVER_CMD_FUNC(oper);
+SILC_SERVER_CMD_FUNC(pass);
+SILC_SERVER_CMD_FUNC(admin);
 SILC_SERVER_CMD_FUNC(join);
 SILC_SERVER_CMD_FUNC(motd);
 SILC_SERVER_CMD_FUNC(umode);
 SILC_SERVER_CMD_FUNC(cmode);
 SILC_SERVER_CMD_FUNC(cumode);
 SILC_SERVER_CMD_FUNC(kick);
+SILC_SERVER_CMD_FUNC(ignore);
 SILC_SERVER_CMD_FUNC(ban);
-SILC_SERVER_CMD_FUNC(detach);
+SILC_SERVER_CMD_FUNC(close);
+SILC_SERVER_CMD_FUNC(shutdown);
 SILC_SERVER_CMD_FUNC(silcoper);
 SILC_SERVER_CMD_FUNC(leave);
 SILC_SERVER_CMD_FUNC(users);
 SILC_SERVER_CMD_FUNC(getkey);
 
-SILC_SERVER_CMD_FUNC(connect);
-SILC_SERVER_CMD_FUNC(close);
-SILC_SERVER_CMD_FUNC(shutdown);
-
 #endif
index 13e6c8db2f752c65aaabd631db176aeec5cbe339..099d03d902817fb4051849a909f25c0faad1d97f 100644 (file)
 #include "server_internal.h"
 #include "command_reply.h"
 
-/* All functions that call the COMMAND_CHECK_STATUS macros must have
-   out: goto label. */
-
-#define COMMAND_CHECK_STATUS                                   \
-do {                                                           \
-  SILC_LOG_DEBUG(("Start"));                                   \
-  if (!silc_command_get_status(cmd->payload, &status, &error)) \
-    goto out;                                                  \
+/* All functions that call the COMMAND_CHECK_STATUS or the
+   COMMAND_CHECK_STATUS_LIST macros must have out: goto label. */
+
+#define COMMAND_CHECK_STATUS                                             \
+do {                                                                     \
+  SILC_LOG_DEBUG(("Start"));                                             \
+  SILC_GET16_MSB(status, silc_argument_get_arg_type(cmd->args, 1, NULL)); \
+  if (status != SILC_STATUS_OK)                                                  \
+    goto out;                                                            \
+} while(0)
+
+#define COMMAND_CHECK_STATUS_LIST                                        \
+do {                                                                     \
+  SILC_LOG_DEBUG(("Start"));                                             \
+  SILC_GET16_MSB(status, silc_argument_get_arg_type(cmd->args, 1, NULL)); \
+  if (status != SILC_STATUS_OK &&                                        \
+      status != SILC_STATUS_LIST_START &&                                \
+      status != SILC_STATUS_LIST_ITEM &&                                 \
+      status != SILC_STATUS_LIST_END)                                    \
+    goto out;                                                            \
 } while(0)
 
 /* Server command reply list. Not all commands have reply function as
@@ -43,7 +55,6 @@ SilcServerCommandReply silc_command_reply_list[] =
   SILC_SERVER_CMD_REPLY(info, INFO),
   SILC_SERVER_CMD_REPLY(motd, MOTD),
   SILC_SERVER_CMD_REPLY(join, JOIN),
-  SILC_SERVER_CMD_REPLY(stats, STATS),
   SILC_SERVER_CMD_REPLY(users, USERS),
   SILC_SERVER_CMD_REPLY(getkey, GETKEY),
   SILC_SERVER_CMD_REPLY(list, LIST),
@@ -121,22 +132,27 @@ static char
 silc_server_command_reply_whois_save(SilcServerCommandReplyContext cmd)
 {
   SilcServer server = cmd->server;
-  unsigned char *tmp, *id_data, *umodes;
+  unsigned char *tmp, *id_data;
   char *nickname, *username, *realname, *servername = NULL;
   unsigned char *fingerprint;
   SilcClientID *client_id;
   SilcClientEntry client;
-  SilcIDCacheEntry cache = NULL;
   char global = FALSE;
   char *nick;
-  SilcUInt32 mode = 0, len, len2, id_len, flen;
+  SilcUInt32 mode = 0, len, id_len, flen;
+  int expire = 0;
 
   id_data = silc_argument_get_arg_type(cmd->args, 2, &id_len);
   nickname = silc_argument_get_arg_type(cmd->args, 3, &len);
   username = silc_argument_get_arg_type(cmd->args, 4, &len);
   realname = silc_argument_get_arg_type(cmd->args, 5, &len);
-  if (!id_data || !nickname || !username || !realname)
+  if (!id_data || !nickname || !username || !realname) {
+    SILC_LOG_ERROR(("Incomplete WHOIS info: %s %s %s",
+                   nickname ? nickname : "",
+                   username ? username : "",
+                   realname ? realname : ""));
     return FALSE;
+  }
 
   tmp = silc_argument_get_arg_type(cmd->args, 7, &len);
   if (tmp)
@@ -210,34 +226,19 @@ silc_server_command_reply_whois_save(SilcServerCommandReplyContext cmd)
     client->data.status |= SILC_IDLIST_STATUS_RESOLVED;
     client->data.status &= ~SILC_IDLIST_STATUS_RESOLVING;
 
+    /* If client is global and is not on any channel then add that we'll
+       expire the entry after a while. */
+    if (global && !silc_hash_table_count(client->channels) &&
+       server->server_type == SILC_SERVER)
+      expire = time(NULL) + 300;
+
     /* Create new cache entry */
     silc_idcache_add(global ? server->global_list->clients :
                     server->local_list->clients, nick, client->id, 
-                    client, 0, &cache); 
+                    client, expire, NULL); 
     silc_free(client_id);
   }
 
-  /* Save channel list if it was sent to us */
-  if (server->server_type == SILC_SERVER) {
-    tmp = silc_argument_get_arg_type(cmd->args, 6, &len);
-    umodes = silc_argument_get_arg_type(cmd->args, 10, &len2);
-    if (tmp && umodes) {
-      SilcBufferStruct channels_buf, umodes_buf;
-      silc_buffer_set(&channels_buf, tmp, len);
-      silc_buffer_set(&umodes_buf, umodes, len2);
-      silc_server_save_user_channels(server, cmd->sock, client, &channels_buf,
-                                    &umodes_buf);
-    } else {
-      silc_server_save_user_channels(server, cmd->sock, client, NULL, NULL);
-    }
-
-    if (cache)
-      /* If client is global and is not on any channel then add that we'll
-        expire the entry after a while. */
-      if (global && !silc_hash_table_count(client->channels))
-       cache->expire = time(NULL) + 300;
-  }
-
   if (fingerprint && flen == sizeof(client->data.fingerprint))
     memcpy(client->data.fingerprint, fingerprint, flen);
 
@@ -254,9 +255,9 @@ SILC_SERVER_CMD_REPLY_FUNC(whois)
 {
   SilcServerCommandReplyContext cmd = (SilcServerCommandReplyContext)context;
   SilcServer server = cmd->server;
-  SilcCommandStatus status, error;
+  SilcCommandStatus status;
 
-  COMMAND_CHECK_STATUS;
+  COMMAND_CHECK_STATUS_LIST;
 
   if (!silc_server_command_reply_whois_save(cmd))
     goto out;
@@ -271,7 +272,7 @@ SILC_SERVER_CMD_REPLY_FUNC(whois)
  out:
   /* If we received notify for invalid ID we'll remove the ID if we
      have it cached. */
-  if (error == SILC_STATUS_ERR_NO_SUCH_CLIENT_ID &&
+  if (status == SILC_STATUS_ERR_NO_SUCH_CLIENT_ID &&
       cmd->sock->type == SILC_SOCKET_TYPE_ROUTER) {
     SilcClientEntry client;
     SilcUInt32 tmp_len;
@@ -390,9 +391,9 @@ silc_server_command_reply_whowas_save(SilcServerCommandReplyContext cmd)
 SILC_SERVER_CMD_REPLY_FUNC(whowas)
 {
   SilcServerCommandReplyContext cmd = (SilcServerCommandReplyContext)context;
-  SilcCommandStatus status, error;
+  SilcCommandStatus status;
 
-  COMMAND_CHECK_STATUS;
+  COMMAND_CHECK_STATUS_LIST;
 
   if (!silc_server_command_reply_whowas_save(cmd))
     goto out;
@@ -615,9 +616,9 @@ SILC_SERVER_CMD_REPLY_FUNC(identify)
 {
   SilcServerCommandReplyContext cmd = (SilcServerCommandReplyContext)context;
   SilcServer server = cmd->server;
-  SilcCommandStatus status, error;
+  SilcCommandStatus status;
 
-  COMMAND_CHECK_STATUS;
+  COMMAND_CHECK_STATUS_LIST;
 
   if (!silc_server_command_reply_identify_save(cmd))
     goto out;
@@ -632,7 +633,7 @@ SILC_SERVER_CMD_REPLY_FUNC(identify)
  out:
   /* If we received notify for invalid ID we'll remove the ID if we
      have it cached. */
-  if (error == SILC_STATUS_ERR_NO_SUCH_CLIENT_ID &&
+  if (status == SILC_STATUS_ERR_NO_SUCH_CLIENT_ID &&
       cmd->sock->type == SILC_SOCKET_TYPE_ROUTER) {
     SilcClientEntry client;
     SilcUInt32 tmp_len;
@@ -664,7 +665,7 @@ SILC_SERVER_CMD_REPLY_FUNC(info)
 {
   SilcServerCommandReplyContext cmd = (SilcServerCommandReplyContext)context;
   SilcServer server = cmd->server;
-  SilcCommandStatus status, error;
+  SilcCommandStatus status;
   SilcServerEntry entry;
   SilcServerID *server_id;
   SilcUInt32 tmp_len;
@@ -721,7 +722,7 @@ SILC_SERVER_CMD_REPLY_FUNC(motd)
 {
   SilcServerCommandReplyContext cmd = (SilcServerCommandReplyContext)context;
   SilcServer server = cmd->server;
-  SilcCommandStatus status, error;
+  SilcCommandStatus status;
   SilcServerEntry entry = NULL;
   SilcServerID *server_id;
   SilcUInt32 tmp_len;
@@ -770,7 +771,7 @@ SILC_SERVER_CMD_REPLY_FUNC(join)
   SilcServerCommandReplyContext cmd = (SilcServerCommandReplyContext)context;
   SilcServer server = cmd->server;
   SilcIDCacheEntry cache = NULL;
-  SilcCommandStatus status, error;
+  SilcCommandStatus status;
   SilcChannelID *id;
   SilcClientID *client_id = NULL;
   SilcChannelEntry entry;
@@ -871,14 +872,19 @@ SILC_SERVER_CMD_REPLY_FUNC(join)
 
     /* If the channel is found from global list we must move it to the
        local list. */
-    entry = silc_idlist_find_channel_by_name(server->global_list,
+    entry = silc_idlist_find_channel_by_name(server->global_list, 
                                             channel_name, &cache);
-    if (entry)
+    if (entry) {
+      if (entry->rekey) {
+       silc_schedule_task_del_by_context(server->schedule, entry->rekey);
+       SILC_LOG_ERROR(("global_list->channels: entry->rekey != NULL, inform Pekka now!!!"));
+      }
       silc_idlist_del_channel(server->global_list, entry);
+    }
 
     /* Add the channel to our local list. */
-    entry = silc_idlist_add_channel(server->local_list, strdup(channel_name),
-                                   SILC_CHANNEL_MODE_NONE, id,
+    entry = silc_idlist_add_channel(server->local_list, strdup(channel_name), 
+                                   SILC_CHANNEL_MODE_NONE, id, 
                                    server->router, NULL, hmac, 0);
     if (!entry) {
       silc_free(id);
@@ -954,7 +960,6 @@ SILC_SERVER_CMD_REPLY_FUNC(join)
   silc_server_save_users_on_channel(server, cmd->sock, entry, 
                                    client_id, client_id_list,
                                    client_mode_list, list_count);
-  entry->users_resolved = TRUE;
 
  out:
   SILC_SERVER_PENDING_EXEC(cmd, SILC_COMMAND_JOIN);
@@ -967,51 +972,11 @@ SILC_SERVER_CMD_REPLY_FUNC(join)
     silc_buffer_free(client_mode_list);
 }
 
-/* Received reply to STATS command.  */
-
-SILC_SERVER_CMD_REPLY_FUNC(stats)
-{
-  SilcServerCommandReplyContext cmd = (SilcServerCommandReplyContext)context;
-  SilcServer server = cmd->server;
-  SilcCommandStatus status, error;
-  unsigned char *tmp;
-  SilcUInt32 tmp_len;
-  SilcBufferStruct buf;
-
-  COMMAND_CHECK_STATUS;
-
-  /* Get statistics structure */
-  tmp = silc_argument_get_arg_type(cmd->args, 3, &tmp_len);
-  if (server->server_type == SILC_SERVER && tmp) {
-    silc_buffer_set(&buf, tmp, tmp_len);
-    silc_buffer_unformat(&buf,
-                        SILC_STR_UI_INT(NULL),
-                        SILC_STR_UI_INT(NULL),
-                        SILC_STR_UI_INT(NULL),
-                        SILC_STR_UI_INT(NULL),
-                        SILC_STR_UI_INT(NULL),
-                        SILC_STR_UI_INT(NULL),
-                        SILC_STR_UI_INT(&server->stat.cell_clients),
-                        SILC_STR_UI_INT(&server->stat.cell_channels),
-                        SILC_STR_UI_INT(&server->stat.cell_servers),
-                        SILC_STR_UI_INT(&server->stat.clients),
-                        SILC_STR_UI_INT(&server->stat.channels),
-                        SILC_STR_UI_INT(&server->stat.servers),
-                        SILC_STR_UI_INT(&server->stat.routers),
-                        SILC_STR_UI_INT(&server->stat.server_ops),
-                        SILC_STR_UI_INT(&server->stat.router_ops),
-                        SILC_STR_END);
-  }
-
- out:
-  SILC_SERVER_PENDING_EXEC(cmd, SILC_COMMAND_STATS);
-}
-
 SILC_SERVER_CMD_REPLY_FUNC(users)
 {
   SilcServerCommandReplyContext cmd = (SilcServerCommandReplyContext)context;
   SilcServer server = cmd->server;
-  SilcCommandStatus status, error;
+  SilcCommandStatus status;
   SilcChannelEntry channel;
   SilcChannelID *channel_id = NULL;
   SilcBuffer client_id_list;
@@ -1087,9 +1052,6 @@ SILC_SERVER_CMD_REPLY_FUNC(users)
                                    client_id_list, client_mode_list, 
                                    list_count);
 
-  channel->global_users = silc_server_channel_has_global(channel);
-  channel->users_resolved = TRUE;
-
   silc_buffer_free(client_id_list);
   silc_buffer_free(client_mode_list);
 
@@ -1103,7 +1065,7 @@ SILC_SERVER_CMD_REPLY_FUNC(getkey)
 {
   SilcServerCommandReplyContext cmd = (SilcServerCommandReplyContext)context;
   SilcServer server = cmd->server;
-  SilcCommandStatus status, error;
+  SilcCommandStatus status;
   SilcClientEntry client = NULL;
   SilcServerEntry server_entry = NULL;
   SilcClientID *client_id = NULL;
@@ -1156,7 +1118,6 @@ SILC_SERVER_CMD_REPLY_FUNC(getkey)
     }
 
     client->data.public_key = public_key;
-    public_key = NULL;
   } else if (id_type == SILC_ID_SERVER) {
     server_id = silc_id_payload_get_id(idp);
 
@@ -1170,7 +1131,6 @@ SILC_SERVER_CMD_REPLY_FUNC(getkey)
     }
 
     server_entry->data.public_key = public_key;
-    public_key = NULL;
   } else {
     goto out;
   }
@@ -1190,7 +1150,7 @@ SILC_SERVER_CMD_REPLY_FUNC(list)
 {
   SilcServerCommandReplyContext cmd = (SilcServerCommandReplyContext)context;
   SilcServer server = cmd->server;
-  SilcCommandStatus status, error;
+  SilcCommandStatus status;
   SilcChannelID *channel_id = NULL;
   SilcChannelEntry channel;
   SilcIDCacheEntry cache;
@@ -1199,7 +1159,7 @@ SILC_SERVER_CMD_REPLY_FUNC(list)
   SilcUInt32 usercount = 0;
   bool global_list = FALSE;
 
-  COMMAND_CHECK_STATUS;
+  COMMAND_CHECK_STATUS_LIST;
 
   tmp = silc_argument_get_arg_type(cmd->args, 2, &len);
   channel_id = silc_id_payload_parse_id(tmp, len, NULL);
index 9156e298413da14a0da6f0a48371e69ff040b118..17422bf4fcafec9d561c4caa06120950c68b9388 100644 (file)
@@ -72,7 +72,6 @@ SILC_SERVER_CMD_REPLY_FUNC(identify);
 SILC_SERVER_CMD_REPLY_FUNC(info);
 SILC_SERVER_CMD_REPLY_FUNC(motd);
 SILC_SERVER_CMD_REPLY_FUNC(join);
-SILC_SERVER_CMD_REPLY_FUNC(stats);
 SILC_SERVER_CMD_REPLY_FUNC(users);
 SILC_SERVER_CMD_REPLY_FUNC(getkey);
 SILC_SERVER_CMD_REPLY_FUNC(list);
index ab8f7d53af5abb6b9b0773020d25001fb2e4526d..a04e11677f5f0ca9a2dd4a8d3856ea17f535238f 100644 (file)
@@ -494,7 +494,7 @@ silc_idlist_find_client_by_id(SilcIDList id_list, SilcClientID *id,
 
 SilcClientEntry
 silc_idlist_replace_client_id(SilcIDList id_list, SilcClientID *old_id,
-                             SilcClientID *new_id, const char *nickname)
+                             SilcClientID *new_id)
 {
   SilcIDCacheEntry id_cache = NULL;
   SilcClientEntry client;
@@ -518,17 +518,12 @@ silc_idlist_replace_client_id(SilcIDList id_list, SilcClientID *old_id,
 
   /* Remove the old entry and add a new one */
 
-  if (!silc_idcache_del_by_context(id_list->clients, client))
-    return NULL;
+  silc_idcache_del_by_context(id_list->clients, client);
 
   silc_free(client->id);
-  silc_free(client->nickname);
   client->id = new_id;
-  client->nickname = nickname ? strdup(nickname) : NULL;
 
-  if (!silc_idcache_add(id_list->clients, client->nickname, client->id, 
-                       client, 0, NULL))
-    return NULL;
+  silc_idcache_add(id_list->clients, NULL, client->id, client, 0, NULL);
 
   SILC_LOG_DEBUG(("Replaced"));
 
index 1d92d4c388687738aa09e816386bcd04e35f54f0..74139ceb384af121f365828b477ddce72ed7838a 100644 (file)
@@ -62,7 +62,6 @@ typedef SilcUInt8 SilcIDListStatus;
 #define SILC_IDLIST_STATUS_RESOLVING    0x04    /* Entry is being resolved
                                                   with WHOIS or IDENTIFY */
 #define SILC_IDLIST_STATUS_DISABLED     0x08    /* Entry is disabled */
-#define SILC_IDLIST_STATUS_RESUMED      0x10    /* Entry is resumed */
 
 /*
    Generic ID list data structure.
@@ -496,7 +495,6 @@ struct SilcChannelEntryStruct {
 
   unsigned long created;
   bool disabled;
-  bool users_resolved;
 };
 
 /* 
@@ -599,7 +597,7 @@ silc_idlist_find_client_by_id(SilcIDList id_list, SilcClientID *id,
                              bool registered, SilcIDCacheEntry *ret_entry);
 SilcClientEntry
 silc_idlist_replace_client_id(SilcIDList id_list, SilcClientID *old_id,
-                             SilcClientID *new_id, const char *nickname);
+                             SilcClientID *new_id);
 void silc_idlist_client_destructor(SilcIDCache cache,
                                   SilcIDCacheEntry entry);
 SilcChannelEntry
index afdc1a622ecb6bb0111bf3adb6dd6ada4be16ba5..ab51f0e87c475b143902a251fc9bfa9222ecd6a4 100644 (file)
@@ -25,6 +25,8 @@
 #include "serverincludes.h"
 #include "server_internal.h"
 
+extern char *server_version;
+
 /* Received notify packet. Server can receive notify packets from router. 
    Server then relays the notify messages to clients if needed. */
 
@@ -67,8 +69,7 @@ void silc_server_notify(SilcServer server,
 
     /* Get the route to the client */
     dst_sock = silc_server_get_client_route(server, packet->dst_id,
-                                           packet->dst_id_len, NULL, 
-                                           &idata, NULL);
+                                           packet->dst_id_len, NULL, &idata);
     if (dst_sock)
       /* Relay the packet */
       silc_server_relay_packet(server, dst_sock, idata->send_key,
@@ -330,7 +331,7 @@ void silc_server_notify(SilcServer server,
 
     /* Update statistics */
     server->stat.clients--;
-    if (server->stat.cell_clients)
+    if (server->server_type == SILC_ROUTER)
       server->stat.cell_clients--;
     SILC_OPER_STATS_UPDATE(client, server, SILC_UMODE_SERVER_OPERATOR);
     SILC_OPER_STATS_UPDATE(client, router, SILC_UMODE_ROUTER_OPERATOR);
@@ -425,8 +426,6 @@ void silc_server_notify(SilcServer server,
        * Distribute the notify to local clients on the channel
        */
       unsigned char *id, *id2;
-      char *nickname;
-      SilcUInt32 nickname_len;
 
       SILC_LOG_DEBUG(("NICK CHANGE notify"));
       
@@ -451,24 +450,26 @@ void silc_server_notify(SilcServer server,
       SILC_LOG_DEBUG(("New Client ID id(%s)", 
                      silc_id_render(client_id2, SILC_ID_CLIENT)));
 
-      /* From protocol version 1.1 we also get the new nickname */
-      nickname = silc_argument_get_arg_type(args, 3, &nickname_len);;
-
       /* Replace the Client ID */
       client = silc_idlist_replace_client_id(server->global_list, client_id,
-                                            client_id2, nickname);
+                                            client_id2);
       if (!client)
        client = silc_idlist_replace_client_id(server->local_list, client_id, 
-                                              client_id2, nickname);
+                                              client_id2);
 
       if (client) {
+       /* The nickname is not valid anymore, set it NULL. This causes that
+          the nickname will be queried if someone wants to know it. */
+       if (client->nickname)
+         silc_free(client->nickname);
+       client->nickname = NULL;
+
        /* Send the NICK_CHANGE notify type to local clients on the channels
           this client is joined to. */
-       silc_server_send_notify_on_channels(server, client, client,
-                                           SILC_NOTIFY_TYPE_NICK_CHANGE, 3,
-                                           id, tmp_len, id2, tmp_len,
-                                           nickname, nickname ?
-                                           nickname_len : 0);
+       silc_server_send_notify_on_channels(server, NULL, client, 
+                                           SILC_NOTIFY_TYPE_NICK_CHANGE, 2,
+                                           id, tmp_len, 
+                                           id2, tmp_len);
       }
 
       silc_free(client_id);
@@ -594,7 +595,7 @@ void silc_server_notify(SilcServer server,
     tmp = silc_argument_get_arg_type(args, 5, &tmp_len);
     if (tmp) {
       silc_free(channel->passphrase);
-      channel->passphrase = silc_memdup(tmp, tmp_len);
+      channel->passphrase = strdup(tmp);
     }
 
     break;
@@ -1038,7 +1039,7 @@ void silc_server_notify(SilcServer server,
 
            /* Update statistics */
            server->stat.clients--;
-           if (server->stat.cell_clients)
+           if (server->server_type == SILC_ROUTER)
              server->stat.cell_clients--;
            SILC_OPER_STATS_UPDATE(client, server, SILC_UMODE_SERVER_OPERATOR);
            SILC_OPER_STATS_UPDATE(client, router, SILC_UMODE_ROUTER_OPERATOR);
@@ -1125,7 +1126,8 @@ void silc_server_notify(SilcServer server,
     if (chl->mode & SILC_CHANNEL_UMODE_CHANFO)
       goto out;
     
-    /* From protocol version 1.1 we get the kicker's ID as well. */
+    /* Get kicker. In protocol version 1.0 this is not mandatory argument
+       so we check it only if it is provided. */
     tmp = silc_argument_get_arg_type(args, 3, &tmp_len);
     if (tmp) {
       client_id = silc_id_payload_parse_id(tmp, tmp_len, NULL);
@@ -1169,8 +1171,8 @@ void silc_server_notify(SilcServer server,
       /* 
        * Distribute the notify to local clients on channels
        */
-      unsigned char *id, *comment;
-      SilcUInt32 id_len, comment_len;
+      unsigned char *id;
+      SilcUInt32 id_len;
     
       SILC_LOG_DEBUG(("KILLED notify"));
       
@@ -1205,44 +1207,16 @@ void silc_server_notify(SilcServer server,
       }
 
       /* Get comment */
-      comment = silc_argument_get_arg_type(args, 2, &comment_len);
-      if (comment_len > 128)
-       comment_len = 127;
-
-      /* From protocol version 1.1 we get the killer's ID as well. */
-      tmp = silc_argument_get_arg_type(args, 3, &tmp_len);
-      if (tmp) {
-       client_id = silc_id_payload_parse_id(tmp, tmp_len, &id_type);
-       if (!client_id)
-         goto out;
-
-       if (id_type == SILC_ID_CLIENT) {
-         /* If the the client is not in local list we check global list */
-         client2 = silc_idlist_find_client_by_id(server->global_list, 
-                                                 client_id, TRUE, NULL);
-         if (!client2) {
-           client2 = silc_idlist_find_client_by_id(server->local_list, 
-                                                   client_id, TRUE, NULL);
-           if (!client2) {
-             silc_free(client_id);
-             goto out;
-           }
-         }
-         silc_free(client_id);
-
-         /* Killer must be router operator */
-         if (!(client2->mode & SILC_UMODE_ROUTER_OPERATOR)) {
-           SILC_LOG_DEBUG(("Killing is not allowed"));
-           goto out;
-         }
-       }
-      }
+      tmp = silc_argument_get_arg_type(args, 2, &tmp_len);
+      if (tmp_len > 128)
+       tmp = NULL;
 
       /* Send the notify to local clients on the channels except to the
         client who is killed. */
       silc_server_send_notify_on_channels(server, client, client,
-                                         SILC_NOTIFY_TYPE_KILLED, 3,
-                                         id, id_len, comment, comment_len,
+                                         SILC_NOTIFY_TYPE_KILLED, 
+                                         tmp ? 2 : 1,
+                                         id, id_len, 
                                          tmp, tmp_len);
 
       /* Remove the client from all channels */
@@ -1292,10 +1266,6 @@ void silc_server_notify(SilcServer server,
       goto out;
     }
 
-    /* Remove internal resumed flag if client is marked detached now */
-    if (mode & SILC_UMODE_DETACHED)
-      client->data.status &= ~SILC_IDLIST_STATUS_RESUMED;
-
     /* Change the mode */
     client->mode = mode;
 
@@ -1444,7 +1414,6 @@ void silc_server_private_message(SilcServer server,
 {
   SilcSocketConnection dst_sock;
   SilcIDListData idata;
-  SilcClientEntry client;
 
   SILC_LOG_DEBUG(("Start"));
 
@@ -1454,21 +1423,13 @@ void silc_server_private_message(SilcServer server,
 
   /* Get the route to the client */
   dst_sock = silc_server_get_client_route(server, packet->dst_id,
-                                         packet->dst_id_len, NULL, 
-                                         &idata, &client);
+                                         packet->dst_id_len, NULL, &idata);
   if (!dst_sock) {
-    SilcBuffer idp;
-
-    if (client && client->mode & SILC_UMODE_DETACHED) {
-      SILC_LOG_DEBUG(("Client is detached, discarding packet"));
-      return;
-    }
-
     /* Send IDENTIFY command reply with error status to indicate that
        such destination ID does not exist or is invalid */
-    idp = silc_id_payload_encode_data(packet->dst_id,
-                                     packet->dst_id_len,
-                                     packet->dst_id_type);
+    SilcBuffer idp = silc_id_payload_encode_data(packet->dst_id,
+                                                packet->dst_id_len,
+                                                packet->dst_id_type);
     if (!idp)
       return;
 
@@ -1480,11 +1441,11 @@ void silc_server_private_message(SilcServer server,
                                          client_id, SILC_ID_CLIENT,
                                          SILC_COMMAND_IDENTIFY,
                                          SILC_STATUS_ERR_NO_SUCH_CLIENT_ID, 
-                                         0, 0, 1, 2, idp->data, idp->len);
+                                         0, 1, 2, idp->data, idp->len);
       silc_free(client_id);
     } else {
       silc_server_send_command_reply(server, sock, SILC_COMMAND_IDENTIFY,
-                                    SILC_STATUS_ERR_NO_SUCH_CLIENT_ID, 0,
+                                    SILC_STATUS_ERR_NO_SUCH_CLIENT_ID, 
                                     0, 1, 2, idp->data, idp->len);
     }
 
@@ -1492,13 +1453,6 @@ void silc_server_private_message(SilcServer server,
     return;
   }
 
-  /* Check whether destination client wishes to receive private messages */
-  if (client && !(packet->flags & SILC_PACKET_FLAG_PRIVMSG_KEY) &&
-      client->mode & SILC_UMODE_BLOCK_PRIVMSG) {
-    SILC_LOG_DEBUG(("Client blocks private messages, discarding packet"));
-    return;
-  }
-
   /* Send the private message */
   silc_server_send_private_message(server, dst_sock, idata->send_key,
                                   idata->hmac_send, idata->psn_send++,
@@ -1528,8 +1482,7 @@ void silc_server_private_message_key(SilcServer server,
 
   /* Get the route to the client */
   dst_sock = silc_server_get_client_route(server, packet->dst_id,
-                                         packet->dst_id_len, NULL, 
-                                         &idata, NULL);
+                                         packet->dst_id_len, NULL, &idata);
   if (!dst_sock)
     return;
 
@@ -1624,7 +1577,6 @@ void silc_server_channel_message(SilcServer server,
   SilcChannelID *id = NULL;
   void *sender_id = NULL;
   SilcClientEntry sender_entry = NULL;
-  SilcChannelClientEntry chl;
   bool local = TRUE;
 
   SILC_LOG_DEBUG(("Processing channel message"));
@@ -1663,24 +1615,11 @@ void silc_server_channel_message(SilcServer server,
                                                   sender_id, TRUE, NULL);
     }
     if (!sender_entry || !silc_server_client_on_channel(sender_entry, 
-                                                       channel, &chl)) {
+                                                       channel, NULL)) {
       SILC_LOG_DEBUG(("Client not on channel"));
       goto out;
     }
 
-    /* If channel is moderated check that client is allowed to send
-       messages. */
-    if (channel->mode & SILC_CHANNEL_MODE_SILENCE_USERS && !chl->mode) {
-      SILC_LOG_DEBUG(("Channel is silenced from normal users"));
-      goto out;
-    }
-    if (channel->mode & SILC_CHANNEL_MODE_SILENCE_OPERS && 
-       chl->mode & SILC_CHANNEL_UMODE_CHANOP &&
-       !(chl->mode & SILC_CHANNEL_UMODE_CHANFO)) {
-      SILC_LOG_DEBUG(("Channel is silenced from operators"));
-      goto out;
-    }
-
     /* If the packet is coming from router, but the client entry is local 
        entry to us then some router is rerouting this to us and it is not 
        allowed. When the client is local to us it means that we've routed
@@ -1746,8 +1685,9 @@ SilcClientEntry silc_server_new_client(SilcServer server,
   SilcBuffer buffer = packet->buffer;
   SilcClientEntry client;
   SilcClientID *client_id;
+  SilcBuffer reply;
   SilcIDListData idata;
-  char *username = NULL, *realname = NULL;
+  char *username = NULL, *realname = NULL, *id_string;
   SilcUInt16 username_len;
   SilcUInt32 id_len;
   int ret;
@@ -1895,11 +1835,6 @@ SilcClientEntry silc_server_new_client(SilcServer server,
   while (!silc_id_create_client_id(server, server->id, server->rng, 
                                   server->md5hash, nickname, &client_id)) {
     nickfail++;
-    if (nickfail > 9) {
-      silc_server_disconnect_remote(server, sock, 
-                                   "Server closed connection: Bad nickname");
-      return NULL;
-    }
     snprintf(&nickname[strlen(nickname) - 1], 1, "%d", nickfail);
   }
 
@@ -1923,11 +1858,71 @@ SilcClientEntry silc_server_new_client(SilcServer server,
                            client->id, SILC_ID_CLIENT, id_len);
   
   /* Send the new client ID to the client. */
-  silc_server_send_new_id(server, sock, FALSE, client->id, SILC_ID_CLIENT,
-                         silc_id_get_len(client->id, SILC_ID_CLIENT));
+  id_string = silc_id_id2str(client->id, SILC_ID_CLIENT);
+  reply = silc_buffer_alloc(2 + 2 + id_len);
+  silc_buffer_pull_tail(reply, SILC_BUFFER_END(reply));
+  silc_buffer_format(reply,
+                    SILC_STR_UI_SHORT(SILC_ID_CLIENT),
+                    SILC_STR_UI_SHORT(id_len),
+                    SILC_STR_UI_XNSTRING(id_string, id_len),
+                    SILC_STR_END);
+  silc_server_packet_send(server, sock, SILC_PACKET_NEW_ID, 0, 
+                         reply->data, reply->len, FALSE);
+  silc_free(id_string);
+  silc_buffer_free(reply);
 
   /* Send some nice info to the client */
-  silc_server_send_connect_notifys(server, sock, client);
+  SILC_SERVER_SEND_NOTIFY(server, sock, SILC_NOTIFY_TYPE_NONE,
+                         ("Welcome to the SILC Network %s",
+                          username));
+  SILC_SERVER_SEND_NOTIFY(server, sock, SILC_NOTIFY_TYPE_NONE,
+                         ("Your host is %s, running version %s",
+                          server->server_name, server_version));
+  if (server->server_type == SILC_ROUTER) {
+    SILC_SERVER_SEND_NOTIFY(server, sock, SILC_NOTIFY_TYPE_NONE,
+                           ("There are %d clients on %d servers in SILC "
+                            "Network", server->stat.clients,
+                            server->stat.servers + 1));
+    SILC_SERVER_SEND_NOTIFY(server, sock, SILC_NOTIFY_TYPE_NONE,
+                           ("There are %d clients on %d server in our cell",
+                            server->stat.cell_clients,
+                            server->stat.cell_servers + 1));
+    SILC_SERVER_SEND_NOTIFY(server, sock, SILC_NOTIFY_TYPE_NONE,
+                           ("I have %d clients, %d channels, %d servers and "
+                            "%d routers",
+                            server->stat.my_clients, 
+                            server->stat.my_channels,
+                            server->stat.my_servers,
+                            server->stat.my_routers));
+    SILC_SERVER_SEND_NOTIFY(server, sock, SILC_NOTIFY_TYPE_NONE,
+                           ("There are %d server operators and %d router "
+                            "operators online",
+                            server->stat.server_ops,
+                            server->stat.router_ops));
+    SILC_SERVER_SEND_NOTIFY(server, sock, SILC_NOTIFY_TYPE_NONE,
+                           ("I have %d operators online",
+                            server->stat.my_router_ops +
+                            server->stat.my_server_ops));
+  } else {
+    SILC_SERVER_SEND_NOTIFY(server, sock, SILC_NOTIFY_TYPE_NONE,
+                           ("I have %d clients and %d channels formed",
+                            server->stat.my_clients,
+                            server->stat.my_channels));
+    SILC_SERVER_SEND_NOTIFY(server, sock, SILC_NOTIFY_TYPE_NONE,
+                           ("%d operators online",
+                            server->stat.my_server_ops));
+  }
+  SILC_SERVER_SEND_NOTIFY(server, sock, SILC_NOTIFY_TYPE_NONE,
+                         ("Your connection is secured with %s cipher, "
+                          "key length %d bits",
+                          idata->send_key->cipher->name,
+                          idata->send_key->cipher->key_len));
+  SILC_SERVER_SEND_NOTIFY(server, sock, SILC_NOTIFY_TYPE_NONE,
+                         ("Your current nickname is %s",
+                          client->nickname));
+
+  /* Send motd */
+  silc_server_send_motd(server, sock);
 
   return client;
 }
@@ -2427,15 +2422,9 @@ void silc_server_new_channel(SilcServer server,
                      silc_id_render(channel_id, SILC_ID_CHANNEL), 
                      sock->hostname));
     
-      channel = 
-       silc_idlist_add_channel(server->global_list, strdup(channel_name), 
-                               0, channel_id, sock->user_data, NULL, NULL, 0);
-      if (!channel)
-       return;
-
+      silc_idlist_add_channel(server->global_list, strdup(channel_name), 
+                             0, channel_id, sock->user_data, NULL, NULL, 0);
       server->stat.channels++;
-      if (server->server_type == SILC_ROUTER)
-       channel->users_resolved = TRUE;
     }
   } else {
     /* The channel is coming from our server, thus it is in our cell
@@ -2678,8 +2667,7 @@ void silc_server_key_agreement(SilcServer server,
 
   /* Get the route to the client */
   dst_sock = silc_server_get_client_route(server, packet->dst_id,
-                                         packet->dst_id_len, NULL, 
-                                         &idata, NULL);
+                                         packet->dst_id_len, NULL, &idata);
   if (!dst_sock)
     return;
 
@@ -2796,8 +2784,7 @@ void silc_server_ftp(SilcServer server,
 
   /* Get the route to the client */
   dst_sock = silc_server_get_client_route(server, packet->dst_id,
-                                         packet->dst_id_len, NULL, 
-                                         &idata, NULL);
+                                         packet->dst_id_len, NULL, &idata);
   if (!dst_sock)
     return;
 
@@ -2806,503 +2793,3 @@ void silc_server_ftp(SilcServer server,
                           idata->hmac_send, idata->psn_send++,
                           packet, FALSE);
 }
-
-typedef struct {
-  SilcServer server;
-  SilcSocketConnection sock;
-  SilcPacketContext *packet;
-  void *data;
-} *SilcServerResumeResolve;
-
-SILC_SERVER_CMD_FUNC(resume_resolve)
-{
-  SilcServerResumeResolve r = (SilcServerResumeResolve)context;
-  SilcServer server = r->server;
-  SilcSocketConnection sock = r->sock;
-  SilcServerCommandReplyContext reply = context2;
-  SilcClientEntry client;
-
-  SILC_LOG_DEBUG(("Start"));
-
-  if (!reply || !silc_command_get_status(reply->payload, NULL, NULL)) {
-    SILC_LOG_ERROR(("Client %s (%s) tried to resume unknown client, "
-                   "closing connection", sock->hostname, sock->ip));
-    silc_server_disconnect_remote(server, sock, 
-                                 "Server closed connection: "
-                                 "Incomplete resume information");
-    goto out;
-  }
-
-  if (reply && silc_command_get(reply->payload) == SILC_COMMAND_WHOIS) {
-    /* Get entry to the client, and resolve it if we don't have it. */
-    client = silc_idlist_find_client_by_id(server->local_list, 
-                                          r->data, TRUE, NULL);
-    if (!client) {
-      client = silc_idlist_find_client_by_id(server->global_list,
-                                            r->data, TRUE, NULL);
-      if (!client) {
-       SILC_LOG_ERROR(("Client %s (%s) tried to resume unknown client, "
-                       "closing connection", sock->hostname, sock->ip));
-       silc_server_disconnect_remote(server, sock, 
-                                     "Server closed connection: "
-                                     "Incomplete resume information");
-       goto out;
-      }
-    }
-
-    if (!(client->mode & SILC_UMODE_DETACHED)) {
-      SILC_LOG_ERROR(("Client %s (%s) tried to resume un-detached client, "
-                     "closing connection", sock->hostname, sock->ip));
-      silc_server_disconnect_remote(server, sock, 
-                                   "Server closed connection: "
-                                   "Incomplete resume information");
-      goto out;
-    }
-  }
-
-  /* Reprocess the packet */
-  silc_server_resume_client(server, sock, r->packet);
-
- out:
-  silc_socket_free(r->sock);
-  silc_packet_context_free(r->packet);
-  silc_free(r->data);
-  silc_free(r);
-}
-
-/* Received client resuming packet.  This is used to resume detached
-   client session.  It can be sent by the client who wishes to resume
-   but this is also sent by servers and routers to notify other routers
-   that the client is not detached anymore. */
-
-void silc_server_resume_client(SilcServer server,
-                              SilcSocketConnection sock,
-                              SilcPacketContext *packet)
-{
-  SilcBuffer buffer = packet->buffer, buf;
-  SilcIDListData idata;
-  SilcClientEntry detached_client;
-  SilcClientID *client_id = NULL;
-  unsigned char *id_string, *auth = NULL;
-  SilcUInt16 id_len, auth_len = 0;
-  int ret, nickfail = 0;
-  bool resolved, local, nick_change = FALSE;
-  SilcChannelEntry channel;
-  SilcHashTableList htl;
-  SilcChannelClientEntry chl;
-  SilcServerResumeResolve r;
-
-  SILC_LOG_DEBUG(("Start"));
-
-  ret = silc_buffer_unformat(buffer,
-                            SILC_STR_UI16_NSTRING(&id_string, &id_len),
-                            SILC_STR_END);
-  if (ret != -1)
-    client_id = silc_id_str2id(id_string, id_len, SILC_ID_CLIENT);
-
-  if (sock->type == SILC_SOCKET_TYPE_CLIENT) {
-    /* Client send this and is attempting to resume to old client session */
-    SilcClientEntry client;
-    SilcBuffer keyp;
-
-    if (ret != -1) {
-      silc_buffer_pull(buffer, 2 + id_len);
-      auth = buffer->data;
-      auth_len = buffer->len;
-      silc_buffer_push(buffer, 2 + id_len);
-    }
-
-    if (!client_id || auth_len < 128) {
-      SILC_LOG_ERROR(("Client %s (%s) sent incomplete resume information, "
-                     "closing connection", sock->hostname, sock->ip));
-      silc_server_disconnect_remote(server, sock, "Server closed connection: "
-                                   "Incomplete resume information");
-      return;
-    }
-
-    /* Take client entry of this connection */
-    client = (SilcClientEntry)sock->user_data;
-    idata = (SilcIDListData)client;
-
-    /* Get entry to the client, and resolve it if we don't have it. */
-    detached_client = silc_server_get_client_resolve(server, client_id, FALSE,
-                                                    &resolved);
-    if (!detached_client) {
-      if (resolved) {
-       /* The client info is being resolved. Reprocess this packet after
-          receiving the reply to the query. */
-       SILC_LOG_DEBUG(("Resolving client"));
-       r = silc_calloc(1, sizeof(*r));
-       if (!r)
-         return;
-       r->server = server;
-       r->sock = silc_socket_dup(sock);
-       r->packet = silc_packet_context_dup(packet);
-       r->data = silc_id_dup(client_id, SILC_ID_CLIENT);
-       silc_server_command_pending(server, SILC_COMMAND_WHOIS,
-                                   server->cmd_ident,
-                                   silc_server_command_resume_resolve, r);
-      } else {
-       SILC_LOG_ERROR(("Client %s (%s) tried to resume unknown client, "
-                       "closing connection", sock->hostname, sock->ip));
-       silc_server_disconnect_remote(server, sock, 
-                                     "Server closed connection: "
-                                     "Incomplete resume information");
-      }
-      return;
-    }
-
-    /* Check that the client is detached, and that we have other info too */
-    if (!(detached_client->mode & SILC_UMODE_DETACHED) ||
-       !silc_hash_table_count(detached_client->channels) ||
-       !detached_client->nickname) {
-      if (server->server_type == SILC_SERVER && !server->standalone) {
-       /* The client info is being resolved. Reprocess this packet after
-          receiving the reply to the query. */
-       SILC_LOG_DEBUG(("Resolving client info"));
-       silc_server_get_client_resolve(server, client_id, TRUE, NULL);
-       r = silc_calloc(1, sizeof(*r));
-       if (!r)
-         return;
-       r->server = server;
-       r->sock = silc_socket_dup(sock);
-       r->packet = silc_packet_context_dup(packet);
-       r->data = silc_id_dup(client_id, SILC_ID_CLIENT);
-       silc_server_command_pending(server, SILC_COMMAND_WHOIS,
-                                   server->cmd_ident,
-                                   silc_server_command_resume_resolve, r);
-      } else {
-       SILC_LOG_ERROR(("Client %s (%s) tried to resume un-detached client, "
-                       "closing connection", sock->hostname, sock->ip));
-       silc_server_disconnect_remote(server, sock, 
-                                     "Server closed connection: "
-                                     "Incomplete resume information");
-      }
-      return;
-    }
-
-    /* Check that we have the public key of the client, if not then we must
-       resolve it first. */
-    if (!detached_client->data.public_key) {
-      if (server->standalone) {
-       silc_server_disconnect_remote(server, sock, 
-                                     "Server closed connection: "
-                                     "Incomplete resume information");
-      } else {
-       /* We must retrieve the detached client's public key by sending
-          GETKEY command. Reprocess this packet after receiving the key */
-       SilcBuffer idp = silc_id_payload_encode(client_id, SILC_ID_CLIENT);
-       SilcSocketConnection dest_sock = 
-         silc_server_get_client_route(server, NULL, 0, client_id, NULL, NULL);
-
-       SILC_LOG_DEBUG(("Resolving client public key"));
-
-       silc_server_send_command(server, dest_sock ? dest_sock : 
-                                server->router->connection,
-                                SILC_COMMAND_GETKEY, ++server->cmd_ident,
-                                1, 1, idp->data, idp->len);
-
-       r = silc_calloc(1, sizeof(*r));
-       if (!r)
-         return;
-
-       r->server = server;
-       r->sock = silc_socket_dup(sock);
-       r->packet = silc_packet_context_dup(packet);
-       silc_server_command_pending(server, SILC_COMMAND_GETKEY,
-                                   server->cmd_ident,
-                                   silc_server_command_resume_resolve, r);
-
-       silc_buffer_free(idp);
-      }
-      return;
-    }
-
-    /* Verify the authentication payload.  This has to be successful in
-       order to allow the resuming */
-    if (!silc_auth_verify_data(auth, auth_len, SILC_AUTH_PUBLIC_KEY,
-                              detached_client->data.public_key, 0,
-                              idata->hash, detached_client->id, 
-                              SILC_ID_CLIENT)) {
-      SILC_LOG_ERROR(("Client %s (%s) resume authentication failed, "
-                     "closing connection", sock->hostname, sock->ip));
-      silc_server_disconnect_remote(server, sock, "Server closed connection: "
-                                   "Incomplete resume information");
-      return;
-    }
-
-    /* Now resume the client to the network */
-
-    sock->user_data = detached_client;
-    detached_client->connection = sock;
-
-    /* Take new keys and stuff into use in the old entry */
-    silc_idlist_del_data(detached_client);
-    silc_idlist_add_data(detached_client, idata);
-    detached_client->data.status |= SILC_IDLIST_STATUS_REGISTERED;
-    detached_client->data.status |= SILC_IDLIST_STATUS_RESUMED;
-    detached_client->mode &= ~SILC_UMODE_DETACHED;
-
-    /* Send the RESUME_CLIENT packet to our primary router so that others
-       know this client isn't detached anymore. */
-    buf = silc_buffer_alloc_size(2 + id_len);
-    silc_buffer_format(buf,
-                      SILC_STR_UI_SHORT(id_len),
-                      SILC_STR_UI_XNSTRING(id_string, id_len),
-                      SILC_STR_END);
-
-    /* Send to primary router */
-    if (!server->standalone)
-      silc_server_packet_send(server, server->router->connection,
-                             SILC_PACKET_RESUME_CLIENT, 0, 
-                             buf->data, buf->len, TRUE);
-
-    /* As router we must deliver this packet directly to the original
-       server whom this client was earlier. */
-    if (server->server_type == SILC_ROUTER && detached_client->router &&
-       detached_client->router->server_type != SILC_ROUTER)
-      silc_server_packet_send(server, detached_client->router->connection,
-                             SILC_PACKET_RESUME_CLIENT, 0, 
-                             buf->data, buf->len, TRUE);
-    silc_buffer_free(buf);
-
-    detached_client->router = NULL;
-
-    /* Delete this client entry since we're resuming to old one. */
-    server->stat.my_clients--;
-    server->stat.clients--;
-    if (server->stat.cell_clients)
-      server->stat.cell_clients--;
-    silc_idlist_del_client(server->local_list, client);
-    client = detached_client;
-
-    /* If the ID is not based in our ID then change it */
-    if (!SILC_ID_COMPARE(client->id, server->id, server->id->ip.data_len)) {
-      while (!silc_id_create_client_id(server, server->id, server->rng, 
-                                      server->md5hash, client->nickname, 
-                                      &client_id)) {
-       nickfail++;
-       if (nickfail > 9) {
-         silc_server_disconnect_remote(server, sock, 
-                                       "Server closed connection: "
-                                       "Bad nickname");
-         return;
-       }
-       snprintf(&client->nickname[strlen(client->nickname) - 1], 1, 
-                "%d", nickfail);
-      }
-      nick_change = TRUE;
-    }
-
-    if (nick_change) {
-      /* Notify about Client ID change, nickname doesn't actually change. */
-      if (!server->standalone)
-       silc_server_send_notify_nick_change(server, server->router->connection,
-                                           FALSE, client->id, client_id,
-                                           client->nickname);
-    }
-
-    /* Resolve users on those channels that client has joined but we
-       haven't resolved user list yet. */
-    if (server->server_type == SILC_SERVER && !server->standalone) {
-      silc_hash_table_list(client->channels, &htl);
-      while (silc_hash_table_get(&htl, NULL, (void **)&chl)) {
-       channel = chl->channel;
-       SILC_LOG_DEBUG(("Resolving users for %s channel", 
-                       channel->channel_name));
-       if (channel->disabled || !channel->users_resolved) {
-         silc_server_send_command(server, server->router->connection,
-                                  SILC_COMMAND_USERS, ++server->cmd_ident,
-                                  1, 2, channel->channel_name,
-                                  strlen(channel->channel_name));
-       }
-      }
-      silc_hash_table_list_reset(&htl);
-    }
-
-    /* Send the new client ID to the client. After this client may start
-       receiving other packets, and may start sending packets too. */
-    silc_server_send_new_id(server, sock, FALSE, client_id, SILC_ID_CLIENT,
-                           silc_id_get_len(client_id, SILC_ID_CLIENT));
-
-    if (nick_change) {
-      /* Send NICK change notify to channels as well. */
-      SilcBuffer oidp, nidp;
-      oidp = silc_id_payload_encode(client->id, SILC_ID_CLIENT);
-      nidp = silc_id_payload_encode(client_id, SILC_ID_CLIENT);
-      silc_server_send_notify_on_channels(server, NULL, client, 
-                                         SILC_NOTIFY_TYPE_NICK_CHANGE, 3,
-                                         oidp->data, oidp->len, 
-                                         nidp->data, nidp->len,
-                                         client->nickname, 
-                                         strlen(client->nickname));
-      silc_buffer_free(oidp);
-      silc_buffer_free(nidp);
-    }
-
-    /* Add the client again to the ID cache to get it to correct list */
-    if (!silc_idcache_del_by_context(server->local_list->clients, client))
-      silc_idcache_del_by_context(server->global_list->clients, client);
-    silc_free(client->id);
-    client->id = client_id;
-    client_id = NULL;
-    silc_idcache_add(server->local_list->clients, client->nickname,
-                    client->id, client, 0, NULL);
-
-    /* Send some nice info to the client */
-    silc_server_send_connect_notifys(server, sock, client);
-
-    /* Send all channel keys of channels the client has joined */
-    silc_hash_table_list(client->channels, &htl);
-    while (silc_hash_table_get(&htl, NULL, (void **)&chl)) {
-      bool created = FALSE;
-      channel = chl->channel;
-
-      if (channel->mode & SILC_CHANNEL_MODE_PRIVKEY)
-       continue;
-
-      /* If we don't have channel key, then create one */
-      if (!channel->channel_key) {
-       if (!silc_server_create_channel_key(server, channel, 0))
-         continue;
-       created = TRUE;
-      }
-
-      id_string = silc_id_id2str(channel->id, SILC_ID_CHANNEL);
-      keyp = 
-       silc_channel_key_payload_encode(silc_id_get_len(channel->id,
-                                                       SILC_ID_CHANNEL), 
-                                       id_string,
-                                       strlen(channel->channel_key->
-                                              cipher->name),
-                                       channel->channel_key->cipher->name,
-                                       channel->key_len / 8, channel->key);
-      silc_free(id_string);
-
-      /* Send the key packet to client */
-      silc_server_packet_send(server, sock, SILC_PACKET_CHANNEL_KEY, 0, 
-                             keyp->data, keyp->len, FALSE);
-
-      if (created && server->server_type == SILC_SERVER && 
-         !server->standalone)
-       silc_server_packet_send(server, server->router->connection, 
-                               SILC_PACKET_CHANNEL_KEY, 0, 
-                               keyp->data, keyp->len, FALSE);
-
-      silc_buffer_free(keyp);
-    }
-    silc_hash_table_list_reset(&htl);
-
-  } else if (sock->type != SILC_SOCKET_TYPE_CLIENT) {
-    /* Server or router sent this to us to notify that that a client has
-       been resumed. */
-    SilcServerEntry server_entry;
-    SilcServerID *server_id;
-
-    if (!client_id)
-      return;
-
-    /* Get entry to the client, and resolve it if we don't have it. */
-    detached_client = silc_idlist_find_client_by_id(server->local_list, 
-                                                   client_id, TRUE, NULL);
-    if (!detached_client) {
-      detached_client = silc_idlist_find_client_by_id(server->global_list,
-                                                     client_id, TRUE, NULL);
-      if (!detached_client)
-       return;
-    }
-
-    /* Check that the client has not been resumed already because it is
-       protocol error to attempt to resume more than once.  The client
-       will be killed if this protocol error occurs. */
-    if (detached_client->data.status & SILC_IDLIST_STATUS_RESUMED &&
-       !(detached_client->mode & SILC_UMODE_DETACHED)) {
-      /* The client is clearly attempting to resume more than once and
-        perhaps playing around by resuming from several different places
-        at the same time. */
-      silc_server_kill_client(server, detached_client, NULL,
-                             server->id, SILC_ID_SERVER);
-      return;
-    }
-
-    /* Check whether client is detached at all */
-    if (!(detached_client->mode & SILC_UMODE_DETACHED))
-      return;
-
-    /* Client is detached, and now it is resumed.  Remove the detached
-       mode and mark that it is resumed. */
-    detached_client->mode &= ~SILC_UMODE_DETACHED;
-    detached_client->data.status |= SILC_IDLIST_STATUS_RESUMED;
-
-    /* Get the new owner of the resumed client */
-    server_id = silc_id_str2id(packet->src_id, packet->src_id_len,
-                              packet->src_id_type);
-    if (!server_id)
-      return;
-
-    /* Get server entry */
-    server_entry = silc_idlist_find_server_by_id(server->global_list, 
-                                                server_id, TRUE, NULL);
-    local = TRUE;
-    if (!server_entry) {
-      server_entry = silc_idlist_find_server_by_id(server->local_list, 
-                                                  server_id, TRUE, NULL);
-      local = FALSE;
-      if (!server_entry) {
-       silc_free(server_id);
-       return;
-      }
-    }
-
-    if (server->server_type == SILC_ROUTER &&
-       sock->type == SILC_SOCKET_TYPE_ROUTER && 
-       server_entry->server_type == SILC_ROUTER)
-      local = FALSE;
-
-    SILC_LOG_DEBUG(("Resuming detached client"));
-
-    /* Change the client to correct list. */
-    if (!silc_idcache_del_by_context(server->local_list->clients,
-                                    detached_client))
-      silc_idcache_del_by_context(server->global_list->clients,
-                                 detached_client);
-    silc_idcache_add(local && server->server_type == SILC_ROUTER ? 
-                    server->local_list->clients : 
-                    server->global_list->clients, 
-                    detached_client->nickname,
-                    detached_client->id, detached_client, FALSE, NULL);
-
-    /* Change the owner of the client if needed */
-    if (detached_client->router != server_entry)
-      detached_client->router = server_entry;
-
-    /* Update channel information regarding global clients on channel. */
-    if (server->server_type == SILC_SERVER) {
-      silc_hash_table_list(detached_client->channels, &htl);
-      while (silc_hash_table_get(&htl, NULL, (void **)&chl))
-       chl->channel->global_users = 
-         silc_server_channel_has_global(chl->channel);
-      silc_hash_table_list_reset(&htl);
-    }
-
-    /* If the sender of this packet is server and we are router we need to
-       broadcast this packet to other routers in the network. */
-    if (!server->standalone && server->server_type == SILC_ROUTER &&
-       sock->type == SILC_SOCKET_TYPE_SERVER &&
-       !(packet->flags & SILC_PACKET_FLAG_BROADCAST)) {
-      SILC_LOG_DEBUG(("Broadcasting received Resume Client packet"));
-      silc_server_packet_send(server, server->router->connection,
-                             packet->type, 
-                             packet->flags | SILC_PACKET_FLAG_BROADCAST,
-                             buffer->data, buffer->len, FALSE);
-      silc_server_backup_send(server, (SilcServerEntry)sock->user_data, 
-                             packet->type, packet->flags,
-                             packet->buffer->data, packet->buffer->len, 
-                             FALSE, TRUE);
-    }
-
-    silc_free(server_id);
-  }
-
-  silc_free(client_id);
-}
index b28d3de498a0197bc4d14a2258d688fbd6e625d4..0aed4ca934ff71230f655e1fddf9e7e45b8fd270 100644 (file)
@@ -78,8 +78,5 @@ void silc_server_rekey(SilcServer server,
 void silc_server_ftp(SilcServer server,
                     SilcSocketConnection sock,
                     SilcPacketContext *packet);
-void silc_server_resume_client(SilcServer server,
-                              SilcSocketConnection sock,
-                              SilcPacketContext *packet);
 
 #endif
index 019df0699a68c825613d772a9ab75ff9b2794593..05b3cd8cff0eb8a334c28384aecf4d9e6c5db414 100644 (file)
@@ -444,9 +444,6 @@ void silc_server_packet_send_clients(SilcServer server,
 
     /* Send to locally connected client */
     sock = (SilcSocketConnection)client->connection;
-    if (!sock)
-      continue;
-
     silc_server_packet_send_dest(server, sock, type, flags,
                                 client->id, SILC_ID_CLIENT,
                                 data, data_len, force_send);
@@ -784,8 +781,7 @@ void silc_server_packet_relay_to_channel(SilcServer server,
   silc_hash_table_list(channel->user_list, &htl);
   while (silc_hash_table_get(&htl, NULL, (void *)&chl)) {
     client = chl->client;
-    if (!client || client == sender_entry || 
-       chl->mode & SILC_CHANNEL_UMODE_BLOCK_MESSAGES)
+    if (!client || client == sender_entry)
       continue;
 
     /* If the client has set router it means that it is not locally
@@ -1097,8 +1093,7 @@ void silc_server_send_notify_nick_change(SilcServer server,
                                         SilcSocketConnection sock,
                                         bool broadcast,
                                         SilcClientID *old_id,
-                                        SilcClientID *new_id,
-                                        const char *nickname)
+                                        SilcClientID *new_id)
 {
   SilcBuffer idp1, idp2;
 
@@ -1107,8 +1102,7 @@ void silc_server_send_notify_nick_change(SilcServer server,
 
   silc_server_send_notify(server, sock, broadcast, 
                          SILC_NOTIFY_TYPE_NICK_CHANGE,
-                         3, idp1->data, idp1->len, idp2->data, idp2->len,
-                         nickname, nickname ? strlen(nickname) : 0);
+                         2, idp1->data, idp1->len, idp2->data, idp2->len);
   silc_buffer_free(idp1);
   silc_buffer_free(idp2);
 }
@@ -1290,21 +1284,16 @@ void silc_server_send_notify_killed(SilcServer server,
                                    SilcSocketConnection sock,
                                    bool broadcast,
                                    SilcClientID *client_id,
-                                   const char *comment,
-                                   void *killer, SilcIdType killer_type)
+                                   char *comment)
 {
-  SilcBuffer idp1;
-  SilcBuffer idp2;
+  SilcBuffer idp;
 
-  idp1 = silc_id_payload_encode(client_id, SILC_ID_CLIENT);
-  idp2 = silc_id_payload_encode(killer, killer_type);
+  idp = silc_id_payload_encode((void *)client_id, SILC_ID_CLIENT);
   silc_server_send_notify_dest(server, sock, broadcast, (void *)client_id,
                               SILC_ID_CLIENT, SILC_NOTIFY_TYPE_KILLED,
-                              3, idp1->data, idp1->len,
-                              comment, comment ? strlen(comment) : 0,
-                              idp2->data, idp2->len);
-  silc_buffer_free(idp1);
-  silc_buffer_free(idp2);
+                              comment ? 2 : 1, idp->data, idp->len,
+                              comment, comment ? strlen(comment) : 0);
+  silc_buffer_free(idp);
 }
 
 /* Sends UMODE_CHANGE notify type. This tells that `client_id' client's
@@ -1724,7 +1713,6 @@ void silc_server_send_command_reply(SilcServer server,
                                    SilcSocketConnection sock,
                                    SilcCommand command, 
                                    SilcCommandStatus status,
-                                   SilcCommandStatus error,
                                    SilcUInt16 ident,
                                    SilcUInt32 argc, ...)
 {
@@ -1733,8 +1721,8 @@ void silc_server_send_command_reply(SilcServer server,
 
   va_start(ap, argc);
 
-  packet = silc_command_reply_payload_encode_vap(command, status, error,
-                                                ident, argc, ap);
+  packet = silc_command_reply_payload_encode_vap(command, status, ident, 
+                                                argc, ap);
   silc_server_packet_send(server, sock, SILC_PACKET_COMMAND_REPLY, 0,
                          packet->data, packet->len, TRUE);
   silc_buffer_free(packet);
@@ -1750,7 +1738,6 @@ void silc_server_send_dest_command_reply(SilcServer server,
                                         SilcIdType dst_id_type,
                                         SilcCommand command, 
                                         SilcCommandStatus status,
-                                        SilcCommandStatus error,
                                         SilcUInt16 ident,
                                         SilcUInt32 argc, ...)
 {
@@ -1759,8 +1746,8 @@ void silc_server_send_dest_command_reply(SilcServer server,
 
   va_start(ap, argc);
 
-  packet = silc_command_reply_payload_encode_vap(command, status, error,
-                                                ident, argc, ap);
+  packet = silc_command_reply_payload_encode_vap(command, status, ident, 
+                                                argc, ap);
   silc_server_packet_send_dest(server, sock, SILC_PACKET_COMMAND_REPLY, 0,
                               dst_id, dst_id_type, packet->data, 
                               packet->len, TRUE);
index c40c888ca1a2c1aaa5cc2d08727ecb5c78625934..3cd431f96ce4cdcfb6dd354b2d4c2e468ff0e934 100644 (file)
@@ -123,8 +123,7 @@ void silc_server_send_notify_nick_change(SilcServer server,
                                         SilcSocketConnection sock,
                                         bool broadcast,
                                         SilcClientID *old_id,
-                                        SilcClientID *new_id,
-                                        const char *nickname);
+                                        SilcClientID *new_id);
 void silc_server_send_notify_join(SilcServer server,
                                  SilcSocketConnection sock,
                                  bool broadcast,
@@ -172,8 +171,7 @@ void silc_server_send_notify_killed(SilcServer server,
                                    SilcSocketConnection sock,
                                    bool broadcast,
                                    SilcClientID *client_id,
-                                   const char *comment,
-                                   void *killer, SilcIdType killer_type);
+                                   char *comment);
 void silc_server_send_notify_umode(SilcServer server,
                                   SilcSocketConnection sock,
                                   bool broadcast,
@@ -233,7 +231,6 @@ void silc_server_send_command_reply(SilcServer server,
                                    SilcSocketConnection sock,
                                    SilcCommand command, 
                                    SilcCommandStatus status,
-                                   SilcCommandStatus error,
                                    SilcUInt16 ident,
                                    SilcUInt32 argc, ...);
 void silc_server_send_dest_command_reply(SilcServer server, 
@@ -242,7 +239,6 @@ void silc_server_send_dest_command_reply(SilcServer server,
                                         SilcIdType dst_id_type,
                                         SilcCommand command, 
                                         SilcCommandStatus status,
-                                        SilcCommandStatus error,
                                         SilcUInt16 ident,
                                         SilcUInt32 argc, ...);
 void silc_server_send_heartbeat(SilcServer server,
index 6aa3ac93b54cb432493347297b4c5d26aab35340..65fafeeae26e53ab27c5f39f2231a9f7e39a4eaa 100644 (file)
@@ -325,36 +325,60 @@ int silc_server_protocol_ke_set_keys(SilcServer server,
 SilcSKEStatus silc_ske_check_version(SilcSKE ske, unsigned char *version,
                                     SilcUInt32 len, void *context)
 {
-  SilcUInt32 l_protocol_version = 0, r_protocol_version = 0;
+  SilcSKEStatus status = SILC_SKE_STATUS_OK;
+  char *cp;
+  int maj = 0, min = 0, build = 0, maj2 = 0, min2 = 0, build2 = 0;
 
   SILC_LOG_INFO(("%s (%s) is version %s", ske->sock->hostname,
                 ske->sock->ip, version));
 
-  if (!silc_parse_version_string(version, &r_protocol_version, NULL, NULL,
-                                NULL, NULL)) {
-    SILC_LOG_ERROR(("%s (%s) %s is not allowed/supported version", 
-                   ske->sock->hostname, ske->sock->ip, version));
-    return SILC_SKE_STATUS_BAD_VERSION;
+  /* Check for initial version string. Allowed "SILC-x.x-". More 
+     specific protocol version is checked later in session. */
+  if (!strstr(version, "SILC-"))
+    status = SILC_SKE_STATUS_BAD_VERSION;
+
+  /* Check software version */
+
+  cp = version + 9;
+  if (!cp)
+    status = SILC_SKE_STATUS_BAD_VERSION;
+
+  maj = atoi(cp);
+  cp = strchr(cp, '.');
+  if (cp) {
+    min = atoi(cp + 1);
+    cp++;
+  }
+  if (cp) {
+    cp = strchr(cp, '.');
+    if (cp)
+      build = atoi(cp + 1);
   }
 
-  if (!silc_parse_version_string(silc_version_string, 
-                                &l_protocol_version, NULL, NULL,
-                                NULL, NULL)) {
-    SILC_LOG_ERROR(("%s (%s) %s is not allowed/supported version", 
-                   ske->sock->hostname, ske->sock->ip, version));
-    return SILC_SKE_STATUS_BAD_VERSION;
+  cp = silc_version_string + 9;
+  if (!cp)
+    status = SILC_SKE_STATUS_BAD_VERSION;
+
+  maj2 = atoi(cp);
+  cp = strchr(cp, '.');
+  if (cp) {
+    min2 = atoi(cp + 1);
+    cp++;
+  }
+  if (cp) {
+    cp = strchr(cp, '.');
+    if (cp)
+      build2 = atoi(cp + 1);
   }
 
-  /* If remote is too new, don't connect */
-  if (l_protocol_version < r_protocol_version) {
+  if (maj != maj2)
+    status = SILC_SKE_STATUS_BAD_VERSION;
+
+  if (status == SILC_SKE_STATUS_BAD_VERSION)
     SILC_LOG_ERROR(("%s (%s) %s is not allowed/supported version", 
                    ske->sock->hostname, ske->sock->ip, version));
-    return SILC_SKE_STATUS_BAD_VERSION;
-  }
-
-  ske->sock->version = r_protocol_version;
 
-  return SILC_SKE_STATUS_OK;
+  return status;
 }
 
 /* Callback that is called by the SKE to indicate that it is safe to
@@ -690,10 +714,10 @@ SILC_TASK_CALLBACK(silc_server_protocol_key_exchange)
  */
 
 static int 
-silc_server_password_authentication(SilcServer server, char *local_auth, 
-                                   char *remote_auth)
+silc_server_password_authentication(SilcServer server, char *remote_auth, 
+                                   char *local_auth)
 {
-  if (!remote_auth || !local_auth || strlen(local_auth) != strlen(remote_auth))
+  if (!remote_auth || !local_auth)
     return FALSE;
 
   if (!memcmp(remote_auth, local_auth, strlen(local_auth)))
index 87de942ec0f1063da4c0d818629e9c2df32879b2..6f22636a7b21a078ee5a59dc49f14253276347d3 100644 (file)
@@ -44,7 +44,6 @@ SILC_TASK_CALLBACK(silc_server_timeout_remote);
 SILC_TASK_CALLBACK(silc_server_channel_key_rekey);
 SILC_TASK_CALLBACK(silc_server_failure_callback);
 SILC_TASK_CALLBACK(silc_server_rekey_callback);
-SILC_TASK_CALLBACK(silc_server_get_stats);
 
 /* Allocates a new SILC server object. This has to be done before the server
    can be used. After allocation one must call silc_server_init to initialize
@@ -149,8 +148,6 @@ bool silc_server_init(SilcServer server)
 
   SILC_LOG_DEBUG(("Initializing server"));
 
-  server->starttime = time(NULL);
-
   /* Take config object for us */
   silc_server_config_ref(&server->config_ref, server->config, 
                         server->config);
@@ -341,13 +338,6 @@ bool silc_server_init(SilcServer server)
                         (void *)purge, purge->timeout, 0,
                         SILC_TASK_TIMEOUT, SILC_TASK_PRI_LOW);
 
-  /* If we are normal server we'll retrieve network statisticial information
-     once in a while from the router. */
-  if (server->server_type == SILC_SERVER)
-    silc_schedule_task_add(purge->schedule, 0, silc_server_get_stats,
-                          server, 10, 0, SILC_TASK_TIMEOUT,
-                          SILC_TASK_PRI_LOW);
-
   SILC_LOG_DEBUG(("Server initialized"));
 
   /* We are done here, return succesfully */
@@ -1435,7 +1425,8 @@ SILC_TASK_CALLBACK(silc_server_accept_new_connection_final)
       /* Statistics */
       server->stat.my_clients++;
       server->stat.clients++;
-      server->stat.cell_clients++;
+      if (server->server_type == SILC_ROUTER)
+       server->stat.cell_clients++;
 
       /* Get connection parameters */
       if (conn->param) {
@@ -2335,14 +2326,6 @@ void silc_server_packet_parse_type(SilcServer server,
     silc_server_ftp(server, sock, packet);
     break;
 
-  case SILC_PACKET_RESUME_CLIENT:
-    /* Resume client */
-    SILC_LOG_DEBUG(("Resume Client packet"));
-    if (packet->flags & SILC_PACKET_FLAG_LIST)
-      break;
-    silc_server_resume_client(server, sock, packet);
-    break;
-
   case SILC_PACKET_RESUME_ROUTER:
     /* Resume router packet received. This packet is received for backup
        router resuming protocol. */
@@ -2509,7 +2492,7 @@ void silc_server_free_client_data(SilcServer server,
   /* Update statistics */
   server->stat.my_clients--;
   server->stat.clients--;
-  if (server->stat.cell_clients)
+  if (server->server_type == SILC_ROUTER)
     server->stat.cell_clients--;
   SILC_OPER_STATS_UPDATE(client, server, SILC_UMODE_SERVER_OPERATOR);
   SILC_OPER_STATS_UPDATE(client, router, SILC_UMODE_ROUTER_OPERATOR);
@@ -2523,9 +2506,9 @@ void silc_server_free_client_data(SilcServer server,
                         (void *)i, 300, 0,
                         SILC_TASK_TIMEOUT, SILC_TASK_PRI_LOW);
   client->data.status &= ~SILC_IDLIST_STATUS_REGISTERED;
-  client->mode = 0;
   client->router = NULL;
   client->connection = NULL;
+  client->mode = 0;
 }
 
 /* Frees user_data pointer from socket connection object. This also sends
@@ -3015,9 +2998,6 @@ SilcChannelEntry silc_server_create_new_channel(SilcServer server,
 
   server->stat.my_channels++;
 
-  if (server->server_type == SILC_ROUTER)
-    entry->users_resolved = TRUE;
-
   return entry;
 }
 
@@ -3082,9 +3062,6 @@ silc_server_create_new_channel_with_id(SilcServer server,
 
   server->stat.my_channels++;
 
-  if (server->server_type == SILC_ROUTER)
-    entry->users_resolved = TRUE;
-
   return entry;
 }
 
@@ -3894,7 +3871,6 @@ void silc_server_save_users_on_channel(SilcServer server,
   SilcClientID *client_id;
   SilcClientEntry client;
   SilcIDCacheEntry cache;
-  SilcChannelClientEntry chl;
   bool global;
 
   SILC_LOG_DEBUG(("Start"));
@@ -3958,126 +3934,16 @@ void silc_server_save_users_on_channel(SilcServer server,
 
     silc_free(client_id);
 
-    if (!silc_server_client_on_channel(client, channel, &chl)) {
+    if (!silc_server_client_on_channel(client, channel, NULL)) {
       /* Client was not on the channel, add it. */
-      chl = silc_calloc(1, sizeof(*chl));
+      SilcChannelClientEntry chl = silc_calloc(1, sizeof(*chl));
       chl->client = client;
       chl->mode = mode;
       chl->channel = channel;
       silc_hash_table_add(channel->user_list, chl->client, chl);
       silc_hash_table_add(client->channels, chl->channel, chl);
       channel->user_count++;
-    } else {
-      /* Update mode */
-      chl->mode = mode;
-    }
-  }
-}
-
-/* Saves channels and channels user modes to the `client'.  Removes
-   the client from those channels that are not sent in the list but
-   it has joined. */
-
-void silc_server_save_user_channels(SilcServer server,
-                                   SilcSocketConnection sock,
-                                   SilcClientEntry client,
-                                   SilcBuffer channels,
-                                   SilcBuffer channels_user_modes)
-{
-  SilcDList ch;
-  SilcUInt32 *chumodes;
-  SilcChannelPayload entry;
-  SilcChannelEntry channel;
-  SilcChannelID *channel_id;
-  SilcChannelClientEntry chl;
-  SilcHashTable ht = NULL;
-  SilcHashTableList htl;
-  char *name;
-  int i = 0;
-
-  if (!channels ||!channels_user_modes)
-    goto out;
-  
-  ch = silc_channel_payload_parse_list(channels->data, channels->len);
-  if (ch && silc_get_mode_list(channels_user_modes, silc_dlist_count(ch),
-                              &chumodes)) {
-    ht = silc_hash_table_alloc(0, silc_hash_ptr, NULL, NULL, 
-                              NULL, NULL, NULL, TRUE);
-    silc_dlist_start(ch);
-    while ((entry = silc_dlist_get(ch)) != SILC_LIST_END) {
-      /* Check if we have this channel, and add it if we don't have it.
-        Also add the client on the channel unless it is there already. */
-      channel_id = silc_channel_get_id_parse(entry);
-      channel = silc_idlist_find_channel_by_id(server->local_list, 
-                                              channel_id, NULL);
-      if (!channel)
-       channel = silc_idlist_find_channel_by_id(server->global_list,
-                                                channel_id, NULL);
-      if (!channel) {
-       if (server->server_type != SILC_SERVER) {
-         silc_free(channel_id);
-         i++;
-         continue;
-       }
-       
-       /* We don't have that channel anywhere, add it. */
-       name = silc_channel_get_name(entry, NULL);
-       channel = silc_idlist_add_channel(server->global_list, strdup(name), 0,
-                                         channel_id, server->router,
-                                         NULL, NULL, 0);
-       if (!channel) {
-         silc_free(channel_id);
-         i++;
-         continue;
-       }
-       channel_id = NULL;
-      }
-
-      channel->mode = silc_channel_get_mode(entry);
-
-      /* Add the client on the channel */
-      if (!silc_server_client_on_channel(client, channel, &chl)) {
-       chl = silc_calloc(1, sizeof(*chl));
-       chl->client = client;
-       chl->mode = chumodes[i++];
-       chl->channel = channel;
-       silc_hash_table_add(channel->user_list, chl->client, chl);
-       silc_hash_table_add(client->channels, chl->channel, chl);
-       channel->user_count++;
-      } else {
-       /* Update mode */
-       chl->mode = chumodes[i++];
-      }
-
-      silc_hash_table_add(ht, channel, channel);
-      silc_free(channel_id);
-    }
-    silc_channel_payload_list_free(ch);
-    silc_free(chumodes);
-  }
-
- out:
-  /* Go through the list again and remove client from channels that
-     are no part of the list. */
-  if (ht) {
-    silc_hash_table_list(client->channels, &htl);
-    while (silc_hash_table_get(&htl, NULL, (void **)&chl)) {
-      if (!silc_hash_table_find(ht, chl->channel, NULL, NULL)) {
-       silc_hash_table_del(chl->channel->user_list, chl->client);
-       silc_hash_table_del(chl->client->channels, chl->channel);
-       silc_free(chl);
-      }
-    }
-    silc_hash_table_list_reset(&htl);
-    silc_hash_table_free(ht);
-  } else {
-    silc_hash_table_list(client->channels, &htl);
-    while (silc_hash_table_get(&htl, NULL, (void **)&chl)) {
-      silc_hash_table_del(chl->channel->user_list, chl->client);
-      silc_hash_table_del(chl->client->channels, chl->channel);
-      silc_free(chl);
     }
-    silc_hash_table_list_reset(&htl);
   }
 }
 
@@ -4086,22 +3952,17 @@ void silc_server_save_user_channels(SilcServer server,
    could not be found to the client. If the `client_id' is specified then
    it is used and the `id_data' is ignored. */
 
-SilcSocketConnection
-silc_server_get_client_route(SilcServer server,
-                            unsigned char *id_data,
-                            SilcUInt32 id_len,
-                            SilcClientID *client_id,
-                            SilcIDListData *idata,
-                            SilcClientEntry *client_entry)
+SilcSocketConnection silc_server_get_client_route(SilcServer server,
+                                                 unsigned char *id_data,
+                                                 SilcUInt32 id_len,
+                                                 SilcClientID *client_id,
+                                                 SilcIDListData *idata)
 {
   SilcClientID *id;
   SilcClientEntry client;
 
   SILC_LOG_DEBUG(("Start"));
 
-  if (client_entry)
-    *client_entry = NULL;
-
   /* Decode destination Client ID */
   if (!client_id) {
     id = silc_id_str2id(id_data, id_len, SILC_ID_CLIENT);
@@ -4133,8 +3994,6 @@ silc_server_get_client_route(SilcServer server,
     /* Seems that client really is directly connected to us */
     if (idata)
       *idata = (SilcIDListData)client;
-    if (client_entry)
-      *client_entry = client;
     return client->connection;
   }
 
@@ -4173,10 +4032,7 @@ silc_server_get_client_route(SilcServer server,
    Secret channels are not put to the list. */
 
 SilcBuffer silc_server_get_client_channel_list(SilcServer server,
-                                              SilcClientEntry client,
-                                              bool get_private,
-                                              bool get_secret,
-                                              SilcBuffer *user_mode_list)
+                                              SilcClientEntry client)
 {
   SilcBuffer buffer = NULL;
   SilcChannelEntry channel;
@@ -4187,16 +4043,12 @@ SilcBuffer silc_server_get_client_channel_list(SilcServer server,
   SilcUInt16 name_len;
   int len;
 
-  if (user_mode_list)
-    *user_mode_list = NULL;
-
   silc_hash_table_list(client->channels, &htl);
   while (silc_hash_table_get(&htl, NULL, (void *)&chl)) {
     channel = chl->channel;
 
-    if (channel->mode & SILC_CHANNEL_MODE_SECRET && !get_secret)
-      continue;
-    if (channel->mode & SILC_CHANNEL_MODE_PRIVATE && !get_private)
+    if (channel->mode & SILC_CHANNEL_MODE_SECRET ||
+       channel->mode & SILC_CHANNEL_MODE_PRIVATE)
       continue;
 
     cid = silc_id_id2str(channel->id, SILC_ID_CHANNEL);
@@ -4205,37 +4057,23 @@ SilcBuffer silc_server_get_client_channel_list(SilcServer server,
 
     len = 4 + name_len + id_len + 4;
     buffer = silc_buffer_realloc(buffer,
-                                (buffer ? buffer->truelen + len : len));
-    silc_buffer_pull_tail(buffer, (buffer->end - buffer->data));
+                                (buffer ? (buffer)->truelen + len : len));
+    silc_buffer_pull_tail(buffer, ((buffer)->end - (buffer)->data));
     silc_buffer_format(buffer,
                       SILC_STR_UI_SHORT(name_len),
                       SILC_STR_UI_XNSTRING(channel->channel_name,
                                            name_len),
                       SILC_STR_UI_SHORT(id_len),
                       SILC_STR_UI_XNSTRING(cid, id_len),
-                      SILC_STR_UI_INT(chl->channel->mode),
+                      SILC_STR_UI_INT(chl->mode), /* Client's mode */
                       SILC_STR_END);
     silc_buffer_pull(buffer, len);
     silc_free(cid);
-
-    if (user_mode_list) {
-      *user_mode_list = silc_buffer_realloc(*user_mode_list,
-                                           (*user_mode_list ?
-                                            (*user_mode_list)->truelen + 4 :
-                                            4));
-      silc_buffer_pull_tail(*user_mode_list, ((*user_mode_list)->end -
-                                             (*user_mode_list)->data));
-      SILC_PUT32_MSB(chl->mode, (*user_mode_list)->data);
-      silc_buffer_pull(*user_mode_list, 4);
-    }
   }
   silc_hash_table_list_reset(&htl);
 
   if (buffer)
     silc_buffer_push(buffer, buffer->data - buffer->head);
-  if (user_mode_list && *user_mode_list)
-    silc_buffer_push(*user_mode_list, ((*user_mode_list)->data -
-                                      (*user_mode_list)->head));
 
   return buffer;
 }
@@ -4245,7 +4083,6 @@ SilcBuffer silc_server_get_client_channel_list(SilcServer server,
 
 SilcClientEntry silc_server_get_client_resolve(SilcServer server,
                                               SilcClientID *client_id,
-                                              bool always_resolve,
                                               bool *resolved)
 {
   SilcClientEntry client;
@@ -4265,15 +4102,12 @@ SilcClientEntry silc_server_get_client_resolve(SilcServer server,
   if (!client && server->standalone)
     return NULL;
 
-  if (!client || !client->nickname || !client->username ||
-      always_resolve) {
+  if (!client || !client->nickname || !client->username) {
     SilcBuffer buffer, idp;
 
-    if (client) {
-      client->data.status |= SILC_IDLIST_STATUS_RESOLVING;
-      client->data.status &= ~SILC_IDLIST_STATUS_RESOLVED;
-      client->resolve_cmd_ident = ++server->cmd_ident;
-    }
+    client->data.status |= SILC_IDLIST_STATUS_RESOLVING;
+    client->data.status &= ~SILC_IDLIST_STATUS_RESOLVED;
+    client->resolve_cmd_ident = ++server->cmd_ident;
 
     idp = silc_id_payload_encode(client_id, SILC_ID_CLIENT);
     buffer = silc_command_payload_encode_va(SILC_COMMAND_WHOIS,
@@ -4373,30 +4207,3 @@ SILC_TASK_CALLBACK_GLOBAL(silc_server_rekey_final)
     silc_ske_free(ctx->ske);
   silc_free(ctx);
 }
-
-/* Task callback used to retrieve network statistical information from
-   router server once in a while. */
-
-SILC_TASK_CALLBACK(silc_server_get_stats)
-{
-  SilcServer server = (SilcServer)context;
-  SilcBuffer idp, packet;
-
-  SILC_LOG_DEBUG(("Retrieving stats from router"));
-
-  if (!server->standalone) {
-    idp = silc_id_payload_encode(server->router->id, SILC_ID_SERVER);
-    packet = silc_command_payload_encode_va(SILC_COMMAND_STATS, 
-                                           ++server->cmd_ident, 1,
-                                           1, idp->data, idp->len);
-    silc_server_packet_send(server, server->router->connection,
-                           SILC_PACKET_COMMAND, 0, packet->data,
-                           packet->len, FALSE);
-    silc_buffer_free(packet);
-    silc_buffer_free(idp);
-  }
-
-  silc_schedule_task_add(server->schedule, 0, silc_server_get_stats,
-                        server, 120, 0, SILC_TASK_TIMEOUT,
-                        SILC_TASK_PRI_LOW);
-}
index 93ec1f49e68bbda839f1ba70feb7a4e49a6cdc57..4aaa18402d8b4b766e75214f85ca164c639dbf9c 100644 (file)
@@ -208,26 +208,15 @@ void silc_server_save_users_on_channel(SilcServer server,
                                       SilcBuffer user_list,
                                       SilcBuffer mode_list,
                                       SilcUInt32 user_count);
-void silc_server_save_user_channels(SilcServer server,
-                                   SilcSocketConnection sock,
-                                   SilcClientEntry client,
-                                   SilcBuffer channels,
-                                   SilcBuffer channels_user_modes);
-SilcSocketConnection
-silc_server_get_client_route(SilcServer server,
-                            unsigned char *id_data,
-                            SilcUInt32 id_len,
-                            SilcClientID *client_id,
-                            SilcIDListData *idata,
-                            SilcClientEntry *client_entry);
+SilcSocketConnection silc_server_get_client_route(SilcServer server,
+                                                 unsigned char *id_data,
+                                                 SilcUInt32 id_len,
+                                                 SilcClientID *client_id,
+                                                 SilcIDListData *idata);
 SilcBuffer silc_server_get_client_channel_list(SilcServer server,
-                                              SilcClientEntry client,
-                                              bool get_private,
-                                              bool get_secret,
-                                              SilcBuffer *user_mode_list);
+                                              SilcClientEntry client);
 SilcClientEntry silc_server_get_client_resolve(SilcServer server,
                                               SilcClientID *client_id,
-                                              bool always_resolve,
                                               bool *resolved);
 void silc_server_stderr(char *message);
 
index 7a6a9253c6bcb7b02b23a03696bdea81cc64ef09..f84566fc2f12e617ea69977b562bb4be80dcf991 100644 (file)
@@ -69,7 +69,6 @@ struct SilcServerStruct {
   SilcUInt32 id_string_len;
   SilcIdType id_type;
 
-  SilcUInt32 starttime;
   bool standalone;                  /* TRUE if server is standalone, and
                                        does not have connection to network. */
   bool listenning;                  /* TRUE if server is listenning for
index 2fe705f32b5c10064f8f541f15207b2a56552e49..cc62e4caa38687032eeae7952dd2d01955fcb129 100644 (file)
@@ -21,8 +21,6 @@
 #include "serverincludes.h"
 #include "server_internal.h"
 
-extern char *server_version;
-
 /* Removes the client from channels and possibly removes the channels
    as well.  After removing those channels that exist, their channel
    keys are regnerated. This is called only by the function
@@ -218,7 +216,7 @@ bool silc_server_remove_clients_by_server(SilcServer server,
 
        /* Update statistics */
        server->stat.clients--;
-       if (server->stat.cell_clients)
+       if (server->server_type == SILC_ROUTER)
          server->stat.cell_clients--;
        SILC_OPER_STATS_UPDATE(client, server, SILC_UMODE_SERVER_OPERATOR);
        SILC_OPER_STATS_UPDATE(client, router, SILC_UMODE_ROUTER_OPERATOR);
@@ -282,7 +280,7 @@ bool silc_server_remove_clients_by_server(SilcServer server,
 
        /* Update statistics */
        server->stat.clients--;
-       if (server->stat.cell_clients)
+       if (server->server_type == SILC_ROUTER)
          server->stat.cell_clients--;
        SILC_OPER_STATS_UPDATE(client, server, SILC_UMODE_SERVER_OPERATOR);
        SILC_OPER_STATS_UPDATE(client, router, SILC_UMODE_ROUTER_OPERATOR);
@@ -926,8 +924,6 @@ bool silc_server_connection_allowed(SilcServer server,
   if (ske && silc_ske_parse_version(ske, &r_protocol_version, NULL,
                                    &r_software_version, NULL,
                                    &r_vendor_version)) {
-    sock->version = r_protocol_version;
-
     /* Match protocol version */
     if (l_protocol_version && r_protocol_version &&
        r_protocol_version < l_protocol_version) {
@@ -1058,28 +1054,6 @@ bool silc_server_check_cmode_rights(SilcServer server,
     }
   }
   
-  if (mode & SILC_CHANNEL_MODE_SILENCE_USERS) {
-    if (!(channel->mode & SILC_CHANNEL_MODE_SILENCE_USERS))
-      if (is_op && !is_fo)
-       return FALSE;
-  } else {
-    if (channel->mode & SILC_CHANNEL_MODE_SILENCE_USERS) {
-      if (is_op && !is_fo)
-       return FALSE;
-    }
-  }
-  
-  if (mode & SILC_CHANNEL_MODE_SILENCE_OPERS) {
-    if (!(channel->mode & SILC_CHANNEL_MODE_SILENCE_OPERS))
-      if (is_op && !is_fo)
-       return FALSE;
-  } else {
-    if (channel->mode & SILC_CHANNEL_MODE_SILENCE_OPERS) {
-      if (is_op && !is_fo)
-       return FALSE;
-    }
-  }
-  
   return TRUE;
 }
 
@@ -1119,142 +1093,3 @@ bool silc_server_check_umode_rights(SilcServer server,
 
   return TRUE;
 }
-
-/* This function is used to send the notify packets and motd to the
-   incoming client connection. */
-
-void silc_server_send_connect_notifys(SilcServer server,
-                                     SilcSocketConnection sock,
-                                     SilcClientEntry client)
-{
-  SilcIDListData idata = (SilcIDListData)client;
-
-  /* Send some nice info to the client */
-  SILC_SERVER_SEND_NOTIFY(server, sock, SILC_NOTIFY_TYPE_NONE,
-                         ("Welcome to the SILC Network %s",
-                          client->username));
-  SILC_SERVER_SEND_NOTIFY(server, sock, SILC_NOTIFY_TYPE_NONE,
-                         ("Your host is %s, running version %s",
-                          server->server_name, server_version));
-
-  if (server->stat.clients && server->stat.servers + 1)
-    SILC_SERVER_SEND_NOTIFY(server, sock, SILC_NOTIFY_TYPE_NONE,
-                           ("There are %d clients on %d servers in SILC "
-                            "Network", server->stat.clients,
-                            server->stat.servers + 1));
-  if (server->stat.cell_clients && server->stat.cell_servers + 1)
-    SILC_SERVER_SEND_NOTIFY(server, sock, SILC_NOTIFY_TYPE_NONE,
-                           ("There are %d clients on %d server in our cell",
-                            server->stat.cell_clients,
-                            server->stat.cell_servers + 1));
-  if (server->server_type == SILC_ROUTER) {
-    SILC_SERVER_SEND_NOTIFY(server, sock, SILC_NOTIFY_TYPE_NONE,
-                           ("I have %d clients, %d channels, %d servers and "
-                            "%d routers",
-                            server->stat.my_clients, 
-                            server->stat.my_channels,
-                            server->stat.my_servers,
-                            server->stat.my_routers));
-  } else {
-    SILC_SERVER_SEND_NOTIFY(server, sock, SILC_NOTIFY_TYPE_NONE,
-                           ("I have %d clients and %d channels formed",
-                            server->stat.my_clients,
-                            server->stat.my_channels));
-  }
-
-  if (server->stat.server_ops || server->stat.router_ops)
-    SILC_SERVER_SEND_NOTIFY(server, sock, SILC_NOTIFY_TYPE_NONE,
-                           ("There are %d server operators and %d router "
-                            "operators online",
-                            server->stat.server_ops,
-                            server->stat.router_ops));
-  if (server->stat.my_router_ops + server->stat.my_server_ops)
-    SILC_SERVER_SEND_NOTIFY(server, sock, SILC_NOTIFY_TYPE_NONE,
-                           ("I have %d operators online",
-                            server->stat.my_router_ops +
-                            server->stat.my_server_ops));
-
-  SILC_SERVER_SEND_NOTIFY(server, sock, SILC_NOTIFY_TYPE_NONE,
-                         ("Your connection is secured with %s cipher, "
-                          "key length %d bits",
-                          idata->send_key->cipher->name,
-                          idata->send_key->cipher->key_len));
-  SILC_SERVER_SEND_NOTIFY(server, sock, SILC_NOTIFY_TYPE_NONE,
-                         ("Your current nickname is %s",
-                          client->nickname));
-
-  /* Send motd */
-  silc_server_send_motd(server, sock);
-}
-
-/* Kill the client indicated by `remote_client' sending KILLED notify
-   to the client, to all channels client has joined and to primary
-   router if needed.  The killed client is also removed from all channels. */
-
-void silc_server_kill_client(SilcServer server,
-                            SilcClientEntry remote_client,
-                            const char *comment,
-                            void *killer_id,
-                            SilcIdType killer_id_type)
-{
-  SilcBuffer killed, killer;
-
-  /* Send the KILL notify packets. First send it to the channel, then
-     to our primary router and then directly to the client who is being
-     killed right now. */
-
-  killed = silc_id_payload_encode(remote_client->id, SILC_ID_CLIENT);
-  killer = silc_id_payload_encode(killer_id, killer_id_type);
-
-  /* Send KILLED notify to the channels. It is not sent to the client
-     as it will be sent differently destined directly to the client and not
-     to the channel. */
-  silc_server_send_notify_on_channels(server, remote_client, 
-                                     remote_client, SILC_NOTIFY_TYPE_KILLED,
-                                     3, killed->data, killed->len,
-                                     comment, comment ? strlen(comment) : 0,
-                                     killer->data, killer->len);
-
-  /* Send KILLED notify to primary route */
-  if (!server->standalone)
-    silc_server_send_notify_killed(server, server->router->connection, TRUE,
-                                  remote_client->id, comment, 
-                                  killer_id, killer_id_type);
-
-  /* Send KILLED notify to the client directly */
-  if (remote_client->connection || remote_client->router)
-    silc_server_send_notify_killed(server, remote_client->connection ? 
-                                  remote_client->connection : 
-                                  remote_client->router->connection, FALSE,
-                                  remote_client->id, comment, 
-                                  killer_id, killer_id_type);
-
-  /* Remove the client from all channels. This generates new keys to the
-     channels as well. */
-  silc_server_remove_from_channels(server, NULL, remote_client, FALSE, 
-                                  NULL, TRUE);
-
-  /* Remove the client entry, If it is locally connected then we will also
-     disconnect the client here */
-  if (remote_client->connection) {
-    /* Remove locally conneted client */
-    SilcSocketConnection sock = remote_client->connection;
-    silc_server_free_client_data(server, sock, remote_client, FALSE, NULL);
-    silc_server_close_connection(server, sock);
-  } else {
-    /* Update statistics */
-    server->stat.clients--;
-    server->stat.my_clients--;
-    if (server->stat.cell_clients)
-      server->stat.cell_clients--;
-    SILC_OPER_STATS_UPDATE(remote_client, server, SILC_UMODE_SERVER_OPERATOR);
-    SILC_OPER_STATS_UPDATE(remote_client, router, SILC_UMODE_ROUTER_OPERATOR);
-
-    /* Remove remote client */
-    if (!silc_idlist_del_client(server->global_list, remote_client))
-      silc_idlist_del_client(server->local_list, remote_client);  
-}
-
-  silc_buffer_free(killer);
-  silc_buffer_free(killed);
-}
index 5a531037f7e6dfddba77861227531daee756e702..1545c1fd72053cdc88080114a4fa76326ec02340 100644 (file)
@@ -134,19 +134,4 @@ bool silc_server_check_umode_rights(SilcServer server,
                                    SilcClientEntry client,
                                    SilcUInt32 mode);
 
-/* This function is used to send the notify packets and motd to the
-   incoming client connection. */
-void silc_server_send_connect_notifys(SilcServer server,
-                                     SilcSocketConnection sock,
-                                     SilcClientEntry client);
-
-/* Kill the client indicated by `remote_client' sending KILLED notify
-   to the client, to all channels client has joined and to primary
-   router if needed.  The killed client is also removed from all channels. */
-void silc_server_kill_client(SilcServer server,
-                            SilcClientEntry remote_client,
-                            const char *comment,
-                            void *killer_id,
-                            SilcIdType killer_id_type);
-
 #endif /* SERVER_UTIL_H */
index 4ccfe543a697ef9841fd3ee34ceab7857bc7386d..88a6b4cbd62631ba6c6af1714a1f41fcc40a4dcd 100644 (file)
@@ -120,17 +120,10 @@ static bool my_parse_authdata(SilcAuthMethod auth_meth, char *p,
 {
   if (auth_meth == SILC_AUTH_PASSWORD) {
     /* p is a plain text password */
-    if (auth_data && auth_data_len) {
-      if (!silc_utf8_valid(p, strlen(p))) {
-       *auth_data_len = silc_utf8_encoded_len(p, strlen(p), 0);
-       *auth_data = silc_calloc(*auth_data_len, sizeof(unsigned char));
-       silc_utf8_encode(p, strlen(p), SILC_STRING_ASCII, *auth_data,
-                        *auth_data_len);
-      } else {
-       *auth_data = (void *) strdup(p);
-       *auth_data_len = (SilcUInt32) strlen(p);
-      }
-    }
+    if (auth_data)
+      *auth_data = (void *) strdup(p);
+    if (auth_data_len)
+      *auth_data_len = (SilcUInt32) strlen(p);
   } else if (auth_meth == SILC_AUTH_PUBLIC_KEY) {
     /* p is a public key file name */
     SilcPublicKey public_key;
index 53b7f81eb12a57efd4bed910f83f5699874dc60f..35693a717f1f5421c4b81c6b5baa65754a2af79c 100644 (file)
@@ -426,8 +426,8 @@ int main(int argc, char **argv)
 
   /* Stop the server and free it. */
   silc_server_stop(silcd);
-  silc_server_config_destroy(silcd->config);
   silc_server_free(silcd);
+  silc_server_config_destroy(silcd->config);
 
   /* Flush the logging system */
   silc_log_flush_all();
index e1b5871708010cf0962a293681cd941b915125e3..ba661651615d361468d6b54633a37f57662f8bbe 100755 (executable)
@@ -1,8 +1,10 @@
 #! /bin/sh
 # Attempt to guess a canonical system name.
-#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
 #   Free Software Foundation, Inc.
-#
+
+timestamp='2001-04-20'
+
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
 # the Free Software Foundation; either version 2 of the License, or
 # the same distribution terms that you use for the rest of that program.
 
 # Written by Per Bothner <bothner@cygnus.com>.
-# The master version of this file is at the FSF in /home/gd/gnu/lib.
-# Please send patches to <autoconf-patches@gnu.org>.
+# Please send patches to <config-patches@gnu.org>.
 #
 # This script attempts to guess a canonical system name similar to
 # config.sub.  If it succeeds, it prints the system name on stdout, and
 # exits with 0.  Otherwise, it exits with 1.
 #
 # The plan is that this can be called by configure scripts if you
-# don't specify an explicit system type (host/target name).
-#
-# Only a few systems have been added to this list; please add others
-# (but try to keep the structure clean).
-#
+# don't specify an explicit build system type.
 
-# Use $HOST_CC if defined. $CC may point to a cross-compiler
-if test x"$CC_FOR_BUILD" = x; then
-  if test x"$HOST_CC" != x; then
-    CC_FOR_BUILD="$HOST_CC"
-  else
-    if test x"$CC" != x; then
-      CC_FOR_BUILD="$CC"
-    else
-      CC_FOR_BUILD=cc
-    fi
-  fi
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION]
+
+Output the configuration name of the system \`$me' is run on.
+
+Operation modes:
+  -h, --help         print this help, then exit
+  -t, --time-stamp   print date of last modification, then exit
+  -v, --version      print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.guess ($timestamp)
+
+Originally written by Per Bothner.
+Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 99, 2000
+Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+  case $1 in
+    --time-stamp | --time* | -t )
+       echo "$timestamp" ; exit 0 ;;
+    --version | -v )
+       echo "$version" ; exit 0 ;;
+    --help | --h* | -h )
+       echo "$usage"; exit 0 ;;
+    -- )     # Stop option processing
+       shift; break ;;
+    - )        # Use stdin as input.
+       break ;;
+    -* )
+       echo "$me: invalid option $1$help" >&2
+       exit 1 ;;
+    * )
+       break ;;
+  esac
+done
+
+if test $# != 0; then
+  echo "$me: too many arguments$help" >&2
+  exit 1
 fi
 
 
+dummy=dummy-$$
+trap 'rm -f $dummy.c $dummy.o $dummy.rel $dummy; exit 1' 1 2 15
+
+# CC_FOR_BUILD -- compiler used by this script.
+# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
+# use `HOST_CC' if defined, but it is deprecated.
+
+case $CC_FOR_BUILD,$HOST_CC,$CC in
+ ,,)    echo "int dummy(){}" > $dummy.c
+       for c in cc gcc c89 ; do
+         ($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1
+         if test $? = 0 ; then
+            CC_FOR_BUILD="$c"; break
+         fi
+       done
+       rm -f $dummy.c $dummy.o $dummy.rel
+       if test x"$CC_FOR_BUILD" = x ; then
+         CC_FOR_BUILD=no_compiler_found
+       fi
+       ;;
+ ,,*)   CC_FOR_BUILD=$CC ;;
+ ,*,*)  CC_FOR_BUILD=$HOST_CC ;;
+esac
+
 # This is needed to find uname on a Pyramid OSx when run in the BSD universe.
 # (ghazi@noc.rutgers.edu 8/24/94.)
 if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
@@ -59,15 +120,57 @@ fi
 
 UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
 UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
-UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null`  || UNAME_SYSTEM=unknown
 UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
 
-dummy=dummy-$$
-trap 'rm -f $dummy.c $dummy.o $dummy; exit 1' 1 2 15
-
 # Note: order is significant - the case branches are not exclusive.
 
 case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+    *:NetBSD:*:*)
+       # Netbsd (nbsd) targets should (where applicable) match one or
+       # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
+       # *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
+       # switched to ELF, *-*-netbsd* would select the old
+       # object file format.  This provides both forward
+       # compatibility and a consistent mechanism for selecting the
+       # object file format.
+       # Determine the machine/vendor (is the vendor relevant).
+       case "${UNAME_MACHINE}" in
+           amiga) machine=m68k-unknown ;;
+           arm32) machine=arm-unknown ;;
+           atari*) machine=m68k-atari ;;
+           sun3*) machine=m68k-sun ;;
+           mac68k) machine=m68k-apple ;;
+           macppc) machine=powerpc-apple ;;
+           hp3[0-9][05]) machine=m68k-hp ;;
+           ibmrt|romp-ibm) machine=romp-ibm ;;
+           *) machine=${UNAME_MACHINE}-unknown ;;
+       esac
+       # The Operating System including object format, if it has switched
+       # to ELF recently, or will in the future.
+       case "${UNAME_MACHINE}" in
+           i386|sparc|amiga|arm*|hp300|mvme68k|vax|atari|luna68k|mac68k|news68k|next68k|pc532|sun3*|x68k)
+               if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
+                       | grep __ELF__ >/dev/null
+               then
+                   # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
+                   # Return netbsd for either.  FIX?
+                   os=netbsd
+               else
+                   os=netbsdelf
+               fi
+               ;;
+           *)
+               os=netbsd
+               ;;
+       esac
+       # The OS release
+       release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+       # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
+       # contains redundant information, the shorter form:
+       # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
+       echo "${machine}-${os}${release}"
+       exit 0 ;;
     alpha:OSF1:*:*)
        if test $UNAME_RELEASE = "V4.0"; then
                UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
@@ -77,41 +180,51 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
        # A Xn.n version is an unreleased experimental baselevel.
        # 1.2 uses "1.2" for uname -r.
        cat <<EOF >$dummy.s
+       .data
+\$Lformat:
+       .byte 37,100,45,37,120,10,0     # "%d-%x\n"
+
+       .text
        .globl main
+       .align 4
        .ent main
 main:
-       .frame \$30,0,\$26,0
-       .prologue 0
-       .long 0x47e03d80 # implver $0
-       lda \$2,259
-       .long 0x47e20c21 # amask $2,$1
-       srl \$1,8,\$2
-       sll \$2,2,\$2
-       sll \$0,3,\$0
-       addl \$1,\$0,\$0
-       addl \$2,\$0,\$0
-       ret \$31,(\$26),1
+       .frame \$30,16,\$26,0
+       ldgp \$29,0(\$27)
+       .prologue 1
+       .long 0x47e03d80 # implver \$0
+       lda \$2,-1
+       .long 0x47e20c21 # amask \$2,\$1
+       lda \$16,\$Lformat
+       mov \$0,\$17
+       not \$1,\$18
+       jsr \$26,printf
+       ldgp \$29,0(\$26)
+       mov 0,\$16
+       jsr \$26,exit
        .end main
 EOF
        $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
        if test "$?" = 0 ; then
-               ./$dummy
-               case "$?" in
-                       7)
+               case `./$dummy` in
+                       0-0)
                                UNAME_MACHINE="alpha"
                                ;;
-                       15)
+                       1-0)
                                UNAME_MACHINE="alphaev5"
                                ;;
-                       14)
+                       1-1)
                                UNAME_MACHINE="alphaev56"
                                ;;
-                       10)
+                       1-101)
                                UNAME_MACHINE="alphapca56"
                                ;;
-                       16)
+                       2-303)
                                UNAME_MACHINE="alphaev6"
                                ;;
+                       2-307)
+                               UNAME_MACHINE="alphaev67"
+                               ;;
                esac
        fi
        rm -f $dummy.s $dummy
@@ -127,11 +240,8 @@ EOF
        echo alpha-dec-winnt3.5
        exit 0 ;;
     Amiga*:UNIX_System_V:4.0:*)
-       echo m68k-cbm-sysv4
+       echo m68k-unknown-sysv4
        exit 0;;
-    amiga:NetBSD:*:*)
-      echo m68k-cbm-netbsd${UNAME_RELEASE}
-      exit 0 ;;
     amiga:OpenBSD:*:*)
        echo m68k-unknown-openbsd${UNAME_RELEASE}
        exit 0 ;;
@@ -162,10 +272,7 @@ EOF
     arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
        echo arm-acorn-riscix${UNAME_RELEASE}
        exit 0;;
-    arm32:NetBSD:*:*)
-       echo arm-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
-       exit 0 ;;
-    SR2?01:HI-UX/MPP:*:*)
+    SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
        echo hppa1.1-hitachi-hiuxmpp
        exit 0;;
     Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
@@ -221,15 +328,12 @@ EOF
     aushp:SunOS:*:*)
        echo sparc-auspex-sunos${UNAME_RELEASE}
        exit 0 ;;
-    atari*:NetBSD:*:*)
-       echo m68k-atari-netbsd${UNAME_RELEASE}
-       exit 0 ;;
     atari*:OpenBSD:*:*)
        echo m68k-unknown-openbsd${UNAME_RELEASE}
        exit 0 ;;
     # The situation for MiNT is a little confusing.  The machine name
     # can be virtually everything (everything which is not
-    # "atarist" or "atariste" at least should have a processor 
+    # "atarist" or "atariste" at least should have a processor
     # > m68000).  The system name ranges from "MiNT" over "FreeMiNT"
     # to the lowercase version "mint" (or "freemint").  Finally
     # the system name "TOS" denotes a system which is actually not
@@ -253,15 +357,9 @@ EOF
     *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
         echo m68k-unknown-mint${UNAME_RELEASE}
         exit 0 ;;
-    sun3*:NetBSD:*:*)
-       echo m68k-sun-netbsd${UNAME_RELEASE}
-       exit 0 ;;
     sun3*:OpenBSD:*:*)
        echo m68k-unknown-openbsd${UNAME_RELEASE}
        exit 0 ;;
-    mac68k:NetBSD:*:*)
-       echo m68k-apple-netbsd${UNAME_RELEASE}
-       exit 0 ;;
     mac68k:OpenBSD:*:*)
        echo m68k-unknown-openbsd${UNAME_RELEASE}
        exit 0 ;;
@@ -274,9 +372,6 @@ EOF
     powerpc:machten:*:*)
        echo powerpc-apple-machten${UNAME_RELEASE}
        exit 0 ;;
-    macppc:NetBSD:*:*)
-        echo powerpc-apple-netbsd${UNAME_RELEASE}
-        exit 0 ;;
     RISC*:Mach:*:*)
        echo mips-dec-mach_bsd4.3
        exit 0 ;;
@@ -292,6 +387,7 @@ EOF
     mips:*:*:UMIPS | mips:*:*:RISCos)
        sed 's/^        //' << EOF >$dummy.c
 #ifdef __cplusplus
+#include <stdio.h>  /* for printf() prototype */
        int main (int argc, char *argv[]) {
 #else
        int main (argc, argv) int argc; char *argv[]; {
@@ -312,10 +408,13 @@ EOF
 EOF
        $CC_FOR_BUILD $dummy.c -o $dummy \
          && ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
-         && rm $dummy.c $dummy && exit 0
+         && rm -f $dummy.c $dummy && exit 0
        rm -f $dummy.c $dummy
        echo mips-mips-riscos${UNAME_RELEASE}
        exit 0 ;;
+    Motorola:PowerMAX_OS:*:*)
+       echo powerpc-motorola-powermax
+       exit 0 ;;
     Night_Hawk:Power_UNIX:*:*)
        echo powerpc-harris-powerunix
        exit 0 ;;
@@ -331,7 +430,7 @@ EOF
     AViiON:dgux:*:*)
         # DG/UX returns AViiON for all architectures
         UNAME_PROCESSOR=`/usr/bin/uname -p`
-       if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110]
+       if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
        then
            if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
               [ ${TARGET_BINARY_INTERFACE}x = x ]
@@ -363,9 +462,17 @@ EOF
     ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
        echo romp-ibm-aix      # uname -m gives an 8 hex-code CPU id
        exit 0 ;;              # Note that: echo "'`uname -s`'" gives 'AIX '
-    i?86:AIX:*:*)
+    i*86:AIX:*:*)
        echo i386-ibm-aix
        exit 0 ;;
+    ia64:AIX:*:*)
+       if [ -x /usr/bin/oslevel ] ; then
+               IBM_REV=`/usr/bin/oslevel`
+       else
+               IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+       fi
+       echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
+       exit 0 ;;
     *:AIX:2:3)
        if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
                sed 's/^                //' << EOF >$dummy.c
@@ -379,7 +486,7 @@ EOF
                        exit(0);
                        }
 EOF
-               $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm $dummy.c $dummy && exit 0
+               $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0
                rm -f $dummy.c $dummy
                echo rs6000-ibm-aix3.2.5
        elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
@@ -388,9 +495,9 @@ EOF
                echo rs6000-ibm-aix3.2
        fi
        exit 0 ;;
-    *:AIX:*:4)
+    *:AIX:*:[45])
        IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'`
-       if /usr/sbin/lsattr -EHl ${IBM_CPU_ID} | grep POWER >/dev/null 2>&1; then
+       if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
                IBM_ARCH=rs6000
        else
                IBM_ARCH=powerpc
@@ -398,7 +505,7 @@ EOF
        if [ -x /usr/bin/oslevel ] ; then
                IBM_REV=`/usr/bin/oslevel`
        else
-               IBM_REV=4.${UNAME_RELEASE}
+               IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
        fi
        echo ${IBM_ARCH}-ibm-aix${IBM_REV}
        exit 0 ;;
@@ -408,7 +515,7 @@ EOF
     ibmrt:4.4BSD:*|romp-ibm:BSD:*)
        echo romp-ibm-bsd4.4
        exit 0 ;;
-    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC NetBSD and
+    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
        echo romp-ibm-bsd${UNAME_RELEASE}   # 4.3 with uname added to
        exit 0 ;;                           # report: romp-ibm BSD 4.3
     *:BOSX:*:*)
@@ -424,11 +531,31 @@ EOF
        echo m68k-hp-bsd4.4
        exit 0 ;;
     9000/[34678]??:HP-UX:*:*)
+       HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
        case "${UNAME_MACHINE}" in
            9000/31? )            HP_ARCH=m68000 ;;
            9000/[34]?? )         HP_ARCH=m68k ;;
            9000/[678][0-9][0-9])
+              case "${HPUX_REV}" in
+                11.[0-9][0-9])
+                  if [ -x /usr/bin/getconf ]; then
+                    sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
+                    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
+                    case "${sc_cpu_version}" in
+                      523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
+                      528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
+                      532)                      # CPU_PA_RISC2_0
+                        case "${sc_kernel_bits}" in
+                          32) HP_ARCH="hppa2.0n" ;;
+                          64) HP_ARCH="hppa2.0w" ;;
+                        esac ;;
+                    esac
+                  fi ;;
+              esac
+              if [ "${HP_ARCH}" = "" ]; then
               sed 's/^              //' << EOF >$dummy.c
+
+              #define _HPUX_SOURCE
               #include <stdlib.h>
               #include <unistd.h>
 
@@ -460,11 +587,16 @@ EOF
               }
 EOF
        (CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null ) && HP_ARCH=`./$dummy`
+       if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi
        rm -f $dummy.c $dummy
+       fi ;;
        esac
-       HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
        echo ${HP_ARCH}-hp-hpux${HPUX_REV}
        exit 0 ;;
+    ia64:HP-UX:*:*)
+       HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+       echo ia64-hp-hpux${HPUX_REV}
+       exit 0 ;;
     3050*:HI-UX:*:*)
        sed 's/^        //' << EOF >$dummy.c
        #include <unistd.h>
@@ -491,7 +623,7 @@ EOF
          exit (0);
        }
 EOF
-       $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm $dummy.c $dummy && exit 0
+       $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0
        rm -f $dummy.c $dummy
        echo unknown-hitachi-hiuxwe2
        exit 0 ;;
@@ -510,7 +642,7 @@ EOF
     hp8??:OSF1:*:*)
        echo hppa1.0-hp-osf
        exit 0 ;;
-    i?86:OSF1:*:*)
+    i*86:OSF1:*:*)
        if [ -x /usr/sbin/sysversion ] ; then
            echo ${UNAME_MACHINE}-unknown-osf1mk
        else
@@ -553,29 +685,30 @@ EOF
              -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
        exit 0 ;;
     CRAY*TS:*:*:*)
-       echo t90-cray-unicos${UNAME_RELEASE}
+       echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit 0 ;;
+    CRAY*T3D:*:*:*)
+       echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
        exit 0 ;;
     CRAY*T3E:*:*:*)
-       echo alpha-cray-unicosmk${UNAME_RELEASE}
+       echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit 0 ;;
+    CRAY*SV1:*:*:*)
+       echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
        exit 0 ;;
     CRAY-2:*:*:*)
        echo cray2-cray-unicos
         exit 0 ;;
-    F300:UNIX_System_V:*:*)
+    F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
+       FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
         FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
         FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
-        echo "f300-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+        echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
         exit 0 ;;
-    F301:UNIX_System_V:*:*)
-       echo f301-fujitsu-uxpv`echo $UNAME_RELEASE | sed 's/ .*//'`
-       exit 0 ;;
-    hp3[0-9][05]:NetBSD:*:*)
-       echo m68k-hp-netbsd${UNAME_RELEASE}
-       exit 0 ;;
     hp300:OpenBSD:*:*)
        echo m68k-unknown-openbsd${UNAME_RELEASE}
        exit 0 ;;
-    i?86:BSD/386:*:* | i?86:BSD/OS:*:*)
+    i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
        echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
        exit 0 ;;
     sparc*:BSD/OS:*:*)
@@ -585,17 +718,8 @@ EOF
        echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
        exit 0 ;;
     *:FreeBSD:*:*)
-       if test -x /usr/bin/objformat; then
-           if test "elf" = "`/usr/bin/objformat`"; then
-               echo ${UNAME_MACHINE}-unknown-freebsdelf`echo ${UNAME_RELEASE}|sed -e 's/[-_].*//'`
-               exit 0
-           fi
-       fi
        echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
        exit 0 ;;
-    *:NetBSD:*:*)
-       echo ${UNAME_MACHINE}-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*//'`
-       exit 0 ;;
     *:OpenBSD:*:*)
        echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
        exit 0 ;;
@@ -605,6 +729,9 @@ EOF
     i*:MINGW*:*)
        echo ${UNAME_MACHINE}-pc-mingw32
        exit 0 ;;
+    i*:PW*:*)
+       echo ${UNAME_MACHINE}-pc-pw32
+       exit 0 ;;
     i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
        # How do we know it's Interix rather than the generic POSIX subsystem?
        # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
@@ -623,54 +750,41 @@ EOF
     *:GNU:*:*)
        echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
        exit 0 ;;
-    *:Linux:*:*)
-
-       # The BFD linker knows what the default object file format is, so
-       # first see if it will tell us. cd to the root directory to prevent
-       # problems with other programs or directories called `ld' in the path.
-       ld_help_string=`cd /; ld --help 2>&1`
-       ld_supported_emulations=`echo $ld_help_string \
-                        | sed -ne '/supported emulations:/!d
-                                   s/[         ][      ]*/ /g
-                                   s/.*supported emulations: *//
-                                   s/ .*//
-                                   p'`
-        case "$ld_supported_emulations" in
-         *ia64)
-               echo "${UNAME_MACHINE}-unknown-linux"
-               exit 0
-               ;;
-         i?86linux)
-               echo "${UNAME_MACHINE}-pc-linux-gnuaout"
-               exit 0
-               ;;
-         i?86coff)
-               echo "${UNAME_MACHINE}-pc-linux-gnucoff"
-               exit 0
-               ;;
-         sparclinux)
-               echo "${UNAME_MACHINE}-unknown-linux-gnuaout"
-               exit 0
-               ;;
-         armlinux)
-               echo "${UNAME_MACHINE}-unknown-linux-gnuaout"
-               exit 0
-               ;;
-         elf32arm*)
-               echo "${UNAME_MACHINE}-unknown-linux-gnu"
-               exit 0
-               ;;
-         armelf_linux*)
-               echo "${UNAME_MACHINE}-unknown-linux-gnu"
-               exit 0
-               ;;
-         m68klinux)
-               echo "${UNAME_MACHINE}-unknown-linux-gnuaout"
-               exit 0
-               ;;
-         elf32ppc)
-               # Determine Lib Version
-               cat >$dummy.c <<EOF
+    i*86:Minix:*:*)
+       echo ${UNAME_MACHINE}-pc-minix
+       exit 0 ;;
+    arm*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit 0 ;;
+    ia64:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux
+       exit 0 ;;
+    m68*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit 0 ;;
+    mips:Linux:*:*)
+       cat >$dummy.c <<EOF
+#ifdef __cplusplus
+#include <stdio.h>  /* for printf() prototype */
+int main (int argc, char *argv[]) {
+#else
+int main (argc, argv) int argc; char *argv[]; {
+#endif
+#ifdef __MIPSEB__
+  printf ("%s-unknown-linux-gnu\n", argv[1]);
+#endif
+#ifdef __MIPSEL__
+  printf ("%sel-unknown-linux-gnu\n", argv[1]);
+#endif
+  return 0;
+}
+EOF
+       $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm -f $dummy.c $dummy && exit 0
+       rm -f $dummy.c $dummy
+       ;;
+    ppc:Linux:*:*)
+       # Determine Lib Version
+       cat >$dummy.c <<EOF
 #include <features.h>
 #if defined(__GLIBC__)
 extern char __libc_version[];
@@ -683,112 +797,130 @@ main(argc, argv)
 #if defined(__GLIBC__)
   printf("%s %s\n", __libc_version, __libc_release);
 #else
-  printf("unkown\n");
+  printf("unknown\n");
 #endif
   return 0;
 }
 EOF
-               LIBC=""
-               $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null
-               if test "$?" = 0 ; then
-                       ./$dummy | grep 1\.99 > /dev/null
-                       if test "$?" = 0 ; then
-                               LIBC="libc1"
-                       fi
-               fi      
-               rm -f $dummy.c $dummy
-               echo powerpc-unknown-linux-gnu${LIBC}
-               exit 0
-               ;;
-       esac
-
-       if test "${UNAME_MACHINE}" = "alpha" ; then
-               sed 's/^        //'  <<EOF >$dummy.s
+       LIBC=""
+       $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null
+       if test "$?" = 0 ; then
+               ./$dummy | grep 1\.99 > /dev/null
+               if test "$?" = 0 ; then LIBC="libc1" ; fi
+       fi
+       rm -f $dummy.c $dummy
+       echo powerpc-unknown-linux-gnu${LIBC}
+       exit 0 ;;
+    alpha:Linux:*:*)
+       cat <<EOF >$dummy.s
+         .data
+         \$Lformat:
+               .byte 37,100,45,37,120,10,0     # "%d-%x\n"
+          .text
                .globl main
+               .align 4
                .ent main
-       main:
-               .frame \$30,0,\$26,0
-               .prologue 0
-               .long 0x47e03d80 # implver $0
-               lda \$2,259
-               .long 0x47e20c21 # amask $2,$1
-               srl \$1,8,\$2
-               sll \$2,2,\$2
-               sll \$0,3,\$0
-               addl \$1,\$0,\$0
-               addl \$2,\$0,\$0
-               ret \$31,(\$26),1
+           main:
+               .frame \$30,16,\$26,0
+               ldgp \$29,0(\$27)
+               .prologue 1
+               .long 0x47e03d80 # implver \$0
+               lda \$2,-1
+               .long 0x47e20c21 # amask \$2,\$1
+               lda \$16,\$Lformat
+               mov \$0,\$17
+               not \$1,\$18
+               jsr \$26,printf
+               ldgp \$29,0(\$26)
+               mov 0,\$16
+               jsr \$26,exit
                .end main
 EOF
-               LIBC=""
-               $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
+       LIBC=""
+       $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
+       if test "$?" = 0 ; then
+               case `./$dummy` in
+               0-0)    UNAME_MACHINE="alpha" ;;
+               1-0)    UNAME_MACHINE="alphaev5" ;;
+               1-1)    UNAME_MACHINE="alphaev56" ;;
+               1-101)  UNAME_MACHINE="alphapca56" ;;
+               2-303)  UNAME_MACHINE="alphaev6" ;;
+               2-307)  UNAME_MACHINE="alphaev67" ;;
+               esac
+               objdump --private-headers $dummy | \
+                 grep ld.so.1 > /dev/null
                if test "$?" = 0 ; then
-                       ./$dummy
-                       case "$?" in
-                       7)
-                               UNAME_MACHINE="alpha"
-                               ;;
-                       15)
-                               UNAME_MACHINE="alphaev5"
-                               ;;
-                       14)
-                               UNAME_MACHINE="alphaev56"
-                               ;;
-                       10)
-                               UNAME_MACHINE="alphapca56"
-                               ;;
-                       16)
-                               UNAME_MACHINE="alphaev6"
-                               ;;
-                       esac
-
-                       objdump --private-headers $dummy | \
-                         grep ld.so.1 > /dev/null
-                       if test "$?" = 0 ; then
-                               LIBC="libc1"
-                       fi
+                       LIBC="libc1"
                fi
-               rm -f $dummy.s $dummy
-               echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} ; exit 0
-       elif test "${UNAME_MACHINE}" = "mips" ; then
-         cat >$dummy.c <<EOF
-#ifdef __cplusplus
-       int main (int argc, char *argv[]) {
-#else
-       int main (argc, argv) int argc; char *argv[]; {
-#endif
-#ifdef __MIPSEB__
-  printf ("%s-unknown-linux-gnu\n", argv[1]);
-#endif
-#ifdef __MIPSEL__
-  printf ("%sel-unknown-linux-gnu\n", argv[1]);
-#endif
-  return 0;
-}
-EOF
-         $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm $dummy.c $dummy && exit 0
-         rm -f $dummy.c $dummy
-       else
-         # Either a pre-BFD a.out linker (linux-gnuoldld)
-         # or one that does not give us useful --help.
-         # GCC wants to distinguish between linux-gnuoldld and linux-gnuaout.
-         # If ld does not provide *any* "supported emulations:"
-         # that means it is gnuoldld.
-         echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations:"
-         test $? != 0 && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0
-
-         case "${UNAME_MACHINE}" in
-         i?86)
-           VENDOR=pc;
-           ;;
-         *)
-           VENDOR=unknown;
-           ;;
-         esac
-         # Determine whether the default compiler is a.out or elf
-         cat >$dummy.c <<EOF
+       fi
+       rm -f $dummy.s $dummy
+       echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
+       exit 0 ;;
+    parisc:Linux:*:* | hppa:Linux:*:*)
+       # Look for CPU level
+       case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
+         PA7*) echo hppa1.1-unknown-linux-gnu ;;
+         PA8*) echo hppa2.0-unknown-linux-gnu ;;
+         *)    echo hppa-unknown-linux-gnu ;;
+       esac
+       exit 0 ;;
+    parisc64:Linux:*:* | hppa64:Linux:*:*)
+       echo hppa64-unknown-linux-gnu
+       exit 0 ;;
+    s390:Linux:*:* | s390x:Linux:*:*)
+       echo ${UNAME_MACHINE}-ibm-linux
+       exit 0 ;;
+    sh*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit 0 ;;
+    sparc:Linux:*:* | sparc64:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit 0 ;;
+    x86_64:Linux:*:*)
+       echo x86_64-unknown-linux-gnu
+       exit 0 ;;
+    i*86:Linux:*:*)
+       # The BFD linker knows what the default object file format is, so
+       # first see if it will tell us. cd to the root directory to prevent
+       # problems with other programs or directories called `ld' in the path.
+       ld_supported_emulations=`cd /; ld --help 2>&1 \
+                        | sed -ne '/supported emulations:/!d
+                                   s/[         ][      ]*/ /g
+                                   s/.*supported emulations: *//
+                                   s/ .*//
+                                   p'`
+        case "$ld_supported_emulations" in
+         i*86linux)
+               echo "${UNAME_MACHINE}-pc-linux-gnuaout"
+               exit 0
+               ;;
+         elf_i*86)
+               TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
+               ;;
+         i*86coff)
+               echo "${UNAME_MACHINE}-pc-linux-gnucoff"
+               exit 0
+               ;;
+       esac
+       # Either a pre-BFD a.out linker (linux-gnuoldld)
+       # or one that does not give us useful --help.
+       # GCC wants to distinguish between linux-gnuoldld and linux-gnuaout.
+       # If ld does not provide *any* "supported emulations:"
+       # that means it is gnuoldld.
+       test -z "$ld_supported_emulations" && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0
+       case "${UNAME_MACHINE}" in
+       i*86)
+         VENDOR=pc;
+         ;;
+       *)
+         VENDOR=unknown;
+         ;;
+       esac
+       # Determine whether the default compiler is a.out or elf
+       cat >$dummy.c <<EOF
 #include <features.h>
 #ifdef __cplusplus
+#include <stdio.h>  /* for printf() prototype */
        int main (int argc, char *argv[]) {
 #else
        int main (argc, argv) int argc; char *argv[]; {
@@ -809,15 +941,16 @@ EOF
   return 0;
 }
 EOF
-         $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm $dummy.c $dummy && exit 0
-         rm -f $dummy.c $dummy
-       fi ;;
+       $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm -f $dummy.c $dummy && exit 0
+       rm -f $dummy.c $dummy
+       test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0
+       ;;
 # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.  earlier versions
 # are messed up and put the nodename in both sysname and nodename.
-    i?86:DYNIX/ptx:4*:*)
+    i*86:DYNIX/ptx:4*:*)
        echo i386-sequent-sysv4
        exit 0 ;;
-    i?86:UNIX_SV:4.2MP:2.*)
+    i*86:UNIX_SV:4.2MP:2.*)
         # Unixware is an offshoot of SVR4, but it has its own version
         # number series starting with 2...
         # I am not positive that other SVR4 systems won't match this,
@@ -825,7 +958,7 @@ EOF
         # Use sysv4.2uw... so that sysv4* matches it.
        echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
        exit 0 ;;
-    i?86:*:4.*:* | i?86:SYSTEM_V:4.*:*)
+    i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
        UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
        if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
                echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
@@ -833,7 +966,7 @@ EOF
                echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
        fi
        exit 0 ;;
-    i?86:*:5:7*)
+    i*86:*:5:7*)
         # Fixed at (any) Pentium or better
         UNAME_MACHINE=i586
         if [ ${UNAME_SYSTEM} = "UnixWare" ] ; then
@@ -842,7 +975,7 @@ EOF
            echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE}
        fi
        exit 0 ;;
-    i?86:*:3.2:*)
+    i*86:*:3.2:*)
        if test -f /usr/options/cb.name; then
                UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
                echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
@@ -860,7 +993,11 @@ EOF
                echo ${UNAME_MACHINE}-pc-sysv32
        fi
        exit 0 ;;
+    i*86:*DOS:*:*)
+       echo ${UNAME_MACHINE}-pc-msdosdjgpp
+       exit 0 ;;
     pc:*:*:*)
+       # Left here for compatibility:
         # uname -m prints for DJGPP always 'pc', but it prints nothing about
         # the processor, so we play safe by assuming i386.
        echo i386-pc-msdosdjgpp
@@ -884,7 +1021,7 @@ EOF
        exit 0 ;;
     M68*:*:R3V[567]*:*)
        test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
-    3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0)
+    3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0)
        OS_REL=''
        test -r /etc/.relid \
        && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
@@ -895,21 +1032,24 @@ EOF
     3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
         /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
           && echo i486-ncr-sysv4 && exit 0 ;;
-    m68*:LynxOS:2.*:*)
+    m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
        echo m68k-unknown-lynxos${UNAME_RELEASE}
        exit 0 ;;
     mc68030:UNIX_System_V:4.*:*)
        echo m68k-atari-sysv4
        exit 0 ;;
-    i?86:LynxOS:2.*:* | i?86:LynxOS:3.[01]*:*)
+    i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
        echo i386-unknown-lynxos${UNAME_RELEASE}
        exit 0 ;;
     TSUNAMI:LynxOS:2.*:*)
        echo sparc-unknown-lynxos${UNAME_RELEASE}
        exit 0 ;;
-    rs6000:LynxOS:2.*:* | PowerPC:LynxOS:2.*:*)
+    rs6000:LynxOS:2.*:*)
        echo rs6000-unknown-lynxos${UNAME_RELEASE}
        exit 0 ;;
+    PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
+       echo powerpc-unknown-lynxos${UNAME_RELEASE}
+       exit 0 ;;
     SM[BE]S:UNIX_SV:*:*)
        echo mips-dde-sysv${UNAME_RELEASE}
        exit 0 ;;
@@ -943,7 +1083,7 @@ EOF
     mc68*:A/UX:*:*)
        echo m68k-apple-aux${UNAME_RELEASE}
        exit 0 ;;
-    news*:NEWS-OS:*:6*)
+    news*:NEWS-OS:6*:*)
        echo mips-sony-newsos6
        exit 0 ;;
     R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
@@ -974,8 +1114,63 @@ EOF
     *:Rhapsody:*:*)
        echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
        exit 0 ;;
+    *:Darwin:*:*)
+       echo `uname -p`-apple-darwin${UNAME_RELEASE}
+       exit 0 ;;
+    *:procnto*:*:* | *:QNX:[0123456789]*:*)
+       if test "${UNAME_MACHINE}" = "x86pc"; then
+               UNAME_MACHINE=pc
+       fi
+       echo `uname -p`-${UNAME_MACHINE}-nto-qnx
+       exit 0 ;;
     *:QNX:*:4*)
-       echo i386-qnx-qnx${UNAME_VERSION}
+       echo i386-pc-qnx
+       exit 0 ;;
+    NSR-[KW]:NONSTOP_KERNEL:*:*)
+       echo nsr-tandem-nsk${UNAME_RELEASE}
+       exit 0 ;;
+    *:NonStop-UX:*:*)
+       echo mips-compaq-nonstopux
+       exit 0 ;;
+    BS2000:POSIX*:*:*)
+       echo bs2000-siemens-sysv
+       exit 0 ;;
+    DS/*:UNIX_System_V:*:*)
+       echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
+       exit 0 ;;
+    *:Plan9:*:*)
+       # "uname -m" is not consistent, so use $cputype instead. 386
+       # is converted to i386 for consistency with other x86
+       # operating systems.
+       if test "$cputype" = "386"; then
+           UNAME_MACHINE=i386
+       else
+           UNAME_MACHINE="$cputype"
+       fi
+       echo ${UNAME_MACHINE}-unknown-plan9
+       exit 0 ;;
+    i*86:OS/2:*:*)
+       # If we were able to find `uname', then EMX Unix compatibility
+       # is probably installed.
+       echo ${UNAME_MACHINE}-pc-os2-emx
+       exit 0 ;;
+    *:TOPS-10:*:*)
+       echo pdp10-unknown-tops10
+       exit 0 ;;
+    *:TENEX:*:*)
+       echo pdp10-unknown-tenex
+       exit 0 ;;
+    KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
+       echo pdp10-dec-tops20
+       exit 0 ;;
+    XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
+       echo pdp10-xkl-tops20
+       exit 0 ;;
+    *:TOPS-20:*:*)
+       echo pdp10-unknown-tops20
+       exit 0 ;;
+    *:ITS:*:*)
+       echo pdp10-unknown-its
        exit 0 ;;
 esac
 
@@ -1068,11 +1263,24 @@ main ()
 #endif
 
 #if defined (vax)
-#if !defined (ultrix)
-  printf ("vax-dec-bsd\n"); exit (0);
-#else
-  printf ("vax-dec-ultrix\n"); exit (0);
-#endif
+# if !defined (ultrix)
+#  include <sys/param.h>
+#  if defined (BSD)
+#   if BSD == 43
+      printf ("vax-dec-bsd4.3\n"); exit (0);
+#   else
+#    if BSD == 199006
+      printf ("vax-dec-bsd4.3reno\n"); exit (0);
+#    else
+      printf ("vax-dec-bsd\n"); exit (0);
+#    endif
+#   endif
+#  else
+    printf ("vax-dec-bsd\n"); exit (0);
+#  endif
+# else
+    printf ("vax-dec-ultrix\n"); exit (0);
+# endif
 #endif
 
 #if defined (alliant) && defined (i860)
@@ -1083,7 +1291,7 @@ main ()
 }
 EOF
 
-$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm $dummy.c $dummy && exit 0
+$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm -f $dummy.c $dummy && exit 0
 rm -f $dummy.c $dummy
 
 # Apollos put the system type in the environment.
@@ -1116,6 +1324,48 @@ then
     esac
 fi
 
-#echo '(Unable to guess system type)' 1>&2
+cat >&2 <<EOF
+$0: unable to guess system type
+
+This script, last modified $timestamp, has failed to recognize
+the operating system you are using. It is advised that you
+download the most up to date version of the config scripts from
+
+    ftp://ftp.gnu.org/pub/gnu/config/
+
+If the version you run ($0) is already up to date, please
+send the following data and any information you think might be
+pertinent to <config-patches@gnu.org> in order to provide the needed
+information to handle your system.
+
+config.guess timestamp = $timestamp
+
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
+/bin/uname -X     = `(/bin/uname -X) 2>/dev/null`
+
+hostinfo               = `(hostinfo) 2>/dev/null`
+/bin/universe          = `(/bin/universe) 2>/dev/null`
+/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null`
+/bin/arch              = `(/bin/arch) 2>/dev/null`
+/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
+
+UNAME_MACHINE = ${UNAME_MACHINE}
+UNAME_RELEASE = ${UNAME_RELEASE}
+UNAME_SYSTEM  = ${UNAME_SYSTEM}
+UNAME_VERSION = ${UNAME_VERSION}
+EOF
 
 exit 1
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
index 12ebc7875a338e7bd8966295ac129848d96f8dce..a06a480adafdfbe81925988759b3e29088d6d2e0 100755 (executable)
@@ -3,7 +3,7 @@
 #   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
 #   Free Software Foundation, Inc.
 
-timestamp='2001-08-13'
+timestamp='2001-04-20'
 
 # This file is (in principle) common to ALL GNU software.
 # The presence of a machine in this file suggests that SOME GNU software
@@ -117,7 +117,7 @@ esac
 # Here we must recognize all the valid KERNEL-OS combinations.
 maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
 case $maybe_os in
-  nto-qnx* | linux-gnu* | storm-chaos* | os2-emx* | windows32-*)
+  nto-qnx* | linux-gnu* | storm-chaos* | os2-emx*)
     os=-$maybe_os
     basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
     ;;
@@ -157,14 +157,6 @@ case $os in
                os=-vxworks
                basic_machine=$1
                ;;
-       -chorusos*)
-               os=-chorusos
-               basic_machine=$1
-               ;;
-       -chorusrdb)
-               os=-chorusrdb
-               basic_machine=$1
-               ;;
        -hiux*)
                os=-hiuxwe2
                ;;
@@ -223,35 +215,26 @@ esac
 case $basic_machine in
        # Recognize the basic CPU types without company name.
        # Some are omitted here because they have special meanings below.
-       1750a | 580 \
-       | a29k \
-       | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
-       | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \
-       | c4x | clipper \
-       | d10v | d30v | dsp16xx \
-       | fr30 \
-       | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
-       | i370 | i860 | i960 | ia64 \
-       | m32r | m68000 | m68k | m88k | mcore \
-       | mips16 | mips64 | mips64el | mips64orion | mips64orionel \
-       | mips64vr4100 | mips64vr4100el | mips64vr4300 \
-       | mips64vr4300el | mips64vr5000 | mips64vr5000el \
-       | mipsbe | mipsel | mipsle | mipstx39 | mipstx39el \
-       | mn10200 | mn10300 \
-       | ns16k | ns32k \
-       | openrisc \
-       | pdp10 | pdp11 | pj | pjl \
-       | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
-       | pyramid \
-       | s390 | s390x \
-       | sh | sh[34] | sh[34]eb | shbe | shle \
-       | sparc | sparc64 | sparclet | sparclite | sparcv9 | sparcv9b \
-       | strongarm \
-       | tahoe | thumb | tic80 | tron \
-       | v850 \
-       | we32k \
-       | x86 | xscale \
-       | z8k)
+       tahoe | i860 | ia64 | m32r | m68k | m68000 | m88k | ns32k | arc \
+               | arm | arme[lb] | arm[bl]e | armv[2345] | armv[345][lb] | strongarm | xscale \
+               | pyramid | mn10200 | mn10300 | tron | a29k \
+               | 580 | i960 | h8300 \
+               | x86 | ppcbe | mipsbe | mipsle | shbe | shle \
+               | hppa | hppa1.0 | hppa1.1 | hppa2.0 | hppa2.0w | hppa2.0n \
+               | hppa64 \
+               | alpha | alphaev[4-8] | alphaev56 | alphapca5[67] \
+               | alphaev6[78] \
+               | we32k | ns16k | clipper | i370 | sh | sh[34] \
+               | powerpc | powerpcle \
+               | 1750a | dsp16xx | pdp10 | pdp11 \
+               | mips16 | mips64 | mipsel | mips64el \
+               | mips64orion | mips64orionel | mipstx39 | mipstx39el \
+               | mips64vr4300 | mips64vr4300el | mips64vr4100 | mips64vr4100el \
+               | mips64vr5000 | miprs64vr5000el | mcore | s390 | s390x \
+               | sparc | sparclet | sparclite | sparc64 | sparcv9 | sparcv9b \
+               | v850 | c4x \
+               | thumb | d10v | d30v | fr30 | avr | openrisc | tic80 \
+               | pj | pjl | h8500)
                basic_machine=$basic_machine-unknown
                ;;
        m6811 | m68hc11 | m6812 | m68hc12)
@@ -259,7 +242,7 @@ case $basic_machine in
                basic_machine=$basic_machine-unknown
                os=-none
                ;;
-       m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
+       m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | z8k | v70 | w65)
                ;;
 
        # We use `pc' rather than `unknown'
@@ -274,43 +257,31 @@ case $basic_machine in
                exit 1
                ;;
        # Recognize the basic CPU types with company name.
-       580-* \
-       | a29k-* \
-       | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
-       | alphapca5[67]-* | arc-* \
-       | arm-*  | armbe-* | armle-* | armv*-* \
-       | bs2000-* \
-       | c[123]* | c30-* | [cjt]90-* | c54x-* \
-       | clipper-* | cray2-* | cydra-* \
-       | d10v-* | d30v-* \
-       | elxsi-* \
-       | f30[01]-* | f700-* | fr30-* | fx80-* \
-       | h8300-* | h8500-* \
-       | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
-       | i*86-* | i860-* | i960-* | ia64-* \
-       | m32r-* \
-       | m68000-* | m680[01234]0-* | m68360-* | m683?2-* | m68k-* \
-       | m88110-* | m88k-* | mcore-* \
-       | mips-* | mips16-* | mips64-* | mips64el-* | mips64orion-* \
-       | mips64orionel-* | mips64vr4100-* | mips64vr4100el-* \
-       | mips64vr4300-* | mips64vr4300el-* | mipsbe-* | mipsel-* \
-       | mipsle-* | mipstx39-* | mipstx39el-* \
-       | none-* | np1-* | ns16k-* | ns32k-* \
-       | orion-* \
-       | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
-       | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
-       | pyramid-* \
-       | romp-* | rs6000-* \
-       | s390-* | s390x-* \
-       | sh-* | sh[34]-* | sh[34]eb-* | shbe-* | shle-* \
-       | sparc-* | sparc64-* | sparc86x-* | sparclite-* \
-       | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* \
-       | t3e-* | tahoe-* | thumb-* | tic30-* | tic54x-* | tic80-* | tron-* \
-       | v850-* | vax-* \
-       | we32k-* \
-       | x86-* | x86_64-* | xmp-* | xps100-* | xscale-* \
-       | ymp-* \
-       | z8k-*)
+       # FIXME: clean up the formatting here.
+       vax-* | tahoe-* | i*86-* | i860-* | ia64-* | m32r-* | m68k-* | m68000-* \
+             | m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | c[123]* \
+             | arm-*  | armbe-* | armle-* | armv*-* | strongarm-* | xscale-* \
+             | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \
+             | power-* | none-* | 580-* | cray2-* | h8300-* | h8500-* | i960-* \
+             | xmp-* | ymp-* \
+             | x86-* | ppcbe-* | mipsbe-* | mipsle-* | shbe-* | shle-* \
+             | hppa-* | hppa1.0-* | hppa1.1-* | hppa2.0-* | hppa2.0w-* \
+             | hppa2.0n-* | hppa64-* \
+             | alpha-* | alphaev[4-8]-* | alphaev56-* | alphapca5[67]-* \
+             | alphaev6[78]-* \
+             | we32k-* | cydra-* | ns16k-* | pn-* | np1-* | xps100-* \
+             | clipper-* | orion-* \
+             | sparclite-* | pdp10-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \
+             | sparc64-* | sparcv9-* | sparcv9b-* | sparc86x-* \
+             | mips16-* | mips64-* | mipsel-* \
+             | mips64el-* | mips64orion-* | mips64orionel-* \
+             | mips64vr4100-* | mips64vr4100el-* | mips64vr4300-* | mips64vr4300el-* \
+             | mipstx39-* | mipstx39el-* | mcore-* \
+             | f30[01]-* | f700-* | s390-* | s390x-* | sv1-* | t3e-* \
+             | [cjt]90-* \
+             | m88110-* | m680[01234]0-* | m683?2-* | m68360-* | z8k-* | d10v-* \
+             | thumb-* | v850-* | d30v-* | tic30-* | tic80-* | c30-* | fr30-* \
+             | bs2000-* | tic54x-* | c54x-* | x86_64-* | pj-* | pjl-*)
                ;;
        # Recognize the various machine names and aliases which stand
        # for a CPU type and a company and sometimes even an OS.
@@ -756,16 +727,6 @@ case $basic_machine in
        ppcle-* | powerpclittle-*)
                basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
                ;;
-       ppc64)  basic_machine=powerpc64-unknown
-               ;;
-       ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
-               ;;
-       ppc64le | powerpc64little | ppc64-le | powerpc64-little)
-               basic_machine=powerpc64le-unknown
-               ;;
-       ppc64le-* | powerpc64little-*)
-               basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
-               ;;
        ps2)
                basic_machine=i386-ibm
                ;;
@@ -920,10 +881,6 @@ case $basic_machine in
                basic_machine=hppa1.1-winbond
                os=-proelf
                ;;
-       windows32)
-               basic_machine=i386-pc
-               os=-windows32-msvcrt
-               ;;
        xmp)
                basic_machine=xmp-cray
                os=-unicos
@@ -977,7 +934,7 @@ case $basic_machine in
        we32k)
                basic_machine=we32k-att
                ;;
-       sh3 | sh4 | sh3eb | sh4eb)
+       sh3 | sh4)
                basic_machine=sh-unknown
                ;;
        sparc | sparcv9 | sparcv9b)
@@ -1061,13 +1018,11 @@ case $os in
              | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
              | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
              | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
-             | -chorusos* | -chorusrdb* \
              | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
              | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \
              | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \
              | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
-             | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
-             | -os2* | -vos*)
+             | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* | -os2*)
        # Remember, each alternative MUST END IN *, to match a version number.
                ;;
        -qnx*)
@@ -1391,9 +1346,6 @@ case $basic_machine in
                        -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
                                vendor=atari
                                ;;
-                       -vos*)
-                               vendor=stratus
-                               ;;
                esac
                basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
                ;;
index 504b53ce0850316dbedb0644a1a71969c06185f4..778714a448e31af8a5bdaa55b2e2c153ce76529c 100644 (file)
@@ -24,21 +24,19 @@ DIST_SUBDIRS = SILC_DISTRIBUTION_SUBDIRS
 makerfc = ../scripts/makerfc
 
 all:
-       touch draft-riikonen-silc-spec-05.txt
-       touch draft-riikonen-silc-pp-05.txt
-       touch draft-riikonen-silc-ke-auth-05.txt
-       touch draft-riikonen-silc-commands-03.txt
-       touch draft-riikonen-silc-flags-payloads-00.txt
+       touch draft-riikonen-silc-spec-04.txt
+       touch draft-riikonen-silc-pp-04.txt
+       touch draft-riikonen-silc-ke-auth-04.txt
+       touch draft-riikonen-silc-commands-02.txt
        -cd ..
 
 if SILC_DIST_CLIENT
 dist-hook:
        rm draft-riikonen*.txt
-       touch draft-riikonen-silc-spec-05.txt
-       touch draft-riikonen-silc-pp-05.txt
-       touch draft-riikonen-silc-ke-auth-05.txt
-       touch draft-riikonen-silc-commands-03.txt
-       touch draft-riikonen-silc-flags-payloads-00.txt
+       touch draft-riikonen-silc-spec-04.txt
+       touch draft-riikonen-silc-pp-04.txt
+       touch draft-riikonen-silc-ke-auth-04.txt
+       touch draft-riikonen-silc-commands-02.txt
 else
 if SILC_DIST_TOOLKIT
 dist-hook:
@@ -50,38 +48,32 @@ dist-hook:
        else  \
          echo ROBODoc is not compiled! Cannot generate documentation! ; \
         fi
-       touch draft-riikonen-silc-spec-05.txt
-       touch draft-riikonen-silc-pp-05.txt
-       touch draft-riikonen-silc-ke-auth-05.txt
-       touch draft-riikonen-silc-commands-03.txt
-       touch draft-riikonen-silc-flags-payloads-00.txt
-       $(makerfc) draft-riikonen-silc-spec-05.nroff \
-               draft-riikonen-silc-spec-05.txt
-       $(makerfc) draft-riikonen-silc-pp-05.nroff \
-               draft-riikonen-silc-pp-05.txt
-       $(makerfc) draft-riikonen-silc-ke-auth-05.nroff \
-               draft-riikonen-silc-ke-auth-05.txt
-       $(makerfc) draft-riikonen-silc-commands-03.nroff \
-               draft-riikonen-silc-commands-03.txt
-       $(makerfc) draft-riikonen-silc-flags-payloads-00.nroff \
-               draft-riikonen-silc-flags-payloads-00.txt
+       touch draft-riikonen-silc-spec-04.txt
+       touch draft-riikonen-silc-pp-04.txt
+       touch draft-riikonen-silc-ke-auth-04.txt
+       touch draft-riikonen-silc-commands-02.txt
+       $(makerfc) draft-riikonen-silc-spec-04.nroff \
+               draft-riikonen-silc-spec-04.txt
+       $(makerfc) draft-riikonen-silc-pp-04.nroff \
+               draft-riikonen-silc-pp-04.txt
+       $(makerfc) draft-riikonen-silc-ke-auth-04.nroff \
+               draft-riikonen-silc-ke-auth-04.txt
+       $(makerfc) draft-riikonen-silc-commands-02.nroff \
+               draft-riikonen-silc-commands-02.txt
 else
 dist-hook:
-       touch draft-riikonen-silc-spec-05.txt
-       touch draft-riikonen-silc-pp-05.txt
-       touch draft-riikonen-silc-ke-auth-05.txt
-       touch draft-riikonen-silc-commands-03.txt
-       touch draft-riikonen-silc-flags-payloads-00.txt
-       $(makerfc) draft-riikonen-silc-spec-05.nroff \
-               draft-riikonen-silc-spec-05.txt
-       $(makerfc) draft-riikonen-silc-pp-05.nroff \
-               draft-riikonen-silc-pp-05.txt
-       $(makerfc) draft-riikonen-silc-ke-auth-05.nroff \
-               draft-riikonen-silc-ke-auth-05.txt
-       $(makerfc) draft-riikonen-silc-commands-03.nroff \
-               draft-riikonen-silc-commands-03.txt
-       $(makerfc) draft-riikonen-silc-flags-payloads-00.nroff \
-               draft-riikonen-silc-flags-payloads-00.txt
+       touch draft-riikonen-silc-spec-04.txt
+       touch draft-riikonen-silc-pp-04.txt
+       touch draft-riikonen-silc-ke-auth-04.txt
+       touch draft-riikonen-silc-commands-02.txt
+       $(makerfc) draft-riikonen-silc-spec-04.nroff \
+               draft-riikonen-silc-spec-04.txt
+       $(makerfc) draft-riikonen-silc-pp-04.nroff \
+               draft-riikonen-silc-pp-04.txt
+       $(makerfc) draft-riikonen-silc-ke-auth-04.nroff \
+               draft-riikonen-silc-ke-auth-04.txt
+       $(makerfc) draft-riikonen-silc-commands-02.nroff \
+               draft-riikonen-silc-commands-02.txt
 endif
 endif
 
index 5f76f8e4de4aff4fb75e90e9d853ce8d42163f26..20c7d47fee75ff85f23c5a630e9c59e26246d7a4 100644 (file)
@@ -202,9 +202,7 @@ are defined in the section 2.3 SILC Command Status Types.
 Every command that has some kind of ID as argument (for example
 <Client ID>) are actually ID Payloads, defined in [SILC2] that includes
 the type of the ID, length of the ID and the actual ID data.  This
-way variable length ID's can be sent as arguments.  Also note that
-all passphrases that may be sent in commands MUST be UTF-8 [RFC2279]
-encoded.
+way variable length ID's can be sent as arguments.
 
 
 .ti 0
@@ -226,7 +224,7 @@ List of all defined commands in SILC follows.
 
    1    SILC_COMMAND_WHOIS
 
-        Max Arguments:  256
+        Max Arguments:  3328
             Arguments:  (1) [<nickname>[@<server>]]  (2) [<count>]
                         (3) [<Client ID>]            (n) [...]
 
@@ -261,14 +259,13 @@ List of all defined commands in SILC follows.
 
         Reply messages to the command:
 
-        Max Arguments:  10
+        Max Arguments:  9
             Arguments:  (1) <Status Payload>       (2) <Client ID> 
                         (3) <nickname>[@<server>]  (4) <username@host> 
                         (5) <real name>            (6) [<Channel Payload 
                                                          list>] 
                         (7) [<user mode>]          (8) [<idle time>]
-                        (9) [<fingerprint>]        (10) <channel user
-                                                         mode list>
+                        (9) [<fingerprint>]
 
 
         This command may reply with several command reply messages to
@@ -285,19 +282,13 @@ List of all defined commands in SILC follows.
         <count> option were defined in the query there will be only
         <count> many replies from the server.
 
-        The server returns the list of channels if the client has
-        joined channels.  In this case the list is list of Channel
-        Payloads.  The Mode Mask in the Channel Payload is the channel's
-        mode.  The list is encoded by adding the Channel Payloads one
-        after the other.  Private and secret channels MUST NOT be sent,
-        except if the sender of this command is on those channels, or
-        the sender is server.  The <channel user mode list> MUST also
-        be sent if client is joined channels.  This list includes 32 bit
-        MSB first order values one after the other and each indicate
-        the user's mode on a channel.  The order of these values MUST
-        be same as the channel order in the <Channel Payload list>.
-
-        The server also returns client's user mode, idle time, and the
+        The server may return the list of channel the client has joined.
+        In this case the list is list of Channel Payloads.  The Mode Mask
+        in the Channel Payload (see [SILC2] and section 2.3.2.3 for the
+        Channel Payload) is the client's mode on the channel.  The list
+        is encoded by adding the Channel Payloads one after the other.
+
+        The server may also send client's user mode, idle time, and the
         fingerprint of the client's public key.  The <fingerprint> is the
         binary hash digest of the public key.  The fingerprint MUST NOT
         be sent if the server has not verified the proof of posession of
@@ -368,7 +359,7 @@ List of all defined commands in SILC follows.
 
    3    SILC_COMMAND_IDENTIFY
 
-        Max Arguments:  256
+        Max Arguments:  3328
             Arguments:  (1) [<nickname>[@<server>]]  (2) [<server name>]
                         (3) [<channel name>]         (4) [<count>]
                         (5) [<ID Payload>]           (n) [...]
@@ -612,7 +603,8 @@ List of all defined commands in SILC follows.
                         (3) [<invite list>]
 
        This command replies with the invite list of the channel if it
-       exists.
+       exists.  The <invite list> may be omitted if the list was not
+        altered.
 
         Status messages:
 
@@ -716,59 +708,34 @@ List of all defined commands in SILC follows.
             SILC_STATUS_ERR_NO_SERVER_ID
 
 
-   11   SILC_COMMAND_STATS
+   11   SILC_COMMAND_CONNECT
 
-        Max Arguments:  1
-            Arguments:  (1) <Server ID>
+        Max Arguments:  2
+            Arguments:  (1) <remote server/router>  (2) [<port>]
 
-        This command is used to fetch various statistical information
-        from the server indicated by <Server ID>, which is the ID of
-        server where sender is connected to.  Server receiving this
-        command MAY also send this further to its router for fetching
-        other cell and network wide statistics to accompany the reply.
+        This command is used by operators to force a server to try to
+        establish a new connection to remote server or router.  The
+        Operator MUST specify the server/router to be connected by
+        setting <remote server> argument.  The port is 32 bit MSB value.
 
         Reply messages to the command:
 
-        Max Arguments:  3
-            Arguments:  (1) <Status Payload>          (2) <Server ID>
-                        (3) [<statistics structure>]
-
-        This command replies with the Server ID of the server and 
-        optional statistics structure which includes 32 bit MSB first
-        ordered integer values to represent various statistical
-        information.  The structure is as follows:
-
-          starttime      - time when server was started
-          uptime         - uptime of the server
-          my clients     - number of locally connected clients
-          my channels    - number of locally created channels
-          my server ops  - number of local server operators
-          my router ops  - number of local router operators
-          cell clients   - number of clients in local cell
-          cell channels  - number of channels in local cell
-          cell servers   - number of servers in local cell
-          clients        - number of client in SILC network
-          channels       - number of channels in SILC network
-          servers        - number of servers in SILC network
-          routers        - number of routers in SILC network
-          server ops     - number of server operators in SILC network
-          router ops     - number of router operators in SILC network
-
-        If some value is unknown it is set to zero (0) value.  The
-        "starttime" is the start time of the server, and is seconds
-        since Epoch (POSIX.1).  The "uptime" is time difference of
-        current time and "starttime" in the server, and is seconds
-        in value.
+        Max Arguments:  1
+            Arguments:  (1) <Status Payload>
+
+        This command replies only with Status Payload.
+
+
 
         Status messages:
 
             SILC_STATUS_OK
+            SILC_STATUS_ERR_WILDCARDS
             SILC_STATUS_ERR_NOT_REGISTERED
             SILC_STATUS_ERR_NOT_ENOUGH_PARAMS
             SILC_STATUS_ERR_TOO_MANY_PARAMS
-            SILC_STATUS_ERR_NO_SUCH_SERVER_ID
-            SILC_STATUS_ERR_NO_SUCH_SERVER
-            SILC_STATUS_ERR_NO_SERVER_ID
+            SILC_STATUS_ERR_NO_SERVER_PRIV
+            SILC_STATUS_ERR_NO_ROUTER_PRIV
 
 
    12   SILC_COMMAND_PING
@@ -972,7 +939,7 @@ List of all defined commands in SILC follows.
    16   SILC_COMMAND_UMODE
 
         Max Arguments:  2
-            Arguments:  (1) <Client ID>  (2) [<client mode mask>]
+            Arguments:  (1) <Client ID>  (2) <client mode mask>
 
         This command is used by client to set/unset modes for itself.
         However, there are some modes that the client MUST NOT set itself,
@@ -987,14 +954,14 @@ List of all defined commands in SILC follows.
 
         The following client modes are defined:
 
-           0x00000000    SILC_UMODE_NONE
+           0x0000    SILC_UMODE_NONE
 
               No specific mode for client.  This is the initial
               setting when new client is created.  The client is
-              normal client and is present in the network.
+              normal client now.
 
 
-           0x00000001    SILC_UMODE_SERVER_OPERATOR
+           0x0001    SILC_UMODE_SERVER_OPERATOR
 
               Marks the user as server operator.  Client MUST NOT
               set this mode itself.  Server sets this mode to the
@@ -1003,108 +970,20 @@ List of all defined commands in SILC follows.
               MAY unset the mode itself.
 
 
-           0x00000002    SILC_UMODE_ROUTER_OPERATOR
+           0x0002    SILC_UMODE_ROUTER_OPERATOR
 
               Marks the user as router (SILC) operator.  Client
-              MUST NOT set this mode itself.  Router sets this mode
-              to the client when client attains the router operator
+              MUST NOT this mode itself.  Router sets this mode to
+              the client when client attains the router operator
               privileges by SILC_COMMAND_SILCOPER command.  Client
               MAY unset the mode itself.
 
 
-           0x00000004    SILC_UMODE_GONE
+           0x0004    SILC_UMODE_GONE
 
               Marks that the user is not currently present in the
               SILC Network.  Client MAY set and unset this mode.
 
-
-           0x00000008    SILC_UMODE_INDISPOSED
-
-              Marks that the user is currently indisposed and may
-              not be able to receive any messages, and that user may
-              not be present in the network.  Client MAY set and
-              unset this mode.
-
-
-           0x00000010    SILC_UMODE_BUSY
-
-              Marks that the user is currently busy and may not
-              want to receive any messages, and that user may not
-              be present in the network.  Client MAY set and unset
-              this mode.
-
-
-           0x00000020    SILC_UMODE_PAGE
-
-              User is not currently present or is unable to receive
-              messages, and prefers to be paged in some mechanism
-              if the user needs to be reached.  Client MAY set and
-              unset this mode.
-
-
-           0x00000040    SILC_UMODE_HYPER
-
-              Marks that the user is hyper active and is eager to
-              receive and send messages.   Client MAY set and unset
-              this mode.
-
-
-           0x00000080    SILC_UMODE_ROBOT
-
-              Marks that the client is actually a robot program.
-              Client MAY set and unset this mode.
-
-
-           0x00000100    SILC_UMODE_ANONYMOUS
-
-              Marks that the client is anonymous client.  Server
-              that specificly is designed for anonymous services
-              can set and unset this mode.  Client MUST NOT set or
-              unset this mode itself.  A client with this mode set
-              would have the username and the hostname information
-              scrambled by the server which set this mode.
-
-
-           0x00000200    SILC_UMODE_BLOCK_PRIVMSG
-
-              Marks that the client wishes to block private
-              messages sent to the client, unless the Private
-              Message Key flag is set in the SILC packet header.
-              If this mode is set server MUST NOT deliver private
-              messages to the client without the Private Message
-              Key flag being set.
-
-              A separate service could provide additional filtering
-              features for accepting private messages from certain
-              sender.  However, this document does not specify such
-              service.
-
-              The client MAY set and unset this mode.
-
-
-           0x00000400    SILC_UMODE_DETACHED
-
-              Marks that the client is detached from the SILC network.
-              This means that the actual network connection to the
-              client is lost but the client entry is still valid.  The
-              detached client can be resumed at a later time.  This
-              mode MUST NOT be set by client.  It can only be set when
-              client has issued command SILC_COMMAND_DETACH.  The server
-              sets this mode.  This mode cannot be unset with this
-              command.  It is unset when the client is resuming back to
-              the network and SILC_PACKET_RESUME_CLIENT packet is
-              received.
-
-              This flag MUST NOT be used to determine whether a packet
-              can be sent to the client or not.  Only the server that
-              had the original client connection can make the decision
-              by noticising that the network connection is not active.
-              In this case the default case is to discard the packet.
-
-        If the <client mode mask> was not provided this command merely
-        returns the mode mask to the client.
-
-
         Reply messages to the command:
 
         Max Arguments:  2
@@ -1131,7 +1010,7 @@ List of all defined commands in SILC follows.
    17   SILC_COMMAND_CMODE
 
         Max Arguments:  7
-            Arguments:  (1) <Channel ID>      (2) [<channel mode mask>]
+            Arguments:  (1) <Channel ID>      (2) <channel mode mask>
                         (3) [<user limit>]    (4) [<passphrase>]
                         (5) [<cipher>]        (6) [<hmac>]
                         (7) [<auth payload>]
@@ -1149,14 +1028,14 @@ List of all defined commands in SILC follows.
 
         The following channel modes are defined:
 
-           0x00000000    SILC_CMODE_NONE
+           0x0000    SILC_CMODE_NONE
 
               No specific mode on channel.  This is the default when
               channel is created.  This means that channel is just plain
               normal channel.
 
 
-           0x00000001    SILC_CMODE_PRIVATE
+           0x0001    SILC_CMODE_PRIVATE
 
               Channel is private channel.  Private channels are shown
               in the channel list listed with SILC_COMMAND_LIST command
@@ -1170,7 +1049,7 @@ List of all defined commands in SILC follows.
               to set/unset this mode.
 
 
-           0x00000002    SILC_CMODE_SECRET
+           0x0002    SILC_CMODE_SECRET
 
               Channel is secret channel.  Secret channels are not shown
               in the list listed with SILC_COMMAND_LIST command.  Secret
@@ -1182,7 +1061,7 @@ List of all defined commands in SILC follows.
               to set/unset this mode.
 
 
-           0x00000004    SILC_CMODE_PRIVKEY
+           0x0004    SILC_CMODE_PRIVKEY
 
               Channel uses private channel key to protect the traffic
               on the channel.  When this mode is set the client will be
@@ -1214,7 +1093,7 @@ List of all defined commands in SILC follows.
               to set/unset this mode.
 
 
-           0x00000008    SILC_CMODE_INVITE
+           0x0008    SILC_CMODE_INVITE
 
               Channel is invite only channel.  Client may join to this
               channel only if it is invited to the channel.  Channel
@@ -1224,7 +1103,7 @@ List of all defined commands in SILC follows.
               to set/unset this mode.
 
 
-           0x00000010    SILC_CMODE_TOPIC
+           0x0010    SILC_CMODE_TOPIC
 
               The topic of the channel may only be set by client that
               is channel founder or channel operator.  Normal clients
@@ -1236,7 +1115,7 @@ List of all defined commands in SILC follows.
               to set/unset this mode.
 
 
-           0x00000020    SILC_CMODE_ULIMIT
+           0x0020    SILC_CMODE_ULIMIT
 
               User limit has been set to the channel.  New clients
               may not join to the channel when the limit set is
@@ -1248,7 +1127,7 @@ List of all defined commands in SILC follows.
               to set/unset this mode.
 
 
-           0x00000040    SILC_CMODE_PASSPHRASE
+           0x0040    SILC_CMODE_PASSPHRASE
 
               Passphrase has been set to the channel.  Client may
               join to the channel only if it is able to provide the
@@ -1262,7 +1141,7 @@ List of all defined commands in SILC follows.
               to set/unset this mode.
 
 
-           0x00000080    SILC_CMODE_CIPHER
+           0x0080    SILC_CMODE_CIPHER
 
               Sets specific cipher to be used to protect channel
               traffic.  The <cipher> argument is the requested cipher.
@@ -1275,7 +1154,7 @@ List of all defined commands in SILC follows.
               to set/unset this mode.
 
 
-           0x00000100    SILC_CMODE_HMAC
+           0x0100    SILC_CMODE_HMAC
 
               Sets specific hmac to be used to compute the MACs of the
               channel message.  The <hmac> argument is the requested hmac.
@@ -1285,7 +1164,7 @@ List of all defined commands in SILC follows.
               to set/unset this mode.
 
 
-           0x00000200    SILC_CMODE_FOUNDER_AUTH
+           0x0200    SILC_CMODE_FOUNDER_AUTH
 
               Channel founder may set this mode to be able to regain
               channel founder rights even if the client leaves the 
@@ -1313,27 +1192,6 @@ List of all defined commands in SILC follows.
               Typical implementation would use [+|-]f on user interface
               to set/unset this mode.
 
-
-           0x00000400    SILC_CMODE_SILENCE_USERS
-
-              Channel founder may set this mode to silence normal users
-              on the channel.  Users with operator privileges are not
-              affected by this mode.  Messages sent by normal users
-              are dropped by servers when this mode is set.  This mode
-              can be used to moderate the channel.  Only channel founder
-              may set/unset this mode.
-
-
-           0x00000800    SILC_CMODE_SILENCE_OPERS
-
-              Channel founder may set this mode to silence operators
-              on the channel.  When used with SILC_CMODE_SILENCE_USERS
-              mode this can be used to set the channel in state where only
-              the founder of the channel may send messages to the channel.
-              Messages sent by operators are dropped by servers when this
-              mode is set.  Only channel founder may set/unset this mode.
-
-
         To make the mode system work, client MUST keep the channel mode
         mask locally so that the mode setting and unsetting would work
         without problems.  The client receives the initial channel mode
@@ -1341,9 +1199,7 @@ List of all defined commands in SILC follows.
         channel the server MUST distribute the changed channel mode mask
         to all clients on the channel by sending the notify type
         SILC_NOTIFY_TYPE_CMODE_CHANGE.  The notify type MUST also be sent
-        to the server's primary router.  If the <channel mode mask> was
-        not provided this command merely returns the mode mask to the
-        client.
+        to the server's primary router.
 
         Reply messages to the command:
 
@@ -1365,7 +1221,6 @@ List of all defined commands in SILC follows.
             SILC_STATUS_ERR_BAD_CHANNEL_ID
             SILC_STATUS_ERR_NO_CHANNEL_ID
             SILC_STATUS_ERR_NO_CHANNEL_PRIV
-            SILC_STATUS_ERR_NO_CHANNEL_FOPRIV
             SILC_STATUS_ERR_UNKNOWN_MODE
             SILC_STATUS_ERR_NO_SUCH_CLIENT_ID
             SILC_STATUS_ERR_AUTH_FAILED
@@ -1391,14 +1246,14 @@ List of all defined commands in SILC follows.
 
         The following channel modes are defined:
 
-           0x00000000    SILC_CUMODE_NONE
+           0x0000    SILC_CUMODE_NONE
 
               No specific mode.  This is the normal situation for client.
               Also, this is the mode set when removing all modes from
               the target client.
 
 
-           0x00000001    SILC_CUMODE_FOUNDER
+           0x0001    SILC_CUMODE_FOUNDER
 
               The client is channel founder of the channel.  Usually this
               mode is set only by the server when the channel was created.
@@ -1411,28 +1266,11 @@ List of all defined commands in SILC follows.
               mode was set.  The client MAY remove this mode at any time.
 
 
-           0x00000002    SILC_CUMODE_OPERATOR
+           0x0002    SILC_CUMODE_OPERATOR
 
               Sets channel operator privileges on the channel for a
               client on the channel.  Channel founder and channel operator
-              MAY set/unset this mode.  The client MAY remove this mode
-              at any time.
-
-
-           0x00000004    SILC_CUMODE_BLOCK_MESSAGES
-
-              Marks that the client wishes not to receive any channel
-              messages sent for the channel.  Client MAY set and unset
-              this mode to itself.  Client MUST NOT set it to anyone else.
-              When this mode is set server MUST NOT deliver channel
-              messages to this client.  Other packets such as channel
-              key packets are still sent to the client.
-
-              A separate service could provide additional filtering
-              features for accepting channel messages from certain
-              sender.  However, this document does not specify such
-              service.
-
+              MAY set/unset this mode.
 
         Reply messages to the command:
 
@@ -1455,7 +1293,6 @@ List of all defined commands in SILC follows.
             SILC_STATUS_ERR_BAD_CHANNEL_ID
             SILC_STATUS_ERR_NO_CHANNEL_ID
             SILC_STATUS_ERR_NO_CHANNEL_PRIV
-            SILC_STATUS_ERR_NO_CHANNEL_FOPRIV
             SILC_STATUS_ERR_UNKNOWN_MODE
             SILC_STATUS_ERR_NO_SUCH_CLIENT_ID
             SILC_STATUS_ERR_AUTH_FAILED
@@ -1544,10 +1381,53 @@ List of all defined commands in SILC follows.
             SILC_STATUS_ERR_NO_CHANNEL_PRIV
 
 
-   21   <deprecated command>
+   21   SILC_COMMAND_CLOSE
+
+        Max Arguments:  2
+            Arguments:  (1) <remote server/router>  (2) [<port>]
 
+        This command is used only by operator to close connection to a
+        remote site.
 
-   22   <deprecated command>
+        Reply messages to the command:
+
+        Max Arguments:  1
+            Arguments:  (1) <Status Payload>
+
+        This command replies only with Status Payload.
+
+        Status messages:
+
+            SILC_STATUS_OK
+            SILC_STATUS_ERR_NOT_ENOUGH_PARAMS
+            SILC_STATUS_ERR_TOO_MANY_PARAMS
+            SILC_STATUS_ERR_NOT_REGISTERED
+            SILC_STATUS_ERR_NO_SUCH_SERVER
+            SILC_STATUS_ERR_NO_SERVER_PRIV
+            SILC_STATUS_ERR_NO_SUCH_SERVER_ID
+
+
+   22   SILC_COMMAND_SHUTDOWN
+
+        Max Arguments:  0
+            Arguments:  None
+
+        This command is used only by operator to shutdown the server.
+        All connections to the server will be closed and the server is
+        shutdown.
+
+        Reply messages to the command:
+
+        Max Arguments:  1
+            Arguments:  (1) <Status Payload>
+
+        This command replies only with Status Payload.
+
+        Status messages:
+
+            SILC_STATUS_OK
+            SILC_STATUS_ERR_NOT_REGISTERED
+            SILC_STATUS_ERR_NO_SERVER_PRIV
 
 
    23   SILC_COMMAND_SILCOPER
@@ -1613,10 +1493,10 @@ List of all defined commands in SILC follows.
 
         Reply messages to the command:
 
-        Max Arguments:  2
-            Arguments:  (1) <Status Payload>  (2) <Channel ID>
+        Max Arguments:  1
+            Arguments:  (1) <Status Payload>
 
-        The <Channel ID> is the ID of left channel.
+        This command replies only with Status Payload.
 
         Status messages:
 
@@ -1637,13 +1517,16 @@ List of all defined commands in SILC follows.
         This command is used to list user names currently on the requested
         channel; either the argument <Channel ID> or the <channel name>. 
         One of these arguments must be present.  The server MUST resolve
-        the joined clients and reply with a lists of users on the channel
-       and with list of user modes on the channel.
+        the user names and send a comma (`,') separated list of user names
+        on the channel.  Server or router MAY resolve the names by sending
+        SILC_COMMAND_WHOIS or SILC_COMMAND_IDENTIFY commands.
 
         If the requested channel is a private or secret channel, this
-        command MUST NOT send the list of users, but error is returned
-        to the sender, except if the sender is on the channel, or the
-        sender is server.
+        command MUST NOT send the list of users, as private and secret
+        channels cannot be seen by outside.  In this case the returned
+        name list MAY include a indication that the server could not 
+        resolve the names of the users on the channel.  Also, in this case
+        Client ID's or client modes are not sent either.
 
         Reply messages to the command:
 
@@ -1736,7 +1619,7 @@ represents the Command Status Payload (field is always in MSB order).
                      1
  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-|     Status    |     Error     |
+|        Status Message         |
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 .in 3
 
@@ -1745,49 +1628,10 @@ Figure 6:  SILC Command Status Payload
 
 
 .in 6
-o Status (1 byte) - Indicates the status message type,
-  error, start of list, entry of list or end of list.
-
-o Error (1 byte) - Indicates the error if the Status
-  field is some list status, which means there are list
-  of errors.
+o Status Message (2 bytes) - Indicates the status message.
+  All Status messages are described in the next section.
 .in 3
 
-The values in Status and Error fields are set according
-the following rules:
-
-.in 6
-o If there is single reply and error has not occurred
-  then Status field includes value SILC_STATUS_OK, and
-  the Error field MUST be ignored (and set to zero
-  value).
-
-o If there is single error, then Status field includes
-  one of the error values, and the Error field MUST be
-  ignored (and set to zero value).
-
-o If there will be multiple successful command replies
-  then Status field includes SILC_STATUS_LIST_START, 
-  SILC_STATUS_LIST_ITEM or SILC_STATUS_LIST_END value,
-  and Error field is set to SILC_STATUS_OK.
-
-o If there are multiple error replies then Status field
-  includes SILC_STATUS_LIST_START, SILC_STATUS_LIST_ITEM
-  or SILC_STATUS_LIST_END value, and the Error field
-  includes the error value.
-.in 3
-
-This way it is possible to send single successful or
-single error reply, but also multiple successful and
-multiple error replies.  Note that it is possible to
-send both list of successful replies and list of error
-replies at the same time, however in this case the
-list of error replies MUST be sent after the successful
-replies.  This way the recipient may ignore the multiple
-errors if it wishes to do so.
-
-All Status messages are described in the next section.
-
 
 .ti 0
 2.3.2 SILC Command Status List
@@ -2099,8 +1943,8 @@ security of this protocol.
 [RFC2119]    Bradner, S., "Key Words for use in RFCs to Indicate
              Requirement Levels", BCP 14, RFC 2119, March 1997.
 
-[RFC2279]    Yergeau, F., "UTF-8, a transformation format of ISO
-             10646", RFC 2279, January 1998.
+
+
 
 
 
index 9abce0d47caebc2c5fbb8a4620a5700d5f80f313..8ba7d4516587f13780ac89685cb812fc7d5492da 100644 (file)
@@ -215,9 +215,9 @@ Hence, the MIME Header in the message payload may be as follows:
 
 .in 8
 .nf
-MIME-Version: 1.0\\r
-Content-Type: discrete/composite\\r
-Content-Transfer-Encoding: binary\\r
+MIME-Version: 1.0
+Content-Type: discrete/composite
+Content-Transfer-Encoding: binary
 .in 3
 
 The Content-Transfer-Encoding field behaves as defined in [RFC2045] and 
index 7089aa4810c884495c065760dcd94bfa976d4b8e..4e207e4fa08d4390b3cc5dc3e51c32ed5d7c7782 100644 (file)
@@ -200,9 +200,7 @@ whether it supports the security properties.
 
 It then sends a Key Exchange Start Payload to the initiator filled with
 security properties it selected from the original payload.  The payload
-sent by responder MUST include only one chosen property per list.  The
-character encoding for the security property values as defined in [SILC1] 
-SHOULD be UTF-8 [RFC2279].
+sent by responder MUST include only one chosen property per list.
 
 The Key Exchange Start Payload is used to tell connecting entities what
 security properties and algorithms should be used in the communication.
@@ -483,9 +481,7 @@ o Public Key Type (2 bytes) - The public key (or certificate)
   be closed immediately.
 
 o Public Key (or certificate) (variable length) - The
-  public key or certificate.  The public key or certificate
-  in this field is encoded in the manner as defined in their
-  respective definitions;  see previous field.
+  public key or certificate.
 
 o Public Data Length (2 bytes) - The length of the Public Data
   field, not including any other field.
@@ -826,7 +822,6 @@ are defined:
 
     Provided version string was not acceptable.
 
-
 11  SILC_SKE_STATUS_INVALID_COOKIE
 
     The cookie in the Key Exchange Start Payload was malformed,
@@ -963,13 +958,7 @@ for defined numerical authentication method types.
 Passphrase authentication or pre-shared-key based authentication is 
 simply an authentication where the party that wants to authenticate 
 itself to the other end sends the passphrase that is required by
-the other end, for example server.  The plaintext passphrase is put
-to the payload, that is then encrypted.  The plaintext passphrase
-MUST be in UTF-8 [RFC2279] encoding.  If the passphrase is in the
-sender's system in some other encoding it MUST be UTF-8 encoded 
-before transmitted.  The receiver MAY change the encoding of the
-passphrase to its system's default character encoding before verifying
-the passphrase.
+the other end, for example server.
 
 If the passphrase matches with the one in the server's end the
 authentication is successful.  Otherwise SILC_PACKET_FAILURE MUST be
@@ -1112,9 +1101,6 @@ security of this protocol.
 [RFC2119]    Bradner, S., "Key Words for use in RFCs to Indicate
              Requirement Levels", BCP 14, RFC 2119, March 1997.
 
-[RFC2279]    Yergeau, F., "UTF-8, a transformation format of ISO
-             10646", RFC 2279, January 1998.
-
 
 .ti 0
 6 Author's Address
index fcc4b85020d93b6ed833f8bf57304146ed584d96..a8ed3e67d619561c90b101441c552472c7502b48 100644 (file)
@@ -102,7 +102,6 @@ Table of Contents
       2.3.20 Key Agreement Payload .............................. 43
       2.3.21 Resume Router Payload .............................. 44
       2.3.22 File Transfer Payload .............................. 44
-      2.3.23 Resume Client Payload .............................. XXXXXX
   2.4 SILC ID Types ............................................. 46
   2.5 Packet Encryption And Decryption .......................... 46
       2.5.1 Normal Packet Encryption And Decryption ............. 46
@@ -146,7 +145,6 @@ Figure 20:  New Server Payload
 Figure 21:  Key Agreement Payload
 Figure 22:  Resume Router Payload
 Figure 23:  File Transfer Payload
-Figure 24:  Resume Client Payload
 
 
 .ti 0
@@ -772,22 +770,7 @@ List of SILC Packet types are defined as follows.
           Payload of the packet:  See section 2.3.22 File Transfer Payload
 
 
-     28   SILC_PACKET_RESUME_CLIENT
-
-          This packet is used to resume a client back to the network
-          after it has been detached.  A client is able to detach from
-          the network but the client is still valid client in the network.
-          The client may then later resume its session back by sending
-          this packet to a server.  Routers also use this packet to notify
-          other routers in the network that the detached client has resumed.
-
-          This packet MUST NOT be sent as list and the List flag MUST
-          NOT be set.
-
-          Payload of the packet:  See section 2.3.23 Resume Client Payload
-
-
-     29 - 199
+     28 - 199
 
           Currently undefined commands.
 
@@ -1206,9 +1189,7 @@ o Argument Nums (2 bytes) - Indicates the number of Argument
 
 The following list of currently defined notify types.  The format for
 notify arguments is same as in SILC commands described in [SILC4]. 
-Note that all ID's sent in arguments are sent inside ID Payload.  Also
-note that all passphrases that may be sent inside arguments MUST be
-UTF-8 [RFC2279] encoded.
+Also, all ID's sent in arguments are sent inside ID Payload.
 
 .in 6
 0     SILC_NOTIFY_TYPE_NONE
@@ -1314,15 +1295,12 @@ UTF-8 [RFC2279] encoded.
       receiving the packet distributes this type to the local clients
       on the channel and broadcast it to the network.
 
-      Max Arguments:  3
+      Max Arguments:  2
           Arguments:  (1) <Old Client ID>  (2) <New Client ID>
-                      (3) <nickname>
 
       The <Old Client ID> is the old ID of the client which changed
       the nickname.  The <New Client ID> is the new ID generated by
-      the change of the nickname.  The <nickname> is the new nickname.
-      Note that it is possible to send this notify even if the nickname
-      hasn't changed, but client ID has changed.
+      the change of the nickname.
 
 
 7     SILC_NOTIFY_TYPE_CMODE_CHANGE
@@ -1437,14 +1415,12 @@ UTF-8 [RFC2279] encoded.
       or server receiving the packet distributes this type to the local
       clients on the channel and broadcast it to the network.
 
-      Max Arguments:  3
-          Arguments:  (1) <Client ID>           (2) [<comment>]
-                      (3) <Killer's ID>
+      Max Arguments:  2
+          Arguments:  (1) <Client ID>  (2) [<comment>]
 
       The <Client ID> is the client which was killed from the network.
       The killer may have set the <comment> to indicate the reason for
-      the killing.  The <Killer's ID> is the killer, which may be
-      client but also router server.
+      the killing.
 
 
 14    SILC_NOTIFY_TYPE_UMODE_CHANGE
@@ -1628,26 +1604,11 @@ o Message Flags (2 bytes) - Includes the Message Flags of
           of the signing process and any associated payloads
           of this flag.
 
-  0x0040  SILC_MESSAGE_FLAG_REPLY
-
-          This is a generic reply flag to send a reply to
-          previously received request.  A separate document
-          should define any payloads associated to this flag.
-
-  0x0080  SILC_MESSAGE_FLAG_DATA
-
-          This is a generic data flag, indicating that the
-          message includes some data which can be interpreted
-          in a specific way.  Using this flag any kind of data
-          can be delivered inside message payload.  A separate
-          document should define how this flag is interpreted
-          and define any associated payloads.
-
-  0x0100 - 0x0800 RESERVED
+  0x0040 - 0x0200 RESERVED
 
           Reserved for future flags
 
-  0x1000 - 0x8000 PRIVATE RANGE
+  0x0400 - 0x8000 PRIVATE RANGE
 
           Private range for free use.
 
@@ -1667,12 +1628,12 @@ o Padding (variable length) - The padding that MUST be
   other parts of the packet.
 
 o MAC (variable length) - The MAC computed from the
-  Message Length, Message Data, Padding Length, Padding and
-  Initial Vector fields.  This protects the integrity of the
-  plaintext channel message.  The receiver can verify from
-  the MAC whether the message decrypted correctly.  Also, if
-  more than one private key has been set for the channel, the
-  receiver can verify which of the keys decrypted the message 
+  Message Length, Message Data, Padding Length and Padding
+  fields.  This protects the integrity of the plaintext
+  channel message.  The receiver can verify from the MAC
+  whether the message decrypted correctly.  Also, if more than
+  one private key has been set for the channel, the receiver
+  can verify which of the keys decrypted the message 
   correctly.  Note that, this field is encrypted and MUST
   be added to the padding calculation.
 
@@ -1859,18 +1820,11 @@ o Padding (variable length) - This field is present only
 .ti 0
 2.3.12 Private Message Key Payload
 
-This payload is optional and can be used to send private message
-key between two clients in the network.  The packet is secured with
-normal session keys.  By default private messages are encrypted
-with session keys, and with this payload it is possible to set
-private key for private message encryption between two clients.
-
-The receiver of this payload SHOULD verify for example from user
-whether user wants to receive private message key.  Note that there
-are other, more secure ways of exchanging private message keys in
-the SILC network.  Instead of sending this payload it is possible to
-negotiate the private message key with SKE protocol using the Key
-Agreement payload directly peer to peer.
+This payload is used to send key from client to another client that
+is going to be used to protect the private messages between these
+two clients.  If this payload is not sent normal session key 
+established by the SILC Key Exchange Protocol is used to protect
+the private messages.
 
 This payload may only be sent by client to another client.  Server
 MUST NOT send this payload at any time.  After sending this payload
@@ -2368,7 +2322,7 @@ protected with the negotiated key material.
 
 The payload may only be sent with SILC_PACKET_FTP packet.  It MUST NOT
 be sent in any other packet type.  The following diagram represents the
-File Transfer Payload.
+File Transfer Payload
 
 .in 5
 .nf
@@ -2411,64 +2365,6 @@ o Data (variable length) - Arbitrary file transfer data.  The
 .in 3
 
 
-.ti 0
-2.3.23 Resume Client Payload
-
-This payload is used by client to resume its detached session in the
-SILC Network.  A client is able to detach itself from the network by
-sending SILC_COMMAND_DETACH command to its server.  The network
-connection to the client is lost but the client remains as valid
-client in the network.  The client is able to resume the session back
-by sending this packet and including the old Client ID, and an
-Authentication Payload [SILC1] which the server uses to verify with
-the detached client's public key.  This also implies that the 
-mandatory authentication method is public key authentication.
-
-Server or router that receives this from the client also sends this,
-without the Authentication Payload, to routers in the network so that
-they know the detached client has resumed.  Refer to the [SILC1] for
-detailed description how the detaching and resuming prodecure is
-performed.
-
-The payload may only be sent with SILC_PACKET_RESUME CLIENT packet.  It
-MUST NOT be sent in any other packet type.  The following diagram
-represents the Resume Client Payload.
-
-.in 5
-.nf
-                     1                   2                   3
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-|       Client ID Length        |                               |
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
-|                                                               |
-~                           Client ID                           ~
-|                                                               |
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-|                                                               |
-~                     Authentication Payload                    ~
-|                                                               |
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-.in 3
-
-.ce
-Figure 24:  Resume Client Payload
-
-
-.in 6
-o Client ID Length (1 byte) - The length of the Client ID
-  field not including any other field.
-
-o Client ID (variable length) - The detached client's Client
-  ID.  The client that sends this payload must know the Client
-  ID.
-
-o Authentication Payload (variable length) - The authentication
-  payload that the server will verify with the detached client's
-  public key.  If the server doesn't know the public key, it must
-  retrieve it for example with SILC_COMMAND_GETKEY command.
-.in 3
-
 
 
 .ti 0
@@ -2909,9 +2805,6 @@ security of this protocol.
 [SFTP]       Ylonen T., and Lehtinen S., "Secure Shell File Transfer
              Protocol", Internet Draft, March 2001.
 
-[RFC2279]    Yergeau, F., "UTF-8, a transformation format of ISO
-             10646", RFC 2279, January 1998.
-
 .ti 0
 5 Author's Address
 
index d98a3ff5fa2706ccf3554f7e2ebea76bf07c89b1..e5181fdd95898bc39ec95d2b0a40d189fbe39e29 100644 (file)
@@ -125,7 +125,6 @@ Table of Contents
   4.8 Session Key Regeneration .................................. 39
   4.9 Command Sending and Reception ............................. 40
   4.10 Closing Connection ....................................... 41
-  4.11 Detaching and Resuming a Session ......................... XXXXX
 5 Security Considerations ....................................... 41
 6 References .................................................... 42
 7 Author's Address .............................................. 44
@@ -453,7 +452,7 @@ between SILC and IRC.  This causes the server names or client's host names
 to be used along with the nicknames to identify specific users when sending
 messages.  This feature of SILC makes IRC style nickname-wars obsolete as
 no one owns their nickname; there can always be someone else with the same
-nickname.  The maximum length of nickname is 128 bytes.
+nickname.  The maximum length of nickname is 128 characters.
 
 
 .ti 0
@@ -738,7 +737,7 @@ can reference it using the name of the channel.
 Channel names are unique although the real uniqueness comes from 64 bit
 Channel ID.  However, channel names are still unique and no two global
 channels with same name may exist.  The Channel name is a string of
-maximum length of 256 bytes.  Channel names MUST NOT contain any
+maximum length of 256 characters.  Channel names MUST NOT contain any
 spaces (`  '), any non-printable ASCII characters, commas (`,') and
 wildcard characters.
 
@@ -883,7 +882,7 @@ established by the SILC Key Exchange Protocol, described in [SILC3].
 Every packet sent from client to server, with exception of packets for
 channels, are encrypted with this session key.
 
-Channels has a channel key that are shared by every client on the channel.
+Channels has their own key that are shared by every client on the channel.
 However, the channel keys are cell specific thus one cell does not know
 the channel key of the other cell, even if that key is for same channel.
 Channel key is also known by the routers and all servers that has clients
@@ -966,10 +965,9 @@ Example:  Private message from client to another client on different
           message delivery key with each other and that is used in 
           the message encryption.
 
-o Client 1. sends encrypted packet to its server.  The packet header
-  is encrypted with the session key shared between the client and
-  server, and the private message is encrypted with the private
-  message delivery key shared between clients.
+o Client 1. sends encrypted packet to its server.  The packet is
+  encrypted with the private message delivery key shared between
+  clients.
 
 o Server determines the destination of the packet and sends the 
   packet to the router.
@@ -1049,9 +1047,8 @@ completed.  The purpose of authentication is to authenticate for example
 client connecting to the server.  However, usually clients are accepted
 to connect to server without explicit authentication.  Servers are
 required use authentication protocol when connecting.  The authentication
-may be based on passphrase (pre-shared-secret) or public key.  All
-passphrases sent in SILC protocol MUST be UTF-8 [RFC2279] encoded.
-The connection authentication protocol is described in detail in [SILC3].
+may be based on passphrase (pre-shared-secret) or public key.  The
+connection authentication protocol is described in detail in [SILC3].
 
 
 .ti 0
@@ -1094,10 +1091,10 @@ Figure 5:  Authentication Payload
 .in 6
 o Payload Length (2 bytes) - Length of the entire payload.
 
-o Authentication Method (2 bytes) - The method of the
-  authentication.  The authentication methods are defined
-  in [SILC2] in the Connection Auth Request Payload.  The NONE 
-  authentication method SHOULD NOT be used.
+o Authentication Method (2) - The method of the authentication.
+  The authentication methods are defined in [SILC2] in the
+  Connection Auth Request Payload.  The NONE authentication
+  method SHOULD NOT be used.
 
 o Public Data Length (2 bytes) - Indicates the length of
   the Public Data field.
@@ -1121,9 +1118,9 @@ o Authentication Data (variable length) - Authentication
 
 
 If the authentication method is password based, the Authentication
-Data field includes the plaintext UTF-8 encoded password.  It is safe
-to send plaintext password since the entire payload is encrypted.  In
-this case the Public Data Length is set to zero (0), but MAY also include
+Data field includes the plaintext password.  It is safe to send
+plaintext password since the entire payload is encrypted.  In this
+case the Public Data Length is set to zero (0), but MAY also include
 random data for padding purposes.  It is also RECOMMENDED that maximum
 amount of padding is applied to SILC packet when using password based
 authentication.  This way it is not possible to approximate the length
@@ -1424,24 +1421,22 @@ software version = <major>[.<minor>[.<build or vendor string>]]
 .in 3
 
 Protocol version MAY provide both major and minor version.  Currently
-implementations MUST set the protocol version and accept at least the 
-protocol version as SILC-1.1-<software version>.  If new protocol version 
-causes incompatibilities with older version the <minor> version number 
-MUST be incremented.  The <major> is incremented if new protocol version 
-is fully incompatible.
+implementations MUST set the protocol version and accept the protocol
+version as SILC-1.0-<software version>.  If new protocol version causes
+in compatibilities with older version the the <minor> versio number MUST
+be incremented.  The <major> is incremented if new protocol version is
+fully incompatible.
 
-Software version MAY provide major, minor and build (vendor) version.
-The software version MAY be freely set and accepted.  The version string 
-MUST consist of printable US-ASCII characters.
+Software version MAY provide major, minor and build version.  The
+software version MAY be freely set and accepted.
 
 
 Thus, the version strings could be, for example:
 
 .in 6
-SILC-1.1-2.0.2
 SILC-1.0-1.2
-SILC-1.1-1.0.VendorXYZ
-SILC-1.1-2.4.5 Vendor Limited
+SILC-1.1-2.0.2
+SILC-1.0-1.0.VendorXYZ
 .in 3
 
 
@@ -2111,99 +2106,6 @@ local clients that are joined on the same channels with the remote
 server's or router's clients.
 
 
-.ti 0
-4.11 Detaching and Resuming a Session
-
-SILC protocol provides a possibility for a client to detach itself from
-the network without actually signing off from the network.  The client
-connection to the server is closed but the client remains as valid client
-in the network.  The client may then later resume its session back from
-any server in the network.
-
-When client wishes to detach from the network it MUST send the
-SILC_COMMAND_DETACH command to its server.  The server then MUST set
-SILC_UMODE_DETACHED mode to the client and send SILC_NOTIFY_UMODE_CHANGE
-notify to its primary router, which will then MUST broadcast it further
-to other routers in the network.  This user mode indicates that the
-client is detached from the network.  Implementations MUST NOT use
-the SILC_UMODE_DETACHED flag to determine whether a packet can be sent
-to the client.  All packets MUST still be sent to the client even if
-client is detached from the network.  Only the server that originally
-had the active client connection is able to make the decision after it
-notices that the network connection is not active.  In this case the
-default case is to discard the packet.
-
-The SILC_UMODE_DETACHED flag cannot be set by client itself directly
-with SILC_COMMAND_UMODE command, but only implicitly by sending the
-SILC_COMMAND_DETACH command.  The flag also cannot be unset by the
-client, server or router with SILC_COMMAND_UMODE command, but only
-implicitly by sending and receiving the SILC_PACKET_RESUME_CLIENT
-packet.
-
-When the client wishes to resume its session in the SILC Network it
-connects to a server in the network, which MAY also be a different
-from the original server, and performs normal procedures regarding
-creating a connection as described in section 4.1.  After the SKE
-and the Connection Authentication protocols has been successfully
-completed the client MUST NOT send SILC_PACKET_NEW_CLIENT packet, but
-MUST send SILC_PACKET_RESUME_CLIENT packet.  This packet is used to
-perform the resuming procedure.  The packet MUST include the detached
-client's Client ID, which the client must know.  It also includes
-Authentication Payload which includes signature made with the client's
-private key.  The signature is computed as defined in the section
-3.9.1.  Thus, the authentication method MUST be based in public key
-authentication.
-
-When server receives the SILC_PACKET_RESUME_CLIENT packet it MUST
-verify that the Client ID is valid client and that it has the
-SILC_UMODE_DETACHED mode set.  It then MUST verify the Authentication
-Payload with the detached client's public key.  If it does not have
-the public key it MUST retrieve it by sending SILC_COMMAND_GETKEY
-command to the server that has the public key from the original
-client connection.  The server MUST NOT use the public key received
-in the SKE protocol for this connection.  If the signature is valid
-the server MUST unset the SILC_UMODE_DETACHED flag, and send the
-SILC_PACKET_RESUME_CLIENT packet to its primary router.  The routers
-MUST broadcast the packet and unset the SILC_UMODE_DETACHED flag
-when the packet is received.  If the server is router server it also
-MUST send the SILC_PACKET_RESUME_CLIENT packet to the original server
-whom owned the detached client.
-
-The servers and routers that receives the SILC_PACKET_RESUME_CLIENT
-packet MUST know whether the packet already has been received for
-the client.  It is protocol error to attempt to resume the client
-session from more than one server.  The implementations could set
-internal flag that indicates that the client is resumed.  If router
-receive SILC_PACKET_RESUME_CLIENT packet for client that is already
-resumed the client MUST be killed from the network.  This would
-indicate that the client is attempting to resume the session more
-than once which is protocol error.  In this case the router sends
-SILC_NOTIFY_TYPE_KILLED to the client.  All routers that detect
-the same situation MUST also send the notify for the client.
-
-The servers and routers that receive the SILC_PACKET_RESUME_CLIENT
-must also understand that the client may not be found behind the
-same server that it originally came from.  They must update their
-caches according this.  The server that now owns the client session
-MUST check whether the Client ID of the resumed client is based
-on the server's Server ID.  If it is not it MUST create new Client
-ID and send SILC_NOTIFY_TYPE_NICK_CHANGE to the network.  It MUST
-also send the channel keys of all channels that the client is
-joined to the client since it does not have them.  Whether the
-Client ID was changed or not the server MUST send SILC_PACKET_NEW_ID
-packet to the client.  Only after this the client is resumed back
-to the network and may start sending packets and messages.
-
-It is also possible that the server does not know about the channels
-that the client has joined.  In this case it MUST join client internally
-to the channels, generate new channel keys and distribute the keys
-to the channels as described in section 4.4.
-
-It is implementation issue for how long servers keep detached client
-sessions.  It is RECOMMENDED that the detached sessions would be
-persistent as long as the server is running.
-
-
 .ti 0
 5 Security Considerations
 
@@ -2318,8 +2220,8 @@ should have a forum to discuss the cell management issues.
 [RFC2119]    Bradner, S., "Key Words for use in RFCs to Indicate
              Requirement Levels", BCP 14, RFC 2119, March 1997.
 
-[RFC2279]    Yergeau, F., "UTF-8, a transformation format of ISO
-             10646", RFC 2279, January 1998.
+
+
 
 
 
index 53414eb64ba7584176500f51ed0e8322ab756e0a..bf0a81b4ff509e78bea59d088adf5609593c0c7a 100644 (file)
@@ -63,7 +63,7 @@ General {
        # remote must be of at least this version, or newer.  If older then
        # the connection will not be allowed.
        #
-       # version_protocol         - SILC protocol version ("major.minor")
+       # version_protocol         - SILC protocol version ("majog.minor")
        # version_software         - software version ("major.minor")
        # version_software_vendor  - vendor specific version extension
        #
@@ -71,7 +71,7 @@ General {
        # number of the software.  The string can be a regex string to match
        # more widely.  Usually the vendor version checking is not necessary
        # and can be omitted.  These can be overridden with ConnectionParams.
-       #version_protocol = "1.1";
+       #version_protocol = "1.0";
        #version_software = "1.3";
        #version_software_vendor = "SomeVendor";
 
@@ -105,7 +105,7 @@ General {
 
        # Key exchange protocol rekey interval (seconds). How often to
        # regenerate the session key with the remote. Initiator will perform
-       # the rekey and this setting affects only when connecting as initiator.
+       # the rekey and this setting affects only when connecting as intiator.
        # This can be overridden with ConnectionParams.
        #key_exchange_rekey = 3600;
 
@@ -284,7 +284,7 @@ ConnectionParams {
        # number of the software.  The string can be a regex string to match
        # more widely.  Usually the vendor version checking is not necessary
        # and can be omitted.
-       #version_protocol = "1.1";
+       #version_protocol = "1.0";
        #version_software = "1.3";
        #version_software_vendor = "SomeVendor";
 
index a74228dc6b0fabccf2c77d63781229fad19c8020..0c72f406c9d326154a8623470fc1c02750a07517 100644 (file)
@@ -230,7 +230,6 @@ extern "C" {
 #include "silcbuffmt.h"
 #include "silcnet.h"
 #include "silcfileutil.h"
-#include "silcstrutil.h"
 #include "silcutil.h"
 #include "silcconfig.h"
 #include "silcprotocol.h"
index 3a29c13ad8343363b464e3b0f51282730e31ca84..32a97f934e26d319eb9b837e872fa3cdc07ea7d5 100644 (file)
@@ -29,8 +29,8 @@ extern "C" {
 /* Version type definition */
 typedef unsigned char SilcVersion;
 
-/* SILC Protocol version number */
-#define SILC_PROTOCOL_VERSION_CURRENT 11
+/* SILC Protocol version number used in SILC packets */
+#define SILC_VERSION_1 '\1'
 
 /* SILC version string */
 const char *silc_version = SILC_VERSION_STRING;
index 26486bc31c863d802f9e8bde857802ef4147b46a..88e103deacf1cc512d5838017cc9ef8e2417807e 100644 (file)
@@ -30,7 +30,7 @@
 #define vsnprintf _vsnprintf
 
 #ifdef WIN32
-#define strcasecmp stricmp
+#define strcasecmp strcmp
 #define strncasecmp strncmp
 #endif
 
diff --git a/lib/.cvsignore b/lib/.cvsignore
deleted file mode 100644 (file)
index a324157..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-Makefile
-Makefile.in
-Makefile.am
index 8f9c8e650130b407e49242d2a239572c81496725..c5f9681e83bf674618da90a2d45d0dc5566f4e11 100644 (file)
@@ -10,7 +10,7 @@ you need.
 
 <br />&nbsp;<br />
 This Toolkit reference manual is targeted at application developers who
-would like to add SILC support into their application, and to create new
+would like add SILC support into their application, and to create new
 SILC based applications.  It is especially aimed at C and C++ programmers,
 who would like to create SILC client applications, either based on command
 line interface (CLI) or on graphical user interface (GUI).
index 68d9f9d7d5356d58e4f87e97b45423fc704f5dc1..b4ec607b1a67ed9656675ce356d11e087ed31e39 100644 (file)
@@ -27,7 +27,6 @@ libsilcclient_a_SOURCES = \
        client_prvmsg.c \
        client_channel.c \
        client_ftp.c    \
-       client_resume.c \
        command.c \
        command_reply.c \
        idlist.c \
index becb0829d527ae34de7537aa173961e4375c699e..64ecee8873b7e3d860c84280c2863bfdb9f63fe1 100644 (file)
@@ -186,10 +186,10 @@ static void silc_client_entry_destructor(SilcIDCache cache,
    application performed the connecting outside the library. The library
    however may use this internally. */
 
-SilcClientConnection
-silc_client_add_connection(SilcClient client,
-                           SilcClientConnectionParams *params,
-                           char *hostname, int port, void *context)
+SilcClientConnection silc_client_add_connection(SilcClient client,
+                                               char *hostname,
+                                               int port,
+                                               void *context)
 {
   SilcClientConnection conn;
   int i;
@@ -208,13 +208,6 @@ silc_client_add_connection(SilcClient client,
   conn->pending_commands = silc_dlist_init();
   conn->ftp_sessions = silc_dlist_init();
 
-  if (params) {
-    if (params->detach_data)
-      conn->params.detach_data = silc_memdup(params->detach_data,
-                                            params->detach_data_len);
-    conn->params.detach_data_len = params->detach_data_len;
-  }
-
   /* Add the connection to connections table */
   for (i = 0; i < client->internal->conns_count; i++)
     if (client->internal->conns && !client->internal->conns[i]) {
@@ -337,9 +330,8 @@ silc_client_connect_to_server_internal(SilcClientInternalConnectContext *ctx)
    case then this function is not used at all. When the connecting is
    done the `connect' client operation is called. */
 
-int silc_client_connect_to_server(SilcClient client,
-                                  SilcClientConnectionParams *params,
-                                  int port, char *host, void *context)
+int silc_client_connect_to_server(SilcClient client, int port,
+                                 char *host, void *context)
 {
   SilcClientInternalConnectContext *ctx;
   SilcClientConnection conn;
@@ -348,7 +340,7 @@ int silc_client_connect_to_server(SilcClient client,
   SILC_LOG_DEBUG(("Connecting to port %d of server %s",
                  port, host));
 
-  conn = silc_client_add_connection(client, params, host, port, context);
+  conn = silc_client_add_connection(client, host, port, context);
 
   client->internal->ops->say(client, conn, SILC_CLIENT_MESSAGE_AUDIT, 
                             "Connecting to port %d of server %s", port, host);
@@ -410,7 +402,7 @@ static void silc_client_start_key_exchange_cb(SilcSocketConnection sock,
     client->internal->ops->say(client, conn, SILC_CLIENT_MESSAGE_ERROR,
                               "Error: Could not start key exchange protocol");
     silc_net_close_connection(conn->sock->sock);
-    client->internal->ops->connect(client, conn, SILC_CLIENT_CONN_ERROR);
+    client->internal->ops->connect(client, conn, FALSE);
     return;
   }
   conn->sock->protocol = protocol;
@@ -465,8 +457,7 @@ SILC_TASK_CALLBACK(silc_client_connect_failure)
     (SilcClientKEInternalContext *)context;
   SilcClient client = (SilcClient)ctx->client;
 
-  client->internal->ops->connect(client, ctx->sock->user_data, 
-                                SILC_CLIENT_CONN_ERROR);
+  client->internal->ops->connect(client, ctx->sock->user_data, FALSE);
   if (ctx->packet)
     silc_packet_context_free(ctx->packet);
   silc_free(ctx);
@@ -516,7 +507,7 @@ SILC_TASK_CALLBACK(silc_client_connect_to_server_start)
       silc_free(ctx);
 
       /* Notify application of failure */
-      client->internal->ops->connect(client, conn, SILC_CLIENT_CONN_ERROR);
+      client->internal->ops->connect(client, conn, FALSE);
       silc_client_del_connection(client, conn);
     }
     return;
@@ -671,71 +662,26 @@ SILC_TASK_CALLBACK(silc_client_connect_to_server_final)
     return;
   }
 
-  if (conn->params.detach_data) {
-    /* Send RESUME_CLIENT packet to the server, which is used to resume
-       old detached session back. */
-    SilcBuffer auth;
-    SilcClientID *old_client_id;
-    unsigned char *old_id;
-    SilcUInt16 old_id_len;
-
-    if (!silc_client_process_detach_data(client, conn, &old_id, &old_id_len))
-      return;
-
-    old_client_id = silc_id_str2id(old_id, old_id_len, SILC_ID_CLIENT);
-    if (!old_client_id) {
-      silc_free(old_id);
-      return;
-    }
-
-    /* Generate authentication data that server will verify */
-    auth = silc_auth_public_key_auth_generate(client->public_key,
-                                             client->private_key,
-                                             client->rng, conn->hash,
-                                             old_client_id, SILC_ID_CLIENT);
-    if (!auth) {
-      silc_free(old_client_id);
-      silc_free(old_id);
-      return;
-    }
+  /* Send NEW_CLIENT packet to the server. We will become registered
+     to the SILC network after sending this packet and we will receive
+     client ID from the server. */
+  packet = silc_buffer_alloc(2 + 2 + strlen(client->username) + 
+                            strlen(client->realname));
+  silc_buffer_pull_tail(packet, SILC_BUFFER_END(packet));
+  silc_buffer_format(packet,
+                    SILC_STR_UI_SHORT(strlen(client->username)),
+                    SILC_STR_UI_XNSTRING(client->username,
+                                         strlen(client->username)),
+                    SILC_STR_UI_SHORT(strlen(client->realname)),
+                    SILC_STR_UI_XNSTRING(client->realname,
+                                         strlen(client->realname)),
+                    SILC_STR_END);
 
-    packet = silc_buffer_alloc_size(2 + old_id_len + auth->len);
-    silc_buffer_format(packet,
-                      SILC_STR_UI_SHORT(old_id_len),
-                      SILC_STR_UI_XNSTRING(old_id, old_id_len),
-                      SILC_STR_UI_XNSTRING(auth->data, auth->len),
-                      SILC_STR_END);
-
-    /* Send the packet */
-    silc_client_packet_send(client, ctx->sock, SILC_PACKET_RESUME_CLIENT,
-                           NULL, 0, NULL, NULL, 
-                           packet->data, packet->len, TRUE);
-    silc_buffer_free(packet);
-    silc_buffer_free(auth);
-    silc_free(old_client_id);
-    silc_free(old_id);
-  } else {
-    /* Send NEW_CLIENT packet to the server. We will become registered
-       to the SILC network after sending this packet and we will receive
-       client ID from the server. */
-    packet = silc_buffer_alloc(2 + 2 + strlen(client->username) + 
-                              strlen(client->realname));
-    silc_buffer_pull_tail(packet, SILC_BUFFER_END(packet));
-    silc_buffer_format(packet,
-                      SILC_STR_UI_SHORT(strlen(client->username)),
-                      SILC_STR_UI_XNSTRING(client->username,
-                                           strlen(client->username)),
-                      SILC_STR_UI_SHORT(strlen(client->realname)),
-                      SILC_STR_UI_XNSTRING(client->realname,
-                                           strlen(client->realname)),
-                      SILC_STR_END);
-
-    /* Send the packet */
-    silc_client_packet_send(client, ctx->sock, SILC_PACKET_NEW_CLIENT,
-                           NULL, 0, NULL, NULL, 
-                           packet->data, packet->len, TRUE);
-    silc_buffer_free(packet);
-  }
+  /* Send the packet */
+  silc_client_packet_send(client, ctx->sock, SILC_PACKET_NEW_CLIENT,
+                         NULL, 0, NULL, NULL, 
+                         packet->data, packet->len, TRUE);
+  silc_buffer_free(packet);
 
   /* Save remote ID. */
   conn->remote_id = ctx->dest_id;
@@ -860,14 +806,14 @@ SILC_TASK_CALLBACK_GLOBAL(silc_client_packet_process)
       if (SILC_IS_DISCONNECTING(sock)) {
        if (sock == conn->sock && sock->type != SILC_SOCKET_TYPE_CLIENT)
          client->internal->ops->disconnect(client, conn);
-       silc_client_close_connection_real(client, sock, conn);
+       silc_client_close_connection(client, sock, conn);
        return;
       }
       
       SILC_LOG_DEBUG(("EOF from connection %d", sock->sock));
       if (sock == conn->sock && sock->type != SILC_SOCKET_TYPE_CLIENT)
        client->internal->ops->disconnect(client, conn);
-      silc_client_close_connection_real(client, sock, conn);
+      silc_client_close_connection(client, sock, conn);
       return;
     }
 
@@ -1332,9 +1278,9 @@ void silc_client_packet_queue_purge(SilcClient client,
    connection but `conn->sock' might be actually a different connection
    than the `sock'). */
 
-void silc_client_close_connection_real(SilcClient client,
-                                      SilcSocketConnection sock,
-                                      SilcClientConnection conn)
+void silc_client_close_connection(SilcClient client,
+                                 SilcSocketConnection sock,
+                                 SilcClientConnection conn)
 {
   int del = FALSE;
 
@@ -1449,14 +1395,6 @@ void silc_client_close_connection_real(SilcClient client,
   silc_socket_free(sock);
 }
 
-/* Closes the connection to the remote end */
-
-void silc_client_close_connection(SilcClient client,
-                                 SilcClientConnection conn)
-{
-  silc_client_close_connection_real(client, NULL, conn);
-}
-
 /* Called when we receive disconnection packet from server. This 
    closes our end properly and displays the reason of the disconnection
    on the screen. */
@@ -1470,7 +1408,7 @@ SILC_TASK_CALLBACK(silc_client_disconnected_by_server_later)
   if (sock == NULL)
     return;
 
-  silc_client_close_connection_real(client, sock, sock->user_data);
+  silc_client_close_connection(client, sock, sock->user_data);
 }
 
 /* Called when we receive disconnection packet from server. This 
@@ -1526,36 +1464,6 @@ SILC_TASK_CALLBACK(silc_client_send_auto_nick)
                           client->nickname, strlen(client->nickname));
 }
 
-/* Client session resuming callback.  If the session was resumed
-   this callback is called after the resuming is completed.  This
-   will call the `connect' client operation to the application
-   since it has not been called yet. */
-
-static void silc_client_resume_session_cb(SilcClient client,
-                                         SilcClientConnection conn,
-                                         bool success,
-                                         void *context)
-{
-  SilcBuffer sidp;
-
-  /* Notify application that connection is created to server */
-  client->internal->ops->connect(client, conn, success ?
-                                SILC_CLIENT_CONN_SUCCESS_RESUME :
-                                SILC_CLIENT_CONN_ERROR);
-
-  if (success) {
-    /* Issue INFO command to fetch the real server name and server
-       information and other stuff. */
-    silc_client_command_register(client, SILC_COMMAND_INFO, NULL, NULL,
-                                silc_client_command_reply_info_i, 0, 
-                                ++conn->cmd_ident);
-    sidp = silc_id_payload_encode(conn->remote_id, SILC_ID_SERVER);
-    silc_client_command_send(client, conn, SILC_COMMAND_INFO,
-                            conn->cmd_ident, 1, 2, sidp->data, sidp->len);
-    silc_buffer_free(sidp);
-  }
-}
-
 /* Processes the received new Client ID from server. Old Client ID is
    deleted from cache and new one is added. */
 
@@ -1566,6 +1474,7 @@ void silc_client_receive_new_id(SilcClient client,
   SilcClientConnection conn = (SilcClientConnection)sock->user_data;
   int connecting = FALSE;
   SilcClientID *client_id = silc_id_payload_get_id(idp);
+  SilcBuffer sidp;
 
   if (!conn->local_entry)
     connecting = TRUE;
@@ -1614,37 +1523,26 @@ void silc_client_receive_new_id(SilcClient client,
                   (void *)conn->local_entry, 0, NULL);
 
   if (connecting) {
-    if (!conn->params.detach_data) {
-      SilcBuffer sidp;
-
-      /* Send NICK command if the nickname was set by the application (and is
-        not same as the username). Send this with little timeout. */
-      if (client->nickname && strcmp(client->nickname, client->username))
-       silc_schedule_task_add(client->schedule, 0,
-                              silc_client_send_auto_nick, conn,
-                              1, 0, SILC_TASK_TIMEOUT, SILC_TASK_PRI_NORMAL);
-
-      /* Notify application of successful connection. We do it here now that
-        we've received the Client ID and are allowed to send traffic. */
-      client->internal->ops->connect(client, conn, SILC_CLIENT_CONN_SUCCESS);
-
-      /* Issue INFO command to fetch the real server name and server
-        information and other stuff. */
-      silc_client_command_register(client, SILC_COMMAND_INFO, NULL, NULL,
-                                  silc_client_command_reply_info_i, 0, 
-                                  ++conn->cmd_ident);
-      sidp = silc_id_payload_encode(conn->remote_id, SILC_ID_SERVER);
-      silc_client_command_send(client, conn, SILC_COMMAND_INFO,
-                              conn->cmd_ident, 1, 2, sidp->data, sidp->len);
-      silc_buffer_free(sidp);
-    } else {
-      /* We are resuming session.  Start resolving informations from the
-        server we need to set the client libary in the state before
-        detaching the session.  The connect client operation is called
-        after this is successfully completed */
-      silc_client_resume_session(client, conn, silc_client_resume_session_cb,
-                                NULL);
-    }
+    /* Send NICK command if the nickname was set by the application (and is
+       not same as the username). Send this with little timeout. */
+    if (client->nickname && strcmp(client->nickname, client->username))
+      silc_schedule_task_add(client->schedule, 0,
+                            silc_client_send_auto_nick, conn,
+                            1, 0, SILC_TASK_TIMEOUT, SILC_TASK_PRI_NORMAL);
+
+    /* Issue INFO command to fetch the real server name and server information
+       and other stuff. */
+    silc_client_command_register(client, SILC_COMMAND_INFO, NULL, NULL,
+                                silc_client_command_reply_info_i, 0, 
+                                ++conn->cmd_ident);
+    sidp = silc_id_payload_encode(conn->remote_id, SILC_ID_SERVER);
+    silc_client_command_send(client, conn, SILC_COMMAND_INFO,
+                            conn->cmd_ident, 1, 2, sidp->data, sidp->len);
+    silc_buffer_free(sidp);
+
+    /* Notify application of successful connection. We do it here now that
+       we've received the Client ID and are allowed to send traffic. */
+    client->internal->ops->connect(client, conn, TRUE);
   }
 }
 
@@ -1658,7 +1556,7 @@ void silc_client_remove_from_channels(SilcClient client,
   SilcChannelUser chu;
 
   silc_hash_table_list(client_entry->channels, &htl);
-  while (silc_hash_table_get(&htl, NULL, (void **)&chu)) {
+  while (silc_hash_table_get(&htl, NULL, (void *)&chu)) {
     silc_hash_table_del(chu->client->channels, chu->channel);
     silc_hash_table_del(chu->channel->user_list, chu->client);
     silc_free(chu);
@@ -1681,7 +1579,7 @@ void silc_client_replace_from_channels(SilcClient client,
   SilcChannelUser chu;
 
   silc_hash_table_list(old->channels, &htl);
-  while (silc_hash_table_get(&htl, NULL, (void **)&chu)) {
+  while (silc_hash_table_get(&htl, NULL, (void *)&chu)) {
     /* Replace client entry */
     silc_hash_table_del(chu->client->channels, chu->channel);
     silc_hash_table_del(chu->channel->user_list, chu->client);
index 2073bc5a0db7e5d09eb8f75048b647bd63b50f95..7868d4602e1c91ec44a6e4c70bffcc78d17e099f 100644 (file)
@@ -135,9 +135,6 @@ struct SilcClientConnectionStruct {
      and the actual client object is accesible through this pointer. */
   SilcClient client;
 
-  /* Connection parameters */
-  SilcClientConnectionParams params;
-
   /* User data context. Library does not touch this. */
   void *context;
 };
index 8d781039ae74b1ffe35d9691d3aa9e05eed60ffa..ff2f6d026a92cf69472661ce93e7218a736ab30b 100644 (file)
@@ -52,24 +52,9 @@ void silc_client_send_channel_message(SilcClient client,
   unsigned char *id_string;
   SilcUInt32 iv_len;
   int block_len;
-  SilcChannelUser chu;
 
   SILC_LOG_DEBUG(("Sending packet to channel"));
 
-  chu = silc_client_on_channel(channel, conn->local_entry);
-  if (!chu) {
-    SILC_LOG_ERROR(("Cannot send message to channel we are not joined"));
-    return;
-  }
-
-  /* Check if it is allowed to send messages to this channel by us. */
-  if (channel->mode & SILC_CHANNEL_MODE_SILENCE_USERS && !chu->mode)
-    return;
-  if (channel->mode & SILC_CHANNEL_MODE_SILENCE_OPERS && 
-      chu->mode & SILC_CHANNEL_UMODE_CHANOP &&
-      !(chu->mode & SILC_CHANNEL_UMODE_CHANFO))
-    return;
-
   /* Take the key to be used */
   if (channel->mode & SILC_CHANNEL_MODE_PRIVKEY) {
     if (key) {
@@ -188,7 +173,6 @@ static void silc_client_channel_message_cb(SilcClient client,
   if (clients_count == 1) {
     SilcChannelEntry channel;
     unsigned char *message;
-    SilcUInt32 message_len;
 
     channel = silc_client_get_channel_by_id(client, conn, res->channel_id);
     if (!channel)
@@ -204,13 +188,13 @@ static void silc_client_channel_message_cb(SilcClient client,
       silc_hash_table_add(clients[0]->channels, channel, chu);
     }
 
-    message = silc_channel_message_get_data(res->payload, &message_len);
+    message = silc_channel_message_get_data(res->payload, NULL);
     
     /* Pass the message to application */
     client->internal->ops->channel_message(
                               client, conn, clients[0], channel,
                               silc_channel_message_get_flags(res->payload),
-                              message, message_len);
+                              message);
   }
 
  out:
@@ -235,7 +219,6 @@ void silc_client_channel_message(SilcClient client,
   SilcClientEntry client_entry;
   SilcClientID *client_id = NULL;
   unsigned char *message;
-  SilcUInt32 message_len;
 
   SILC_LOG_DEBUG(("Start"));
 
@@ -318,13 +301,13 @@ void silc_client_channel_message(SilcClient client,
     goto out;
   }
 
-  message = silc_channel_message_get_data(payload, &message_len);
+  message = silc_channel_message_get_data(payload, NULL);
 
   /* Pass the message to application */
   client->internal->ops->channel_message(
                                 client, conn, client_entry, channel,
                                 silc_channel_message_get_flags(payload),
-                                message, message_len);
+                                message);
 
  out:
   silc_free(id);
index 87a1f4c9e51b05c0f74d78b0779d550976b23e88..a67267098ea5121ff2db44b57092b66a88cc1182 100644 (file)
@@ -542,7 +542,7 @@ static void silc_client_ftp_start_key_agreement(SilcClientFtpSession session,
                        NULL, session->monitor_context);
 
   /* Add new connection for this session */
-  conn = silc_client_add_connection(client, NULL, session->hostname,
+  conn = silc_client_add_connection(client, session->hostname,
                                    session->port, session);
 
   /* Allocate new socket connection object */
@@ -640,7 +640,7 @@ SILC_TASK_CALLBACK(silc_client_ftp_process_key_agreement)
                        NULL, session->monitor_context);
 
   /* Add new connection for this session */
-  conn = silc_client_add_connection(client, NULL, newsocket->hostname,
+  conn = silc_client_add_connection(client, newsocket->hostname,
                                    newsocket->port, session);
   conn->sock = newsocket;
   conn->sock->user_data = conn;
@@ -754,7 +754,7 @@ void silc_client_ftp_session_free(SilcClientFtpSession session)
       if (conn->active_session == session)
        conn->active_session = NULL;
 
-      silc_client_close_connection_real(session->client, session->sock, conn);
+      silc_client_close_connection(session->client, session->sock, conn);
     } else {
       silc_socket_free(session->sock);
     }
index be5c05b168efa490478f25d77756f550123888b2..294e003a165ce76048daabc25a3fd4920fc76ec5 100644 (file)
@@ -84,12 +84,6 @@ struct SilcClientInternalStruct {
   char *silc_client_version;
 };
 
-/* Session resuming callback */
-typedef void (*SilcClientResumeSessionCallback)(SilcClient client,
-                                               SilcClientConnection conn,
-                                               bool success,
-                                               void *context);
-
 /* Macros */
 
 /* Registers generic task for file descriptor for reading from network and
@@ -161,9 +155,6 @@ void silc_client_packet_send(SilcClient client,
                             unsigned char *data, 
                             SilcUInt32 data_len, 
                             int force_send);
-void silc_client_close_connection_real(SilcClient client,
-                                      SilcSocketConnection sock,
-                                      SilcClientConnection conn);
 void silc_client_disconnected_by_server(SilcClient client,
                                        SilcSocketConnection sock,
                                        SilcBuffer message);
@@ -208,15 +199,5 @@ void silc_client_connection_auth_request(SilcClient client,
 void silc_client_ftp(SilcClient client,
                     SilcSocketConnection sock,
                     SilcPacketContext *packet);
-SilcBuffer silc_client_get_detach_data(SilcClient client,
-                                      SilcClientConnection conn);
-bool silc_client_process_detach_data(SilcClient client,
-                                    SilcClientConnection conn,
-                                    unsigned char **old_id,
-                                    SilcUInt16 *old_id_len);
-void silc_client_resume_session(SilcClient client,
-                               SilcClientConnection conn,
-                               SilcClientResumeSessionCallback callback,
-                               void *context);
 
 #endif
index c13030695bb6c2544828ff63cf2bfb0f946c775f..5e13bf72dae90ce0c3860c576b47d06796dac597 100644 (file)
 #include "silcclient.h"
 #include "client_internal.h"
 
-/* Context used for resolving client, channel and server info. */
 typedef struct {
-  void *packet;
+  SilcPacketContext *packet;
   void *context;
   SilcSocketConnection sock;
 } *SilcClientNotifyResolve;
 
-SILC_TASK_CALLBACK(silc_client_notify_check_client)
-{ 
-  SilcClientNotifyResolve res = (SilcClientNotifyResolve)context;
-  SilcClientConnection conn = res->context;
-  SilcClient client = conn->client;
-  SilcClientID *client_id = res->packet;
-  silc_client_get_client_by_id_resolve(client, conn, client_id, NULL, NULL);
-  silc_free(client_id);
-  silc_free(res);
-}
-
 /* Called when notify is received and some async operation (such as command)
    is required before processing the notify message. This calls again the
    silc_client_notify_by_server and reprocesses the original notify packet. */
@@ -55,8 +43,11 @@ static void silc_client_notify_by_server_pending(void *context, void *context2)
 
   SILC_LOG_DEBUG(("Start"));
 
-  if (reply && !silc_command_get_status(reply->payload, NULL, NULL))
-    goto out;
+  if (reply) {
+    SilcCommandStatus status = silc_command_get_status(reply->payload);
+    if (status != SILC_STATUS_OK)
+      goto out;
+  }
 
   silc_client_notify_by_server(res->context, res->sock, res->packet);
 
@@ -81,7 +72,7 @@ static void silc_client_notify_by_server_resolve(SilcClient client,
   res->context = client;
   res->sock = silc_socket_dup(conn->sock);
 
-  /* For client resolving use WHOIS, and otherwise use IDENTIFY */
+  /* For client resolving use WHOIS, and oterhwise use IDENTIFY */
   if (id_type == SILC_ID_CLIENT) {
     silc_client_command_register(client, SILC_COMMAND_WHOIS, NULL, NULL,
                                 silc_client_command_reply_whois_i, 0,
@@ -223,10 +214,9 @@ void silc_client_notify_by_server(SilcClient client,
        client_entry->status &= ~SILC_CLIENT_STATUS_RESOLVING;
        goto out;
       }
+      client_entry->status |= SILC_CLIENT_STATUS_RESOLVING;
       silc_client_notify_by_server_resolve(client, conn, packet, 
                                           SILC_ID_CLIENT, client_id);
-      client_entry->status |= SILC_CLIENT_STATUS_RESOLVING;
-      client_entry->resolve_cmd_ident = conn->cmd_ident;
       goto out;
     } else {
       if (client_entry != conn->local_entry)
@@ -302,20 +292,6 @@ void silc_client_notify_by_server(SilcClient client,
       silc_free(chu);
     }
 
-    /* Some client implementations actually quit network by first doing
-       LEAVE and then immediately SIGNOFF.  We'll check for this by doing 
-       check for the client after 5 - 34 seconds.  If it is not valid after
-       that we'll remove the client from cache. */
-    if (!silc_hash_table_count(client_entry->channels)) {
-      SilcClientNotifyResolve res = silc_calloc(1, sizeof(*res));
-      res->context = conn;
-      res->packet = silc_id_dup(client_id, SILC_ID_CLIENT);
-      silc_schedule_task_add(client->schedule, 0,
-                            silc_client_notify_check_client, conn,
-                            (5 + (silc_rng_get_rn16(client->rng) % 29)),
-                            0, SILC_TASK_TIMEOUT, SILC_TASK_PRI_NORMAL);
-    }
-
     /* Notify application. The channel entry is sent last as this notify
        is for channel but application don't know it from the arguments
        sent by server. */
@@ -457,7 +433,7 @@ void silc_client_notify_by_server(SilcClient client,
       goto out;
 
     /* Ignore my ID */
-    if (conn->local_id && SILC_ID_CLIENT_COMPARE(client_id, conn->local_id))
+    if (SILC_ID_CLIENT_COMPARE(client_id, conn->local_id))
       break;
 
     /* Find old Client entry */
@@ -477,96 +453,41 @@ void silc_client_notify_by_server(SilcClient client,
     if (!client_id)
       goto out;
 
-    /* From protocol version 1.1 we get the new nickname in notify as well,
-       so we don't have to resolve it.  Do it the hard way if server doesn't
-       send it to us. */
-    tmp = silc_argument_get_arg_type(args, 3, NULL);
-    if (tmp) {
-      /* Protocol version 1.1 */
-      char *tmp_nick = NULL;
-
-      /* Check whether nickname changed at all.  It is possible that nick
-        change notify is received but nickname didn't changed, only the
-        ID changes. */
-      if (client->internal->params->nickname_parse)
-       client->internal->params->nickname_parse(client_entry->nickname,
-                                                &tmp_nick);
-      else
-       tmp_nick = strdup(tmp);
-
-      if (tmp_nick && !strcmp(tmp, tmp_nick)) {
-       /* Nickname didn't change. Update only the ID */
-       silc_idcache_del_by_context(conn->client_cache, client_entry);
-       silc_free(client_entry->id);
-       client_entry->id = silc_id_dup(client_id, SILC_ID_CLIENT);
-       silc_idcache_add(conn->client_cache, strdup(tmp),
-                        client_entry->id, client_entry, 0, NULL);
-
-       /* Notify application */
-       client->internal->ops->notify(client, conn, type, 
-                                     client_entry, client_entry);
-       break;
-      }
-      silc_free(tmp_nick);
-
-      /* Create new client entry, and save all old information with the
-        new nickname and client ID */
-      client_entry2 = silc_client_add_client(client, conn, NULL, NULL, 
-                                            client_entry->realname,
-                                            silc_id_dup(client_id, 
-                                                        SILC_ID_CLIENT), 0);
-      if (!client_entry2)
-       goto out;
-
-      if (client_entry->server)
-       client_entry2->server = strdup(client_entry->server);
-      if (client_entry->username)
-       client_entry2->username = strdup(client_entry->username);
-      if (client_entry->hostname)
-       client_entry2->hostname = strdup(client_entry->hostname);
-      silc_client_update_client(client, conn, client_entry2, tmp, NULL, NULL,
-                               client_entry->mode);
-    } else {
-      /* Protocol version 1.0 */
-
-      /* Find client entry and if not found resolve it */
-      client_entry2 = silc_client_get_client_by_id(client, conn, client_id);
-      if (!client_entry2) {
-       /* Resolve the entry information */
-       silc_client_notify_by_server_resolve(client, conn, packet, 
-                                            SILC_ID_CLIENT, client_id);
+    /* Find Client entry and if not found resolve it */
+    client_entry2 = silc_client_get_client_by_id(client, conn, client_id);
+    if (!client_entry2) {
+      /* Resolve the entry information */
+      silc_client_notify_by_server_resolve(client, conn, packet, 
+                                          SILC_ID_CLIENT, client_id);
 
-       /* Add the new entry even though we resolved it. This is because we
-          want to replace the old entry with the new entry here right now. */
-       client_entry2 = 
-         silc_client_add_client(client, conn, NULL, NULL, NULL, 
-                                silc_id_dup(client_id, SILC_ID_CLIENT), 
-                                client_entry->mode);
-
-       /* Replace old ID entry with new one on all channels. */
-       silc_client_replace_from_channels(client, conn, client_entry,
-                                         client_entry2);
-       break;
-      }
+      /* Add the new entry even though we resolved it. This is because we
+        want to replace the old entry with the new entry here right now. */
+      client_entry2 = 
+       silc_client_add_client(client, conn, NULL, NULL, NULL, 
+                              silc_id_dup(client_id, SILC_ID_CLIENT), 
+                              client_entry->mode);
 
+      /* Replace old ID entry with new one on all channels. */
+      silc_client_replace_from_channels(client, conn, client_entry,
+                                       client_entry2);
+    } else {
       if (client_entry2 != conn->local_entry)
        silc_client_nickname_format(client, conn, client_entry2);
-    }
 
-    /* Remove the old from cache */
-    silc_idcache_del_by_context(conn->client_cache, client_entry);
-    
-    /* Replace old ID entry with new one on all channels. */
-    silc_client_replace_from_channels(client, conn, client_entry,
-                                     client_entry2);
+      /* Remove the old from cache */
+      silc_idcache_del_by_context(conn->client_cache, client_entry);
 
-    /* Notify application */
-    client->internal->ops->notify(client, conn, type, 
-                                 client_entry, client_entry2);
-    
-    /* Free old client entry */
-    silc_client_del_client_entry(client, conn, client_entry);
+      /* Replace old ID entry with new one on all channels. */
+      silc_client_replace_from_channels(client, conn, client_entry,
+                                       client_entry2);
+
+      /* Notify application */
+      client->internal->ops->notify(client, conn, type, 
+                                   client_entry, client_entry2);
 
+      /* Free data */
+      silc_client_del_client_entry(client, conn, client_entry);
+    }
     break;
 
   case SILC_NOTIFY_TYPE_CMODE_CHANGE:
@@ -848,10 +769,9 @@ void silc_client_notify_by_server(SilcClient client,
     if (!channel)
       break;
 
-    /* From protocol version 1.1 we get the kicker's client ID as well */
+    /* Get the kicker */
     tmp = silc_argument_get_arg_type(args, 3, &tmp_len);
     if (tmp) {
-      silc_free(client_id);
       client_id = silc_id_payload_parse_id(tmp, tmp_len, NULL);
       if (!client_id)
        goto out;
@@ -894,88 +814,36 @@ void silc_client_notify_by_server(SilcClient client,
     break;
 
   case SILC_NOTIFY_TYPE_KILLED:
-    {
-      /*
-       * A client (maybe me) was killed from the network.
-       */
-      char *comment;
-      SilcUInt32 comment_len;
+    /*
+     * A client (maybe me) was killed from the network.
+     */
 
-      SILC_LOG_DEBUG(("Notify: KILLED"));
+    SILC_LOG_DEBUG(("Notify: KILLED"));
 
-      /* Get Client ID */
-      tmp = silc_argument_get_arg_type(args, 1, &tmp_len);
-      if (!tmp)
-       goto out;
+    /* Get Client ID */
+    tmp = silc_argument_get_arg_type(args, 1, &tmp_len);
+    if (!tmp)
+      goto out;
 
-      client_id = silc_id_payload_parse_id(tmp, tmp_len, NULL);
-      if (!client_id)
-       goto out;
+    client_id = silc_id_payload_parse_id(tmp, tmp_len, NULL);
+    if (!client_id)
+      goto out;
 
-      /* Find Client entry */
-      client_entry = silc_client_get_client_by_id(client, conn, client_id);
-      if (!client_entry)
-       goto out;
+    /* Find Client entry */
+    client_entry = silc_client_get_client_by_id(client, conn, client_id);
+    if (!client_entry)
+      goto out;
 
-      /* Get comment */
-      comment = silc_argument_get_arg_type(args, 2, &comment_len);
-
-      /* From protocol version 1.1 we get killer's client ID as well */
-      tmp = silc_argument_get_arg_type(args, 3, &tmp_len);
-      if (tmp) {
-       silc_free(client_id);
-       id = silc_id_payload_parse_id(tmp, tmp_len, &id_type);
-       if (!id)
-         goto out;
-
-       /* Find Client entry */
-       if (id_type == SILC_ID_CLIENT) {
-         /* Find Client entry */
-         client_id = id;
-         client_entry2 = silc_client_get_client_by_id(client, conn, 
-                                                      client_id);
-         if (!client_entry) {
-           silc_client_notify_by_server_resolve(client, conn, packet, 
-                                                SILC_ID_CLIENT, client_id);
-           goto out;
-         }
-       } else if (id_type == SILC_ID_SERVER) {
-         /* Find Server entry */
-         server_id = id;
-         server = silc_client_get_server_by_id(client, conn, server_id);
-         if (!server) {
-           silc_client_notify_by_server_resolve(client, conn, packet, 
-                                                SILC_ID_SERVER, server_id);
-           goto out;
-         }
-      
-         /* Save the pointer to the client_entry pointer */
-         client_entry2 = (SilcClientEntry)server;
-       } else {
-         /* Find Channel entry */
-         channel_id = id;
-         channel = silc_client_get_channel_by_id(client, conn, channel_id);
-         if (!channel) {
-           silc_client_notify_by_server_resolve(client, conn, packet, 
-                                                SILC_ID_CHANNEL, channel_id);
-           goto out;
-         }
-         
-         /* Save the pointer to the client_entry pointer */
-         client_entry2 = (SilcClientEntry)channel;
-         silc_free(channel_id);
-         channel_id = NULL;
-       }
-      }
+    /* Get comment */
+    tmp = silc_argument_get_arg_type(args, 2, &tmp_len);
 
-      /* Notify application. */
-      client->internal->ops->notify(client, conn, type, client_entry, 
-                                   comment, id_type, client_entry2);
+    /* Notify application. */
+    client->internal->ops->notify(client, conn, type, client_entry, tmp);
+
+    if (client_entry != conn->local_entry)
+      /* Remove the client from all channels and free it */
+      silc_client_del_client(client, conn, client_entry);
 
-      if (client_entry != conn->local_entry)
-       /* Remove the client from all channels and free it */
-       silc_client_del_client(client, conn, client_entry);
-    }
     break;
     
   case SILC_NOTIFY_TYPE_SERVER_SIGNOFF:
index 6662e8550d1c84dcacae20570f953ab73854dcd7..bb17c1a4cd2ca41f594c3ffad34c1459524f7f24 100644 (file)
@@ -29,8 +29,7 @@ silc_say(SilcClient client, SilcClientConnection conn,
 static void 
 silc_channel_message(SilcClient client, SilcClientConnection conn, 
                     SilcClientEntry sender, SilcChannelEntry channel, 
-                    SilcMessageFlags flags, const unsigned char *message,
-                    SilcUInt32 message_len);
+                    SilcMessageFlags flags, char *msg)
 {
 
 }
@@ -41,9 +40,7 @@ silc_channel_message(SilcClient client, SilcClientConnection conn,
 
 static void 
 silc_private_message(SilcClient client, SilcClientConnection conn, 
-                    SilcClientEntry sender, SilcMessageFlags flags, 
-                    const unsigned char *message,
-                    SilcUInt32 message_len);
+                    SilcClientEntry sender, SilcMessageFlags flags, char *msg)
 {
 
 }
@@ -117,8 +114,7 @@ silc_command_reply(SilcClient client, SilcClientConnection conn,
    silc_client_close_connection. */
 
 static void 
-silc_connect(SilcClient client, SilcClientConnection conn,
-            SilcClientConnectionStatus status);
+silc_connect(SilcClient client, SilcClientConnection conn, int success)
 {
 
 }
@@ -165,8 +161,7 @@ silc_verify_public_key(SilcClient client, SilcClientConnection conn,
 
 /* Ask (interact, that is) a passphrase from user. The passphrase is
    returned to the library by calling the `completion' callback with
-   the `context'. The returned passphrase SHOULD be in UTF-8 encoded,
-   if not then the library will attempt to encode. */
+   the `context'. */
 
 static void 
 silc_ask_passphrase(SilcClient client, SilcClientConnection conn, 
@@ -226,31 +221,6 @@ silc_ftp(SilcClient client, SilcClientConnection conn,
 }
 
 
-/* Delivers SILC session detachment data indicated by `detach_data' to the 
-   application.  If application has issued SILC_COMMAND_DETACH command
-   the client session in the SILC network is not quit.  The client remains
-   in the network but is detached.  The detachment data may be used later
-   to resume the session in the SILC Network.  The appliation is 
-   responsible of saving the `detach_data', to for example in a file.
-
-   The detachment data can be given as argument to the functions
-   silc_client_connect_to_server, or silc_client_add_connection when
-   creating connection to remote server, inside SilcClientConnectionParams
-   structure.  If it is provided the client library will attempt to resume 
-   the session in the network.  After the connection is created 
-   successfully, the application is responsible of setting the user 
-   interface for user into the same state it was before detaching (showing 
-   same channels, channel modes, etc).  It can do this by fetching the
-   information (like joined channels) from the client library. */
-
-static void
-silc_detach(SilcClient client, SilcClientConnection conn,
-           const unsigned char *detach_data, SilcUInt32 detach_data_len)
-{
-
-}
-
-
 /* The SilcClientOperation structure containing the operation functions.
    You will give this as an argument to silc_client_alloc function. */
 SilcClientOperations ops = {
@@ -267,6 +237,5 @@ SilcClientOperations ops = {
   silc_ask_passphrase,
   silc_failure,
   silc_key_agreement,
-  silc_ftp,
-  silc_detach
+  silc_ftp
 };
index 439fe0e32d3853877fa8b3346b41dec2cf3598e8..c229b4509655c111fe43e21c6f0fc45d8922a6d7 100644 (file)
@@ -148,8 +148,6 @@ void silc_client_private_message(SilcClient client,
   SilcClientID *remote_id = NULL;
   SilcClientEntry remote_client;
   SilcMessageFlags flags;
-  unsigned char *message;
-  SilcUInt32 message_len;
 
   if (packet->src_id_type != SILC_ID_CLIENT)
     goto out;
@@ -168,7 +166,6 @@ void silc_client_private_message(SilcClient client,
        goto out;
       }
       remote_client->status |= SILC_CLIENT_STATUS_RESOLVING;
-      remote_client->resolve_cmd_ident = conn->cmd_ident + 1;
     }
 
     /* Resolve the client info */
@@ -190,9 +187,10 @@ void silc_client_private_message(SilcClient client,
   flags = silc_private_message_get_flags(payload);
 
   /* Pass the private message to application */
-  message = silc_private_message_get_message(payload, &message_len);
-  client->internal->ops->private_message(client, conn, remote_client, flags,
-                                        message, message_len);
+  client->internal->ops->private_message(
+                                client, conn, remote_client, flags,
+                                silc_private_message_get_message(payload, 
+                                                                 NULL));
 
   /* See if we are away (gone). If we are away we will reply to the
      sender with the set away message. */
diff --git a/lib/silcclient/client_resume.c b/lib/silcclient/client_resume.c
deleted file mode 100644 (file)
index d3fd7a9..0000000
+++ /dev/null
@@ -1,566 +0,0 @@
-/*
-
-  client_resume.c
-
-  Author: Pekka Riikonen <priikone@silcnet.org>
-
-  Copyright (C) 2002 Pekka Riikonen
-
-  This program is free software; you can redistribute it and/or modify
-  it under the terms of the GNU General Public License as published by
-  the Free Software Foundation; version 2 of the License.
-
-  This program is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  GNU General Public License for more details.
-
-*/
-/* $Id$ */
-
-#include "silcincludes.h"
-#include "silcclient.h"
-#include "client_internal.h"
-
-SILC_CLIENT_CMD_REPLY_FUNC(resume);
-SILC_CLIENT_CMD_FUNC(resume_identify);
-SILC_CLIENT_CMD_FUNC(resume_cmode);
-SILC_CLIENT_CMD_FUNC(resume_users);
-
-#define RESUME_CALL_COMPLETION(client, session, s)                     \
-do {                                                                   \
-  session->success = s;                                                        \
-  silc_schedule_task_add(client->schedule, 0,                          \
-                        silc_client_resume_call_completion, session,   \
-                        0, 1, SILC_TASK_TIMEOUT, SILC_TASK_PRI_LOW);   \
-} while(0)
-
-/* Generates the session detachment data. This data can be used later
-   to resume back to the server. */
-
-SilcBuffer silc_client_get_detach_data(SilcClient client,
-                                      SilcClientConnection conn)
-{
-  SilcBuffer detach;
-  SilcHashTableList htl;
-  SilcChannelUser chu;
-  int ch_count;
-
-  SILC_LOG_DEBUG(("Creating detachment data"));
-
-  ch_count = silc_hash_table_count(conn->local_entry->channels);
-
-  /* Save the nickname, Client ID and user mode in SILC network */
-  detach = silc_buffer_alloc_size(2 + strlen(conn->nickname) +
-                                 2 + conn->local_id_data_len + 4 + 4);
-  silc_buffer_format(detach,
-                    SILC_STR_UI_SHORT(strlen(conn->nickname)),
-                    SILC_STR_UI_XNSTRING(conn->nickname,
-                                         strlen(conn->nickname)),
-                    SILC_STR_UI_SHORT(conn->local_id_data_len),
-                    SILC_STR_UI_XNSTRING(conn->local_id_data,
-                                         conn->local_id_data_len),
-                    SILC_STR_UI_INT(conn->local_entry->mode),
-                    SILC_STR_UI_INT(ch_count),
-                    SILC_STR_END);
-
-  /* Save all joined channels */
-  silc_hash_table_list(conn->local_entry->channels, &htl);
-  while (silc_hash_table_get(&htl, NULL, (void **)&chu)) {
-    unsigned char *chid = silc_id_id2str(chu->channel->id, SILC_ID_CHANNEL);
-    SilcUInt16 chid_len = silc_id_get_len(chu->channel->id, SILC_ID_CHANNEL);
-
-    detach = silc_buffer_realloc(detach, detach->truelen + 2 +
-                                strlen(chu->channel->channel_name) +
-                                2 + chid_len + 4);
-    silc_buffer_pull(detach, detach->len);
-    silc_buffer_pull_tail(detach, 2 + strlen(chu->channel->channel_name) +
-                         2 + chid_len + 4);
-    silc_buffer_format(detach,
-                      SILC_STR_UI_SHORT(strlen(chu->channel->channel_name)),
-                      SILC_STR_UI_XNSTRING(chu->channel->channel_name,
-                                          strlen(chu->channel->channel_name)),
-                      SILC_STR_UI_SHORT(chid_len),
-                      SILC_STR_UI_XNSTRING(chid, chid_len),
-                      SILC_STR_UI_INT(chu->channel->mode),
-                      SILC_STR_END);
-    silc_free(chid);
-  }
-  silc_hash_table_list_reset(&htl);
-
-  silc_buffer_push(detach, detach->data - detach->head);
-
-  SILC_LOG_HEXDUMP(("Detach data"), detach->data, detach->len);
-
-  return detach;
-}
-
-/* Processes the detachment data. This creates channels and other
-   stuff according the data found in the the connection parameters.
-   This doesn't actually resolve any detailed information from the
-   server.  To do that call silc_client_resume_session function. 
-   This returns the old detached session client ID. */
-
-bool silc_client_process_detach_data(SilcClient client,
-                                    SilcClientConnection conn,
-                                    unsigned char **old_id,
-                                    SilcUInt16 *old_id_len)
-{
-  SilcBufferStruct detach;
-  SilcUInt32 ch_count;
-  int i, len;
-
-  SILC_LOG_DEBUG(("Start"));
-
-  silc_free(conn->nickname);
-  silc_buffer_set(&detach, conn->params.detach_data, 
-                 conn->params.detach_data_len);
-
-  SILC_LOG_HEXDUMP(("Detach data"), detach.data, detach.len);
-
-  /* Take the old client ID from the detachment data */
-  len = silc_buffer_unformat(&detach,
-                            SILC_STR_UI16_NSTRING_ALLOC(&conn->nickname, 
-                                                        NULL),
-                            SILC_STR_UI16_NSTRING_ALLOC(old_id, old_id_len),
-                            SILC_STR_UI_INT(NULL),
-                            SILC_STR_UI_INT(&ch_count),
-                            SILC_STR_END);
-  if (len == -1)
-    return FALSE;
-
-  silc_buffer_pull(&detach, len);
-
-  for (i = 0; i < ch_count; i++) {
-    char *channel;
-    unsigned char *chid;
-    SilcUInt16 chid_len;
-    SilcUInt32 ch_mode;
-    SilcChannelID *channel_id;
-    SilcChannelEntry channel_entry;
-
-    len = silc_buffer_unformat(&detach,
-                              SILC_STR_UI16_NSTRING_ALLOC(&channel, NULL),
-                              SILC_STR_UI16_NSTRING(&chid, &chid_len),
-                              SILC_STR_UI_INT(&ch_mode),
-                              SILC_STR_END);
-    if (len == -1)
-      return FALSE;
-
-    /* Add new channel */
-    channel_id = silc_id_str2id(chid, chid_len, SILC_ID_CHANNEL);
-    channel_entry = silc_client_get_channel_by_id(client, conn, channel_id);
-    if (!channel_entry) {
-      channel_entry = silc_client_add_channel(client, conn, channel, ch_mode,
-                                             channel_id);
-    } else {
-      silc_free(channel);
-      silc_free(channel_id);
-    }
-
-    silc_buffer_pull(&detach, len);
-  }
-  silc_buffer_push(&detach, detach.data - detach.head);
-
-  return TRUE;
-}
-
-
-/* Resume session context */
-typedef struct {
-  SilcClient client;
-  SilcClientConnection conn;
-  SilcClientResumeSessionCallback callback;
-  void *context;
-  SilcUInt32 channel_count;
-  SilcUInt32 *cmd_idents;
-  SilcUInt32 cmd_idents_count;
-  bool success;
-} *SilcClientResumeSession;
-
-/* Generic command reply callback. */
-
-SILC_CLIENT_CMD_REPLY_FUNC(resume)
-{
-  SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
-  SILC_LOG_DEBUG(("Start"));
-  SILC_CLIENT_PENDING_EXEC(cmd, silc_command_get(cmd->payload));
-}
-
-/* Special command reply callback for IDENTIFY callbacks.  This calls
-   the pending callback for every returned command entry. */
-
-SILC_CLIENT_CMD_REPLY_FUNC(resume_special)
-{
-  SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
-  int i;
-
-  SILC_LOG_DEBUG(("Start"));
-  for (i = 0; i < cmd->callbacks_count; i++)
-    if (cmd->callbacks[i].callback)
-      (*cmd->callbacks[i].callback)(cmd->callbacks[i].context, cmd);
-}
-
-/* Completion calling callback */
-
-SILC_TASK_CALLBACK(silc_client_resume_call_completion)
-{
-  SilcClientResumeSession session = context;
-  int i;
-
-  session->callback(session->client, session->conn, session->success,
-                   session->context);
-
-  for (i = 0; i < session->cmd_idents_count; i++)
-    silc_client_command_pending_del(session->conn, SILC_COMMAND_IDENTIFY, 
-                                   session->cmd_idents[i]);
-  silc_free(session->cmd_idents);
-
-  memset(session, 'F', sizeof(*session));
-  silc_free(session);
-}
-
-/* This function is used to perform the resuming procedure after the
-   client has connected to the server properly and has received the
-   Client ID for the resumed session.  This resolves all channels
-   that the resumed client is joined, joined users, users modes
-   and channel modes.  The `callback' is called after this procedure
-   is completed. */
-
-void silc_client_resume_session(SilcClient client,
-                               SilcClientConnection conn,
-                               SilcClientResumeSessionCallback callback,
-                               void *context)
-{
-  SilcClientResumeSession session;
-  SilcIDCacheList list;
-  SilcIDCacheEntry entry;
-  SilcChannelEntry channel;
-  SilcBuffer tmp;
-  int i;
-  bool ret;
-
-  SILC_LOG_DEBUG(("Resuming detached session"));
-
-  session = silc_calloc(1, sizeof(*session));
-  if (!session) {
-    callback(client, conn, FALSE, context);
-    return;
-  }
-  session->client = client;
-  session->conn = conn;
-  session->callback = callback;
-  session->context = context;
-
-  /* First, send UMODE commandto get our own user mode in the network */
-  SILC_LOG_DEBUG(("Sending UMODE"));
-  tmp = silc_id_payload_encode(conn->local_entry->id, SILC_ID_CLIENT);
-  silc_client_command_send(client, conn, SILC_COMMAND_UMODE,
-                          conn->cmd_ident, 1, 1, tmp->data, tmp->len);
-  silc_buffer_free(tmp);
-
-  /* Second, send IDENTIFY command of all channels we know about.  These
-     are the channels we've joined to according our detachment data. */
-  if (silc_idcache_get_all(conn->channel_cache, &list)) {
-    unsigned char **res_argv = NULL;
-    SilcUInt32 *res_argv_lens = NULL, *res_argv_types = NULL, res_argc = 0;
-
-    session->channel_count = silc_idcache_list_count(list);
-
-    ret = silc_idcache_list_first(list, &entry);
-    while (ret) {
-      channel = entry->context;
-      tmp = silc_id_payload_encode(channel->id, SILC_ID_CHANNEL);
-      res_argv = silc_realloc(res_argv, sizeof(*res_argv) * (res_argc + 1));
-      res_argv_lens = silc_realloc(res_argv_lens, sizeof(*res_argv_lens) *
-                                  (res_argc + 1));
-      res_argv_types = silc_realloc(res_argv_types, sizeof(*res_argv_types) *
-                                   (res_argc + 1));
-      res_argv[res_argc] = silc_memdup(tmp->data, tmp->len);
-      res_argv_lens[res_argc] = tmp->len;
-      res_argv_types[res_argc] = res_argc + 5;
-      res_argc++;
-      silc_buffer_free(tmp);
-      ret = silc_idcache_list_next(list, &entry);
-    }
-    silc_idcache_list_free(list);
-
-    if (res_argc) {
-      /* Send the IDENTIFY command */
-      SILC_LOG_DEBUG(("Sending IDENTIFY"));
-      silc_client_command_register(client, SILC_COMMAND_IDENTIFY, NULL, NULL,
-                                  silc_client_command_reply_resume_special,
-                                  0, ++conn->cmd_ident);
-      silc_client_command_pending(conn, SILC_COMMAND_IDENTIFY, 
-                                 conn->cmd_ident,
-                                 silc_client_command_resume_identify,
-                                 session);
-
-      tmp = silc_command_payload_encode(SILC_COMMAND_IDENTIFY,
-                                       res_argc, res_argv, res_argv_lens,
-                                       res_argv_types, conn->cmd_ident);
-      silc_client_packet_send(client, conn->sock, SILC_PACKET_COMMAND, 
-                             NULL, 0, NULL, NULL, tmp->data, tmp->len, TRUE);
-
-      session->cmd_idents = silc_realloc(session->cmd_idents,
-                                        sizeof(*session->cmd_idents) *
-                                        (session->cmd_idents_count + 1));
-      session->cmd_idents[session->cmd_idents_count] = conn->cmd_ident;
-      session->cmd_idents_count++;
-
-      for (i = 0; i < res_argc; i++)
-       silc_free(res_argv[i]);
-      silc_free(res_argv);
-      silc_free(res_argv_lens);
-      silc_free(res_argv_types);
-      silc_buffer_free(tmp);
-    }
-  }
-
-  /* Now, we wait for replies to come back and then continue with USERS,
-     CMODE and TOPIC commands. */
-}
-
-/* Received identify reply for a channel entry */
-
-SILC_CLIENT_CMD_FUNC(resume_identify)
-{
-  SilcClientResumeSession session = context;
-  SilcClientCommandReplyContext cmd = context2;
-  SilcClient client = session->client;
-  SilcClientConnection conn = session->conn;
-  unsigned char *tmp;
-  SilcUInt32 tmp_len;
-  SilcChannelEntry channel = NULL;
-  SilcChannelID *channel_id;
-  SilcIDPayload idp;
-  SilcIdType id_type;
-
-  SILC_LOG_DEBUG(("Start"));
-
-  tmp = silc_argument_get_arg_type(cmd->args, 2, &tmp_len);
-  if (!tmp)
-    goto err;
-
-  if (cmd->error != SILC_STATUS_OK) {
-    /* Delete unknown channel from our cache */
-    if (cmd->error == SILC_STATUS_ERR_NO_SUCH_CHANNEL_ID) {
-      channel_id = silc_id_payload_parse_id(tmp, tmp_len, NULL);
-      if (channel_id) {
-       channel = silc_client_get_channel_by_id(client, conn, channel_id);
-       if (channel)
-         silc_client_del_channel(client, conn, channel);
-       silc_free(channel_id);
-      }
-    }
-    goto err;
-  }
-
-  idp = silc_id_payload_parse(tmp, tmp_len);
-  if (!idp) {
-    return;
-  }
-  id_type = silc_id_payload_get_type(idp);
-
-  switch (id_type) {
-  case SILC_ID_CHANNEL:
-    channel_id = silc_id_payload_get_id(idp);
-    channel = silc_client_get_channel_by_id(client, conn, channel_id);
-    silc_free(channel_id);
-    break;
-  default:
-    silc_id_payload_free(idp);
-    goto err;
-    break;
-  }
-
-  /* Now, send CMODE command for this channel.  We send only this one
-     because this will return also error if we are not currently joined
-     on this channel, plus we get the channel mode.  USERS and TOPIC
-     commands are called after this returns. */
-  if (channel) {
-    SILC_LOG_DEBUG(("Sending CMODE"));
-    silc_client_command_register(client, SILC_COMMAND_CMODE, NULL, NULL,
-                                silc_client_command_reply_resume, 0,
-                                ++conn->cmd_ident);
-    silc_client_command_send(client, conn, SILC_COMMAND_CMODE,
-                            conn->cmd_ident, 1, 1, tmp, tmp_len);
-    silc_client_command_pending(conn, SILC_COMMAND_CMODE, conn->cmd_ident,
-                               silc_client_command_resume_cmode, session);
-  }
-
-  silc_id_payload_free(idp);
-
-  if (cmd->status != SILC_STATUS_OK &&
-      cmd->status != SILC_STATUS_LIST_END)
-    return;
-
-  /* Unregister this command reply */
-  silc_client_command_unregister(client, SILC_COMMAND_IDENTIFY, NULL, 
-                                silc_client_command_reply_resume,
-                                cmd->ident);
-  return;
-
- err:
-  session->channel_count--;
-  if (!session->channel_count)
-    RESUME_CALL_COMPLETION(client, session, FALSE);
-}
-
-/* Received cmode to channel entry */
-
-SILC_CLIENT_CMD_FUNC(resume_cmode)
-{
-  SilcClientResumeSession session = context;
-  SilcClientCommandReplyContext cmd = context2;
-  SilcClient client = session->client;
-  SilcClientConnection conn = session->conn;
-  unsigned char *tmp;
-  SilcChannelID *channel_id;
-  SilcChannelEntry channel;
-  SilcUInt32 len;
-
-  SILC_LOG_DEBUG(("Start"));
-
-  /* Unregister this command reply */
-  silc_client_command_unregister(client, SILC_COMMAND_CMODE, NULL, 
-                                silc_client_command_reply_resume,
-                                cmd->ident);
-
-  if (cmd->error != SILC_STATUS_OK)
-    goto err;
-
-  /* Take Channel ID */
-  tmp = silc_argument_get_arg_type(cmd->args, 2, &len);
-  if (!tmp)
-    goto err;
-  channel_id = silc_id_payload_parse_id(tmp, len, NULL);
-  if (!channel_id)
-    goto err;
-
-  /* Get the channel entry */
-  channel = silc_client_get_channel_by_id(cmd->client, conn, channel_id);
-  if (channel) {
-
-    /* Get channel mode */
-    tmp = silc_argument_get_arg_type(cmd->args, 3, NULL);
-    if (tmp)
-      SILC_GET32_MSB(channel->mode, tmp);
-
-    tmp = silc_argument_get_arg_type(cmd->args, 2, &len);
-
-    /* And now, we will send USERS to get users on the channel */
-    SILC_LOG_DEBUG(("Sending USERS"));
-    silc_client_command_register(client, SILC_COMMAND_USERS, NULL, NULL,
-                                silc_client_command_reply_users_i, 0,
-                                ++conn->cmd_ident);
-    silc_client_command_send(client, conn, SILC_COMMAND_USERS,
-                            conn->cmd_ident, 1, 1, tmp, len);
-    silc_client_command_pending(conn, SILC_COMMAND_USERS, conn->cmd_ident,
-                               silc_client_command_resume_users, session);
-  }
-
-  silc_free(channel_id);
-  return;
-
- err:
-  session->channel_count--;
-  if (!session->channel_count)
-    RESUME_CALL_COMPLETION(client, session, FALSE);
-}
-
-/* Received users reply to a channel entry */
-
-SILC_CLIENT_CMD_FUNC(resume_users)
-{
-  SilcClientResumeSession session = context;
-  SilcClientCommandReplyContext cmd = context2;
-  SilcClient client = session->client;
-  SilcClientConnection conn = session->conn;
-  SilcBufferStruct client_id_list, client_mode_list;
-  unsigned char *tmp;
-  SilcUInt32 tmp_len, list_count;
-  SilcChannelEntry channel;
-  SilcChannelID *channel_id = NULL;
-
-  SILC_LOG_DEBUG(("Start"));
-
-  /* Unregister this command reply */
-  silc_client_command_unregister(client, SILC_COMMAND_USERS, NULL, 
-                                silc_client_command_reply_users_i,
-                                cmd->ident);
-
-  if (cmd->error != SILC_STATUS_OK)
-    goto err;
-
-  /* Get channel ID */
-  tmp = silc_argument_get_arg_type(cmd->args, 2, &tmp_len);
-  if (!tmp) {
-    COMMAND_REPLY_ERROR;
-    goto err;
-  }
-  channel_id = silc_id_payload_parse_id(tmp, tmp_len, NULL);
-  if (!channel_id) {
-    COMMAND_REPLY_ERROR;
-    goto err;
-  }
-
-  /* Get the list count */
-  tmp = silc_argument_get_arg_type(cmd->args, 3, &tmp_len);
-  if (!tmp) {
-    COMMAND_REPLY_ERROR;
-    goto err;
-  }
-  SILC_GET32_MSB(list_count, tmp);
-
-  /* Get Client ID list */
-  tmp = silc_argument_get_arg_type(cmd->args, 4, &tmp_len);
-  if (!tmp) {
-    COMMAND_REPLY_ERROR;
-    goto err;
-  }
-  silc_buffer_set(&client_id_list, tmp, tmp_len);
-
-  /* Get client mode list */
-  tmp = silc_argument_get_arg_type(cmd->args, 5, &tmp_len);
-  if (!tmp) {
-    COMMAND_REPLY_ERROR;
-    goto err;
-  }
-  silc_buffer_set(&client_mode_list, tmp, tmp_len);
-
-  /* Get channel entry */
-  channel = silc_client_get_channel_by_id(cmd->client, conn, channel_id);
-  if (!channel)
-    goto err;
-
-  /* Send fake JOIN command reply to application */
-  client->internal->ops->command_reply(client, conn, cmd->payload, TRUE,
-                                      SILC_COMMAND_JOIN, cmd->status,
-                                      channel->channel_name, channel,
-                                      channel->mode, 0, 
-                                      NULL, NULL, NULL, NULL, 
-                                      channel->hmac, list_count,
-                                      &client_id_list, client_mode_list);
-
-  /* Send TOPIC for this channel to get the topic */
-  SILC_LOG_DEBUG(("Sending TOPIC"));
-  tmp = silc_argument_get_arg_type(cmd->args, 2, &tmp_len);
-  silc_client_command_send(client, conn, SILC_COMMAND_TOPIC,
-                          ++conn->cmd_ident, 1, 1, tmp, tmp_len);
-
-  /* Call the completion callback after we've got reply to all of
-     our channels */
-  session->channel_count--;
-  if (!session->channel_count)
-    RESUME_CALL_COMPLETION(client, session, TRUE);
-
-  silc_free(channel_id);
-  return;
-
- err:
-  silc_free(channel_id);
-  session->channel_count--;
-  if (!session->channel_count)
-    RESUME_CALL_COMPLETION(client, session, FALSE);
-}
index 1e829efa368a0ae4b9b700d873ef7d936f854856..c0c058d00aa865054db8f0cd17ff918ed946c2ea 100644 (file)
@@ -86,13 +86,10 @@ void silc_client_command_call(SilcClientCommand command,
 }
 
 /* Add new pending command to be executed when reply to a command has been
-   received. The `reply_cmd' is the command that will call the `callback'
-   with `context' when reply has been received.  It can be SILC_COMMAND_NONE
-   to match any command with the `ident'.  If `ident' is non-zero
-   the `callback' will be executed when received reply with command
-   identifier `ident'. If there already exists pending command for the
-   specified command, ident, callback and context this function has no
-   effect. */
+   received.  The `reply_cmd' is the command that will call the `callback'
+   with `context' when reply has been received.  If `ident is non-zero
+   the `callback' will be executed when received reply with command 
+   identifier `ident'. */
 
 void silc_client_command_pending(SilcClientConnection conn,
                                 SilcCommand reply_cmd,
@@ -102,16 +99,6 @@ void silc_client_command_pending(SilcClientConnection conn,
 {
   SilcClientCommandPending *reply;
 
-  /* Check whether identical pending already exists for same command,
-     ident, callback and callback context. If it does then it would be
-     error to register it again. */
-  silc_dlist_start(conn->pending_commands);
-  while ((reply = silc_dlist_get(conn->pending_commands)) != SILC_LIST_END) {
-    if (reply->reply_cmd == reply_cmd && reply->ident == ident &&
-       reply->callback == callback && reply->context == context)
-      return;
-  }
-
   reply = silc_calloc(1, sizeof(*reply));
   reply->reply_cmd = reply_cmd;
   reply->ident = ident;
@@ -138,33 +125,26 @@ void silc_client_command_pending_del(SilcClientConnection conn,
 }
 
 /* Checks for pending commands and marks callbacks to be called from
-   the command reply function. */
-
-SilcClientCommandPendingCallbacks
-silc_client_command_pending_check(SilcClientConnection conn,
-                                 SilcClientCommandReplyContext ctx,
-                                 SilcCommand command, 
-                                 SilcUInt16 ident,
-                                 SilcUInt32 *callbacks_count)
+   the command reply function. Returns TRUE if there were pending command. */
+
+int silc_client_command_pending_check(SilcClientConnection conn,
+                                     SilcClientCommandReplyContext ctx,
+                                     SilcCommand command, 
+                                     SilcUInt16 ident)
 {
   SilcClientCommandPending *r;
-  SilcClientCommandPendingCallbacks callbacks = NULL;
-  int i = 0;
 
   silc_dlist_start(conn->pending_commands);
   while ((r = silc_dlist_get(conn->pending_commands)) != SILC_LIST_END) {
-    if ((r->reply_cmd == command || r->reply_cmd == SILC_COMMAND_NONE)
-       && r->ident == ident) {
-      callbacks = silc_realloc(callbacks, sizeof(*callbacks) * (i + 1));
-      callbacks[i].context = r->context;
-      callbacks[i].callback = r->callback;
+    if (r->reply_cmd == command && r->ident == ident) {
+      ctx->context = r->context;
+      ctx->callback = r->callback;
       ctx->ident = ident;
-      i++;
+      return TRUE;
     }
   }
 
-  *callbacks_count = i;
-  return callbacks;
+  return FALSE;
 }
 
 /* Allocate Command Context */
@@ -342,9 +322,8 @@ SILC_CLIENT_CMD_FUNC(nick_change)
   SilcClientConnection conn = cmd->conn;
   SilcClientCommandReplyContext reply = 
     (SilcClientCommandReplyContext)context2;
-  SilcCommandStatus status;
+  SilcCommandStatus status = silc_command_get_status(reply->payload);
 
-  silc_command_get_status(reply->payload, &status, NULL);
   if (status == SILC_STATUS_OK) {
     /* Set the nickname */
     silc_idcache_del_by_context(conn->client_cache, conn->local_entry);
@@ -684,7 +663,7 @@ SILC_TASK_CALLBACK(silc_client_command_quit_cb)
 
   /* Close connection */
   q->client->internal->ops->disconnect(q->client, q->conn);
-  silc_client_close_connection(q->client, q->conn->sock->user_data);
+  silc_client_close_connection(q->client, NULL, q->conn->sock->user_data);
 
   silc_free(q);
 }
@@ -769,9 +748,8 @@ SILC_CLIENT_CMD_FUNC(kill_remove)
   SilcClientCommandContext cmd = (SilcClientCommandContext)context;
   SilcClientCommandReplyContext reply = 
     (SilcClientCommandReplyContext)context2;
-  SilcCommandStatus status;
+  SilcCommandStatus status = silc_command_get_status(reply->payload);
 
-  silc_command_get_status(reply->payload, &status, NULL);
   if (status == SILC_STATUS_OK) {
     /* Remove with timeout */
     silc_schedule_task_add(cmd->client->schedule, cmd->conn->sock->sock,
@@ -970,8 +948,8 @@ SILC_CLIENT_CMD_FUNC(join)
   SilcClientConnection conn = cmd->conn;
   SilcChannelEntry channel;
   SilcBuffer buffer, idp, auth = NULL;
-  char *name, *passphrase = NULL, *pu8, *cipher = NULL, *hmac = NULL;
-  int i, passphrase_len = 0;
+  char *name, *passphrase = NULL, *cipher = NULL, *hmac = NULL;
+  int i;
 
   if (!cmd->conn) {
     SILC_NOT_CONNECTED(cmd->client, cmd->conn);
@@ -1017,18 +995,7 @@ SILC_CLIENT_CMD_FUNC(join)
       }
       i++;
     } else {
-      /* Passphrases must be UTF-8 encoded, so encode if it is not */
-      if (!silc_utf8_valid(cmd->argv[i], cmd->argv_lens[i])) {
-       passphrase_len = silc_utf8_encoded_len(cmd->argv[i], 
-                                              cmd->argv_lens[i], 0);
-       pu8 = silc_calloc(passphrase_len, sizeof(*pu8));
-       passphrase_len = silc_utf8_encode(cmd->argv[i], cmd->argv_lens[i],
-                                         0, pu8, passphrase_len);
-       passphrase = pu8;
-      } else {
-       passphrase = strdup(cmd->argv[i]);
-       passphrase_len = cmd->argv_lens[i];
-      }
+      passphrase = cmd->argv[i];
     }
   }
 
@@ -1037,7 +1004,8 @@ SILC_CLIENT_CMD_FUNC(join)
     silc_command_payload_encode_va(SILC_COMMAND_JOIN, 0, 6,
                                   1, name, strlen(name),
                                   2, idp->data, idp->len,
-                                  3, passphrase, passphrase_len,
+                                  3, passphrase, 
+                                  passphrase ? strlen(passphrase) : 0,
                                   4, cipher, cipher ? strlen(cipher) : 0,
                                   5, hmac, hmac ? strlen(hmac) : 0,
                                   6, auth ? auth->data : NULL,
@@ -1048,7 +1016,6 @@ SILC_CLIENT_CMD_FUNC(join)
   silc_buffer_free(idp);
   if (auth)
     silc_buffer_free(auth);
-  silc_free(passphrase);
 
   /* Notify application */
   COMMAND;
@@ -1163,42 +1130,6 @@ SILC_CLIENT_CMD_FUNC(umode)
       else
        mode &= ~SILC_UMODE_GONE;
       break;
-    case 'i':
-      if (add)
-       mode |= SILC_UMODE_INDISPOSED;
-      else
-       mode &= ~SILC_UMODE_INDISPOSED;
-      break;
-    case 'b':
-      if (add)
-       mode |= SILC_UMODE_BUSY;
-      else
-       mode &= ~SILC_UMODE_BUSY;
-      break;
-    case 'p':
-      if (add)
-       mode |= SILC_UMODE_PAGE;
-      else
-       mode &= ~SILC_UMODE_PAGE;
-      break;
-    case 'h':
-      if (add)
-       mode |= SILC_UMODE_HYPER;
-      else
-       mode &= ~SILC_UMODE_HYPER;
-      break;
-    case 't':
-      if (add)
-       mode |= SILC_UMODE_ROBOT;
-      else
-       mode &= ~SILC_UMODE_ROBOT;
-      break;
-    case 'P':
-      if (add)
-       mode |= SILC_UMODE_BLOCK_PRIVMSG;
-      else
-       mode &= ~SILC_UMODE_BLOCK_PRIVMSG;
-      break;
     default:
       COMMAND_ERROR;
       goto out;
@@ -1321,18 +1252,6 @@ SILC_CLIENT_CMD_FUNC(cmode)
       else
        mode &= ~SILC_CHANNEL_MODE_TOPIC;
       break;
-    case 'm':
-      if (add)
-       mode |= SILC_CHANNEL_MODE_SILENCE_USERS;
-      else
-       mode &= ~SILC_CHANNEL_MODE_SILENCE_USERS;
-      break;
-    case 'M':
-      if (add)
-       mode |= SILC_CHANNEL_MODE_SILENCE_OPERS;
-      else
-       mode &= ~SILC_CHANNEL_MODE_SILENCE_OPERS;
-      break;
     case 'l':
       if (add) {
        int ll;
@@ -1564,7 +1483,6 @@ SILC_CLIENT_CMD_FUNC(cumode)
       if (add) {
        mode |= SILC_CHANNEL_UMODE_CHANFO;
        mode |= SILC_CHANNEL_UMODE_CHANOP;
-       mode |= SILC_CHANNEL_UMODE_BLOCK_MESSAGES;
       } else {
        mode = SILC_CHANNEL_UMODE_NONE;
       }
@@ -1595,12 +1513,6 @@ SILC_CLIENT_CMD_FUNC(cumode)
       else
        mode &= ~SILC_CHANNEL_UMODE_CHANOP;
       break;
-    case 'b':
-      if (add)
-       mode |= SILC_CHANNEL_UMODE_BLOCK_MESSAGES;
-      else
-       mode &= ~SILC_CHANNEL_UMODE_BLOCK_MESSAGES;
-      break;
     default:
       COMMAND_ERROR;
       goto out;
@@ -1806,8 +1718,7 @@ SILC_CLIENT_CMD_FUNC(oper)
 }
 
 static void silc_client_command_silcoper_send(unsigned char *data,
-                                             SilcUInt32 data_len, 
-                                             void *context)
+                                             SilcUInt32 data_len, void *context)
 {
   SilcClientCommandContext cmd = (SilcClientCommandContext)context;
   SilcClientConnection conn = cmd->conn;
@@ -1874,6 +1785,54 @@ SILC_CLIENT_CMD_FUNC(silcoper)
   silc_client_command_free(cmd);
 }
 
+/* CONNECT command. Connects the server to another server. */
+
+SILC_CLIENT_CMD_FUNC(connect)
+{
+  SilcClientCommandContext cmd = (SilcClientCommandContext)context;
+  SilcClientConnection conn = cmd->conn;
+  SilcBuffer buffer;
+  unsigned char port[4];
+  SilcUInt32 tmp;
+
+  if (!cmd->conn) {
+    SILC_NOT_CONNECTED(cmd->client, cmd->conn);
+    COMMAND_ERROR;
+    goto out;
+  }
+
+  if (cmd->argc < 2) {
+    SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, 
+       "Usage: /CONNECT <server> [<port>]");
+    COMMAND_ERROR;
+    goto out;
+  }
+
+  if (cmd->argc == 3) {
+    tmp = atoi(cmd->argv[2]);
+    SILC_PUT32_MSB(tmp, port);
+  }
+
+  if (cmd->argc == 3)
+    buffer = silc_command_payload_encode_va(SILC_COMMAND_CONNECT, 0, 2, 
+                                           1, cmd->argv[1], 
+                                           strlen(cmd->argv[1]),
+                                           2, port, 4);
+  else
+    buffer = silc_command_payload_encode_va(SILC_COMMAND_CONNECT, 0, 1,
+                                           1, cmd->argv[1], 
+                                           strlen(cmd->argv[1]));
+  silc_client_packet_send(cmd->client, conn->sock, SILC_PACKET_COMMAND, NULL,
+                         0, NULL, NULL, buffer->data, buffer->len, TRUE);
+  silc_buffer_free(buffer);
+
+  /* Notify application */
+  COMMAND;
+
+ out:
+  silc_client_command_free(cmd);
+}
+
 /* Command BAN. This is used to manage the ban list of the channel. */
 
 SILC_CLIENT_CMD_FUNC(ban)
@@ -1933,10 +1892,14 @@ SILC_CLIENT_CMD_FUNC(ban)
   chidp = silc_id_payload_encode(channel->id, SILC_ID_CHANNEL);
 
   /* Send the command */
-  buffer = silc_command_payload_encode_va(SILC_COMMAND_BAN, 
-                                         ++conn->cmd_ident, 2,
-                                         1, chidp->data, chidp->len,
-                                         type, ban, ban ? strlen(ban) : 0);
+  if (ban)
+    buffer = silc_command_payload_encode_va(SILC_COMMAND_BAN, 0, 2, 
+                                           1, chidp->data, chidp->len,
+                                           type, ban, strlen(ban));
+  else
+    buffer = silc_command_payload_encode_va(SILC_COMMAND_BAN, 0, 1, 
+                                           1, chidp->data, chidp->len);
+
   silc_client_packet_send(cmd->client, conn->sock, SILC_PACKET_COMMAND, NULL, 
                          0, NULL, NULL, buffer->data, buffer->len, TRUE);
   silc_buffer_free(buffer);
@@ -1949,13 +1912,15 @@ SILC_CLIENT_CMD_FUNC(ban)
   silc_client_command_free(cmd);
 }
 
-/* Command DETACH. This is used to detach from the server */
-
-SILC_CLIENT_CMD_FUNC(detach)
+/* CLOSE command. Close server connection to the remote server */
+SILC_CLIENT_CMD_FUNC(close)
 {
   SilcClientCommandContext cmd = (SilcClientCommandContext)context;
   SilcClientConnection conn = cmd->conn;
   SilcBuffer buffer;
+  unsigned char port[4];
+  SilcUInt32 tmp;
 
   if (!cmd->conn) {
     SILC_NOT_CONNECTED(cmd->client, cmd->conn);
@@ -1963,9 +1928,28 @@ SILC_CLIENT_CMD_FUNC(detach)
     goto out;
   }
 
-  buffer = silc_command_payload_encode_va(SILC_COMMAND_DETACH,
-                                         ++conn->cmd_ident, 0);
-  silc_client_packet_send(cmd->client, conn->sock, SILC_PACKET_COMMAND, NULL, 
+  if (cmd->argc < 2) {
+    SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, 
+       "Usage: /CLOSE <server> [<port>]");
+    COMMAND_ERROR;
+    goto out;
+  }
+
+  if (cmd->argc == 3) {
+    tmp = atoi(cmd->argv[2]);
+    SILC_PUT32_MSB(tmp, port);
+  }
+
+  if (cmd->argc == 3)
+    buffer = silc_command_payload_encode_va(SILC_COMMAND_CLOSE, 0, 2, 
+                                           1, cmd->argv[1], 
+                                           strlen(cmd->argv[1]),
+                                           2, port, 4);
+  else
+    buffer = silc_command_payload_encode_va(SILC_COMMAND_CLOSE, 0, 1,
+                                           1, cmd->argv[1], 
+                                           strlen(cmd->argv[1]));
+  silc_client_packet_send(cmd->client, conn->sock, SILC_PACKET_COMMAND, NULL,
                          0, NULL, NULL, buffer->data, buffer->len, TRUE);
   silc_buffer_free(buffer);
 
@@ -1975,6 +1959,29 @@ SILC_CLIENT_CMD_FUNC(detach)
  out:
   silc_client_command_free(cmd);
 }
+/* SHUTDOWN command. Shutdowns the server. */
+
+SILC_CLIENT_CMD_FUNC(shutdown)
+{
+  SilcClientCommandContext cmd = (SilcClientCommandContext)context;
+
+  if (!cmd->conn) {
+    SILC_NOT_CONNECTED(cmd->client, cmd->conn);
+    COMMAND_ERROR;
+    goto out;
+  }
+
+  /* Send the command */
+  silc_client_command_send(cmd->client, cmd->conn, 
+                          SILC_COMMAND_SHUTDOWN, 0, 0);
+
+  /* Notify application */
+  COMMAND;
+
+ out:
+  silc_client_command_free(cmd);
+}
 
 /* LEAVE command. Leaves a channel. Client removes itself from a channel. */
 
@@ -2158,11 +2165,10 @@ SILC_CLIENT_CMD_FUNC(getkey)
       } else {
        SilcClientCommandReplyContext reply = 
          (SilcClientCommandReplyContext)context2;
-       SilcCommandStatus error;
-
+       SilcCommandStatus status = silc_command_get_status(reply->payload);
+       
        /* If nickname was not found, then resolve the server. */
-       silc_command_get_status(reply->payload, NULL, &error);
-       if (error == SILC_STATUS_ERR_NO_SUCH_NICK) {
+       if (status == SILC_STATUS_ERR_NO_SUCH_NICK) {
          /* This sends the IDENTIFY command to resolve the server. */
          silc_client_command_register(client, SILC_COMMAND_IDENTIFY, 
                                       NULL, NULL,
@@ -2180,11 +2186,11 @@ SILC_CLIENT_CMD_FUNC(getkey)
 
        /* If server was not found, then we've resolved both nickname and
           server and did not find anybody. */
-       if (error == SILC_STATUS_ERR_NO_SUCH_SERVER) {
+       if (status == SILC_STATUS_ERR_NO_SUCH_SERVER) {
          SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, "%s", 
             silc_client_command_status_message(SILC_STATUS_ERR_NO_SUCH_NICK));
          SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, "%s", 
-           silc_client_command_status_message(error));
+           silc_client_command_status_message(status));
          COMMAND_ERROR;
          goto out;
        }
@@ -2276,129 +2282,6 @@ bool silc_client_command_unregister(SilcClient client,
   return FALSE;
 }
 
-/* Private range commands, specific to this implementation (and compatible
-   with SILC Server). */
-
-/* CONNECT command. Connects the server to another server. */
-
-SILC_CLIENT_CMD_FUNC(connect)
-{
-  SilcClientCommandContext cmd = (SilcClientCommandContext)context;
-  SilcClientConnection conn = cmd->conn;
-  SilcBuffer buffer;
-  unsigned char port[4];
-  SilcUInt32 tmp;
-
-  if (!cmd->conn) {
-    SILC_NOT_CONNECTED(cmd->client, cmd->conn);
-    COMMAND_ERROR;
-    goto out;
-  }
-
-  if (cmd->argc < 2) {
-    SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, 
-       "Usage: /CONNECT <server> [<port>]");
-    COMMAND_ERROR;
-    goto out;
-  }
-
-  if (cmd->argc == 3) {
-    tmp = atoi(cmd->argv[2]);
-    SILC_PUT32_MSB(tmp, port);
-  }
-
-  if (cmd->argc == 3)
-    buffer = silc_command_payload_encode_va(SILC_COMMAND_PRIV_CONNECT, 0, 2, 
-                                           1, cmd->argv[1], 
-                                           strlen(cmd->argv[1]),
-                                           2, port, 4);
-  else
-    buffer = silc_command_payload_encode_va(SILC_COMMAND_PRIV_CONNECT, 0, 1,
-                                           1, cmd->argv[1], 
-                                           strlen(cmd->argv[1]));
-  silc_client_packet_send(cmd->client, conn->sock, SILC_PACKET_COMMAND, NULL,
-                         0, NULL, NULL, buffer->data, buffer->len, TRUE);
-  silc_buffer_free(buffer);
-
-  /* Notify application */
-  COMMAND;
-
- out:
-  silc_client_command_free(cmd);
-}
-
-
-/* CLOSE command. Close server connection to the remote server */
-SILC_CLIENT_CMD_FUNC(close)
-{
-  SilcClientCommandContext cmd = (SilcClientCommandContext)context;
-  SilcClientConnection conn = cmd->conn;
-  SilcBuffer buffer;
-  unsigned char port[4];
-  SilcUInt32 tmp;
-
-  if (!cmd->conn) {
-    SILC_NOT_CONNECTED(cmd->client, cmd->conn);
-    COMMAND_ERROR;
-    goto out;
-  }
-
-  if (cmd->argc < 2) {
-    SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_INFO, 
-       "Usage: /CLOSE <server> [<port>]");
-    COMMAND_ERROR;
-    goto out;
-  }
-
-  if (cmd->argc == 3) {
-    tmp = atoi(cmd->argv[2]);
-    SILC_PUT32_MSB(tmp, port);
-  }
-
-  if (cmd->argc == 3)
-    buffer = silc_command_payload_encode_va(SILC_COMMAND_PRIV_CLOSE, 0, 2, 
-                                           1, cmd->argv[1], 
-                                           strlen(cmd->argv[1]),
-                                           2, port, 4);
-  else
-    buffer = silc_command_payload_encode_va(SILC_COMMAND_PRIV_CLOSE, 0, 1,
-                                           1, cmd->argv[1], 
-                                           strlen(cmd->argv[1]));
-  silc_client_packet_send(cmd->client, conn->sock, SILC_PACKET_COMMAND, NULL,
-                         0, NULL, NULL, buffer->data, buffer->len, TRUE);
-  silc_buffer_free(buffer);
-
-  /* Notify application */
-  COMMAND;
-
- out:
-  silc_client_command_free(cmd);
-}
-/* SHUTDOWN command. Shutdowns the server. */
-
-SILC_CLIENT_CMD_FUNC(shutdown)
-{
-  SilcClientCommandContext cmd = (SilcClientCommandContext)context;
-
-  if (!cmd->conn) {
-    SILC_NOT_CONNECTED(cmd->client, cmd->conn);
-    COMMAND_ERROR;
-    goto out;
-  }
-
-  /* Send the command */
-  silc_client_command_send(cmd->client, cmd->conn, 
-                          SILC_COMMAND_PRIV_SHUTDOWN, 0, 0);
-
-  /* Notify application */
-  COMMAND;
-
- out:
-  silc_client_command_free(cmd);
-}
-
 /* Register all default commands provided by the client library for the
    application. */
 
@@ -2417,6 +2300,7 @@ void silc_client_commands_register(SilcClient client)
   SILC_CLIENT_CMD(quit, QUIT, "QUIT", 2);
   SILC_CLIENT_CMD(kill, KILL, "KILL", 3);
   SILC_CLIENT_CMD(info, INFO, "INFO", 2);
+  SILC_CLIENT_CMD(connect, CONNECT, "CONNECT", 3);
   SILC_CLIENT_CMD(ping, PING, "PING", 2);
   SILC_CLIENT_CMD(oper, OPER, "OPER", 3);
   SILC_CLIENT_CMD(join, JOIN, "JOIN", 9);
@@ -2426,15 +2310,12 @@ void silc_client_commands_register(SilcClient client)
   SILC_CLIENT_CMD(cumode, CUMODE, "CUMODE", 5);
   SILC_CLIENT_CMD(kick, KICK, "KICK", 4);
   SILC_CLIENT_CMD(ban, BAN, "BAN", 3);
-  SILC_CLIENT_CMD(detach, DETACH, "DETACH", 0);
+  SILC_CLIENT_CMD(close, CLOSE, "CLOSE", 3);
+  SILC_CLIENT_CMD(shutdown, SHUTDOWN, "SHUTDOWN", 1);
   SILC_CLIENT_CMD(silcoper, SILCOPER, "SILCOPER", 3);
   SILC_CLIENT_CMD(leave, LEAVE, "LEAVE", 2);
   SILC_CLIENT_CMD(users, USERS, "USERS", 2);
   SILC_CLIENT_CMD(getkey, GETKEY, "GETKEY", 2);
-
-  SILC_CLIENT_CMD(connect, PRIV_CONNECT, "CONNECT", 3);
-  SILC_CLIENT_CMD(close, PRIV_CLOSE, "CLOSE", 3);
-  SILC_CLIENT_CMD(shutdown, PRIV_SHUTDOWN, "SHUTDOWN", 1);
 }
 
 /* Unregister all commands. */
@@ -2451,6 +2332,7 @@ void silc_client_commands_unregister(SilcClient client)
   SILC_CLIENT_CMDU(quit, QUIT, "QUIT");
   SILC_CLIENT_CMDU(kill, KILL, "KILL");
   SILC_CLIENT_CMDU(info, INFO, "INFO");
+  SILC_CLIENT_CMDU(connect, CONNECT, "CONNECT");
   SILC_CLIENT_CMDU(ping, PING, "PING");
   SILC_CLIENT_CMDU(oper, OPER, "OPER");
   SILC_CLIENT_CMDU(join, JOIN, "JOIN");
@@ -2460,13 +2342,10 @@ void silc_client_commands_unregister(SilcClient client)
   SILC_CLIENT_CMDU(cumode, CUMODE, "CUMODE");
   SILC_CLIENT_CMDU(kick, KICK, "KICK");
   SILC_CLIENT_CMDU(ban, BAN, "BAN");
-  SILC_CLIENT_CMDU(detach, DETACH, "DETACH");
+  SILC_CLIENT_CMDU(close, CLOSE, "CLOSE");
+  SILC_CLIENT_CMDU(shutdown, SHUTDOWN, "SHUTDOWN");
   SILC_CLIENT_CMDU(silcoper, SILCOPER, "SILCOPER");
   SILC_CLIENT_CMDU(leave, LEAVE, "LEAVE");
   SILC_CLIENT_CMDU(users, USERS, "USERS");
   SILC_CLIENT_CMDU(getkey, GETKEY, "GETKEY");
-
-  SILC_CLIENT_CMDU(connect, PRIV_CONNECT, "CONNECT");
-  SILC_CLIENT_CMDU(close, PRIV_CLOSE, "CLOSE");
-  SILC_CLIENT_CMDU(shutdown, PRIV_SHUTDOWN, "SHUTDOWN");
 }
index 46fb36509bc830781800e32bae61be9ad425e17f..0b8949e15132da54cb230e7e20face8ce73f0354 100644 (file)
@@ -87,13 +87,12 @@ silc_client_command_unregister(client, SILC_COMMAND_##cmd,          \
 void silc_client_command_##func(void *context, void *context2)
 
 /* Executed pending command callback */
-#define SILC_CLIENT_PENDING_EXEC(ctx, cmd)                               \
-do {                                                                     \
-  int _i;                                                                \
-  for (_i = 0; _i < ctx->callbacks_count; _i++)                                  \
-    if (ctx->callbacks[_i].callback)                                     \
-      (*ctx->callbacks[_i].callback)(ctx->callbacks[_i].context, ctx);   \
-  silc_client_command_pending_del(ctx->sock->user_data, cmd, ctx->ident); \
+#define SILC_CLIENT_PENDING_EXEC(ctx, cmd)                             \
+do {                                                                   \
+  if ((ctx)->callback)                                                 \
+    (*ctx->callback)(ctx->context, ctx);                               \
+  silc_client_command_pending_del((ctx)->sock->user_data, (cmd),       \
+                                 (ctx)->ident);                        \
 } while(0)
 
 bool silc_client_command_register(SilcClient client,
@@ -113,12 +112,11 @@ void silc_client_commands_unregister(SilcClient client);
 void silc_client_command_pending_del(SilcClientConnection conn,
                                     SilcCommand reply_cmd,
                                     SilcUInt16 ident);
-SilcClientCommandPendingCallbacks
-silc_client_command_pending_check(SilcClientConnection conn,
-                                 SilcClientCommandReplyContext ctx,
-                                 SilcCommand command, 
-                                 SilcUInt16 ident,
-                                 SilcUInt32 *callbacks_count);
+int silc_client_command_pending_check(SilcClientConnection conn,
+                                     SilcClientCommandReplyContext ctx,
+                                     SilcCommand command, 
+                                     SilcUInt16 ident);
+
 SILC_CLIENT_CMD_FUNC(whois);
 SILC_CLIENT_CMD_FUNC(whowas);
 SILC_CLIENT_CMD_FUNC(identify);
@@ -129,6 +127,7 @@ SILC_CLIENT_CMD_FUNC(invite);
 SILC_CLIENT_CMD_FUNC(quit);
 SILC_CLIENT_CMD_FUNC(kill);
 SILC_CLIENT_CMD_FUNC(info);
+SILC_CLIENT_CMD_FUNC(connect);
 SILC_CLIENT_CMD_FUNC(ping);
 SILC_CLIENT_CMD_FUNC(oper);
 SILC_CLIENT_CMD_FUNC(join);
@@ -138,14 +137,11 @@ SILC_CLIENT_CMD_FUNC(cmode);
 SILC_CLIENT_CMD_FUNC(cumode);
 SILC_CLIENT_CMD_FUNC(kick);
 SILC_CLIENT_CMD_FUNC(ban);
-SILC_CLIENT_CMD_FUNC(detach);
+SILC_CLIENT_CMD_FUNC(close);
+SILC_CLIENT_CMD_FUNC(shutdown);
 SILC_CLIENT_CMD_FUNC(silcoper);
 SILC_CLIENT_CMD_FUNC(leave);
 SILC_CLIENT_CMD_FUNC(users);
 SILC_CLIENT_CMD_FUNC(getkey);
 
-SILC_CLIENT_CMD_FUNC(shutdown);
-SILC_CLIENT_CMD_FUNC(close);
-SILC_CLIENT_CMD_FUNC(connect);
-
 #endif
index 424d3ea2cd9ac1e8993f878e71489b63ed3a52f1..9246831c0788ec5c9665738c01a172e72076f73b 100644 (file)
@@ -79,19 +79,41 @@ const SilcCommandStatusMessage silc_command_status_messages[] = {
 
   { 0, NULL }
 };
+/* Command reply operation that is called at the end of all command replys. 
+   Usage: COMMAND_REPLY((ARGS, argument1, argument2, etc...)), */
+#define COMMAND_REPLY(args) cmd->client->internal->ops->command_reply args
+#define ARGS cmd->client, cmd->sock->user_data,                                \
+             cmd->payload, TRUE, silc_command_get(cmd->payload), cmd->status
+
+/* Error reply to application. Usage: COMMAND_REPLY_ERROR; */
+#define COMMAND_REPLY_ERROR cmd->client->internal->ops->               \
+  command_reply(cmd->client, cmd->sock->user_data, cmd->payload,       \
+  FALSE, silc_command_get(cmd->payload), cmd->status)
 
 #define SAY cmd->client->internal->ops->say
 
-/* All functions that call the COMMAND_CHECK_STATUS macro must have 
-   out: goto label. */
+/* All functions that call the COMMAND_CHECK_STATUS or the
+   COMMAND_CHECK_STATUS_LIST macros must have out: goto label. */
+
+#define COMMAND_CHECK_STATUS                   \
+do {                                           \
+  SILC_LOG_DEBUG(("Start"));                   \
+  if (cmd->status != SILC_STATUS_OK)  {                \
+    COMMAND_REPLY_ERROR;                       \
+    goto out;                                  \
+  }                                            \
+} while(0)
 
-#define COMMAND_CHECK_STATUS                                   \
-do {                                                           \
-  SILC_LOG_DEBUG(("Start"));                                   \
-  if (!silc_command_get_status(cmd->payload, NULL, NULL)) {    \
-    COMMAND_REPLY_ERROR;                                       \
-    goto out;                                                  \
-  }                                                            \
+#define COMMAND_CHECK_STATUS_LIST              \
+do {                                           \
+  SILC_LOG_DEBUG(("Start"));                   \
+  if (cmd->status != SILC_STATUS_OK &&         \
+      cmd->status != SILC_STATUS_LIST_START && \
+      cmd->status != SILC_STATUS_LIST_ITEM &&  \
+      cmd->status != SILC_STATUS_LIST_END) {   \
+    COMMAND_REPLY_ERROR;                       \
+    goto out;                                  \
+  }                                            \
 } while(0)
 
 /* Process received command reply. */
@@ -121,16 +143,15 @@ void silc_client_command_reply_process(SilcClient client,
   ctx->client = client;
   ctx->sock = sock;
   ctx->payload = payload;
+  ctx->status = silc_command_get_status(ctx->payload);
   ctx->args = silc_command_get_args(ctx->payload);
   ctx->packet = packet;
   ctx->ident = silc_command_get_ident(ctx->payload);
-  silc_command_get_status(ctx->payload, &ctx->status, &ctx->error);
 
   /* Check for pending commands and mark to be exeucted */
-  ctx->callbacks =
-    silc_client_command_pending_check(sock->user_data, ctx, 
-                                     silc_command_get(ctx->payload), 
-                                     ctx->ident, &ctx->callbacks_count);
+  silc_client_command_pending_check(sock->user_data, ctx, 
+                                   silc_command_get(ctx->payload), 
+                                   ctx->ident);
 
   /* Execute command reply */
 
@@ -191,16 +212,18 @@ silc_client_command_reply_whois_save(SilcClientCommandReplyContext cmd,
   SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
   SilcClientID *client_id;
   SilcClientEntry client_entry = NULL;
+  int argc;
   SilcUInt32 len;
   unsigned char *id_data, *tmp;
   char *nickname = NULL, *username = NULL;
   char *realname = NULL;
   SilcUInt32 idle = 0, mode = 0;
-  SilcBufferStruct channels, ch_user_modes;
-  bool has_channels = FALSE, has_user_modes = FALSE;
+  SilcBuffer channels = NULL;
   unsigned char *fingerprint;
   SilcUInt32 fingerprint_len;
   
+  argc = silc_argument_get_arg_num(cmd->args);
+
   id_data = silc_argument_get_arg_type(cmd->args, 2, &len);
   if (!id_data) {
     if (notify)
@@ -226,8 +249,9 @@ silc_client_command_reply_whois_save(SilcClientCommandReplyContext cmd,
 
   tmp = silc_argument_get_arg_type(cmd->args, 6, &len);
   if (tmp) {
-    silc_buffer_set(&channels, tmp, len);
-    has_channels = TRUE;
+    channels = silc_buffer_alloc(len);
+    silc_buffer_pull_tail(channels, SILC_BUFFER_END(channels));
+    silc_buffer_put(channels, tmp, len);
   }
 
   tmp = silc_argument_get_arg_type(cmd->args, 7, &len);
@@ -240,12 +264,6 @@ silc_client_command_reply_whois_save(SilcClientCommandReplyContext cmd,
 
   fingerprint = silc_argument_get_arg_type(cmd->args, 9, &fingerprint_len);
 
-  tmp = silc_argument_get_arg_type(cmd->args, 10, &len);
-  if (tmp) {
-    silc_buffer_set(&ch_user_modes, tmp, len);
-    has_user_modes = TRUE;
-  }
-
   /* Check if we have this client cached already. */
   client_entry = silc_client_get_client_by_id(cmd->client, conn, client_id);
   if (!client_entry) {
@@ -268,10 +286,12 @@ silc_client_command_reply_whois_save(SilcClientCommandReplyContext cmd,
     client_entry->status &= ~SILC_CLIENT_STATUS_RESOLVING;
 
   /* Notify application */
-  if (!cmd->callbacks_count && notify)
+  if (!cmd->callback && notify)
     COMMAND_REPLY((ARGS, client_entry, nickname, username, realname, 
-                  has_channels ? &channels : NULL, mode, idle, 
-                  fingerprint, has_user_modes ? &ch_user_modes : NULL));
+                  channels, mode, idle, fingerprint));
+
+  if (channels)
+    silc_buffer_free(channels);
 }
 
 /* Received reply for WHOIS command. This maybe called several times
@@ -282,7 +302,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(whois)
   SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
   SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
 
-  COMMAND_CHECK_STATUS;
+  COMMAND_CHECK_STATUS_LIST;
 
   /* Save WHOIS info */
   silc_client_command_reply_whois_save(cmd, cmd->status, TRUE);
@@ -299,7 +319,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(whois)
 
   /* If we received notify for invalid ID we'll remove the ID if we
      have it cached. */
-  if (cmd->error == SILC_STATUS_ERR_NO_SUCH_CLIENT_ID) {
+  if (cmd->status == SILC_STATUS_ERR_NO_SUCH_CLIENT_ID) {
     SilcClientEntry client_entry;
     SilcUInt32 tmp_len;
     unsigned char *tmp =
@@ -333,7 +353,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(whowas)
   char *nickname, *username;
   char *realname = NULL;
 
-  COMMAND_CHECK_STATUS;
+  COMMAND_CHECK_STATUS_LIST;
 
   id_data = silc_argument_get_arg_type(cmd->args, 2, &len);
   if (!id_data) {
@@ -389,12 +409,15 @@ silc_client_command_reply_identify_save(SilcClientCommandReplyContext cmd,
   SilcClientEntry client_entry;
   SilcServerEntry server_entry;
   SilcChannelEntry channel_entry;
+  int argc;
   SilcUInt32 len;
   unsigned char *id_data;
   char *name = NULL, *info = NULL;
   SilcIDPayload idp = NULL;
   SilcIdType id_type;
   
+  argc = silc_argument_get_arg_num(cmd->args);
+
   id_data = silc_argument_get_arg_type(cmd->args, 2, &len);
   if (!id_data) {
     if (notify)
@@ -500,7 +523,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(identify)
   SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
   SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
 
-  COMMAND_CHECK_STATUS;
+  COMMAND_CHECK_STATUS_LIST;
 
   /* Save IDENTIFY info */
   silc_client_command_reply_identify_save(cmd, cmd->status, TRUE);
@@ -517,7 +540,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(identify)
 
   /* If we received notify for invalid ID we'll remove the ID if we
      have it cached. */
-  if (cmd->error == SILC_STATUS_ERR_NO_SUCH_CLIENT_ID) {
+  if (cmd->status == SILC_STATUS_ERR_NO_SUCH_CLIENT_ID) {
     SilcClientEntry client_entry;
     SilcUInt32 tmp_len;
     unsigned char *tmp =
@@ -551,10 +574,10 @@ SILC_CLIENT_CMD_REPLY_FUNC(nick)
 
   SILC_LOG_DEBUG(("Start"));
 
-  if (cmd->error != SILC_STATUS_OK) {
+  if (cmd->status != SILC_STATUS_OK) {
     SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
        "Cannot set nickname: %s", 
-       silc_client_command_status_message(cmd->error));
+       silc_client_command_status_message(cmd->status));
     COMMAND_REPLY_ERROR;
     goto out;
   }
@@ -592,53 +615,19 @@ SILC_CLIENT_CMD_REPLY_FUNC(nick)
 SILC_CLIENT_CMD_REPLY_FUNC(list)
 {
   SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
-  SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
   unsigned char *tmp, *name, *topic;
-  SilcUInt32 usercount = 0, len;
-  SilcChannelID *channel_id = NULL;
-  SilcChannelEntry channel_entry;
+  SilcUInt32 usercount = 0;
 
-  COMMAND_CHECK_STATUS;
-
-  tmp = silc_argument_get_arg_type(cmd->args, 2, &len);
-  if (!tmp) {
-    COMMAND_REPLY_ERROR;
-    goto out;
-  }
-
-  channel_id = silc_id_payload_parse_id(tmp, len, NULL);
-  if (!channel_id) {
-    COMMAND_REPLY_ERROR;
-    goto out;
-  }
+  COMMAND_CHECK_STATUS_LIST;
 
   name = silc_argument_get_arg_type(cmd->args, 3, NULL);
-  if (!name) {
-    COMMAND_REPLY_ERROR;
-    goto out;
-  }
-
   topic = silc_argument_get_arg_type(cmd->args, 4, NULL);
   tmp = silc_argument_get_arg_type(cmd->args, 5, NULL);
   if (tmp)
     SILC_GET32_MSB(usercount, tmp);
 
-  /* Check whether the channel exists, and add it to cache if it doesn't. */
-  channel_entry = silc_client_get_channel_by_id(cmd->client, conn, 
-                                               channel_id);
-  if (!channel_entry) {
-    /* Add new channel entry */
-    channel_entry = silc_client_add_channel(cmd->client, conn, name, 0,
-                                           channel_id);
-    if (!channel_entry) {
-      COMMAND_REPLY_ERROR;
-      goto out;
-    }
-    channel_id = NULL;
-  }
-
   /* Notify application */
-  COMMAND_REPLY((ARGS, channel_entry, name, topic, usercount));
+  COMMAND_REPLY((ARGS, NULL, name, topic, usercount));
 
   /* Pending callbacks are not executed if this was an list entry */
   if (cmd->status != SILC_STATUS_OK &&
@@ -648,7 +637,6 @@ SILC_CLIENT_CMD_REPLY_FUNC(list)
   }
 
  out:
-  silc_free(channel_id);
   SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_LIST);
   silc_client_command_reply_free(cmd);
 }
@@ -665,9 +653,9 @@ SILC_CLIENT_CMD_REPLY_FUNC(topic)
   char *topic;
   SilcUInt32 argc, len;
 
-  if (cmd->error != SILC_STATUS_OK) {
+  if (cmd->status != SILC_STATUS_OK) {
     SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
-       "%s", silc_client_command_status_message(cmd->error));
+       "%s", silc_client_command_status_message(cmd->status));
     COMMAND_REPLY_ERROR;
     goto out;
   }
@@ -719,9 +707,9 @@ SILC_CLIENT_CMD_REPLY_FUNC(invite)
   unsigned char *tmp;
   SilcUInt32 len;
 
-  if (cmd->error != SILC_STATUS_OK) {
+  if (cmd->status != SILC_STATUS_OK) {
     SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
-       "%s", silc_client_command_status_message(cmd->error));
+       "%s", silc_client_command_status_message(cmd->status));
     COMMAND_REPLY_ERROR;
     goto out;
   }
@@ -761,9 +749,9 @@ SILC_CLIENT_CMD_REPLY_FUNC(kill)
   SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
   SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
 
-  if (cmd->error != SILC_STATUS_OK) {
+  if (cmd->status != SILC_STATUS_OK) {
     SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
-       "%s", silc_client_command_status_message(cmd->error));
+       "%s", silc_client_command_status_message(cmd->status));
     COMMAND_REPLY_ERROR;
     goto out;
   }
@@ -791,9 +779,9 @@ SILC_CLIENT_CMD_REPLY_FUNC(info)
 
   SILC_LOG_DEBUG(("Start"));
 
-  if (cmd->error != SILC_STATUS_OK) {
+  if (cmd->status != SILC_STATUS_OK) {
     SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR, "%s", 
-       silc_client_command_status_message(cmd->error));
+       silc_client_command_status_message(cmd->status));
     COMMAND_REPLY_ERROR;
     goto out;
   }
@@ -847,9 +835,9 @@ SILC_CLIENT_CMD_REPLY_FUNC(ping)
   int i;
   time_t diff, curtime;
 
-  if (cmd->error != SILC_STATUS_OK) {
+  if (cmd->status != SILC_STATUS_OK) {
     SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
-       "%s", silc_client_command_status_message(cmd->error));
+       "%s", silc_client_command_status_message(cmd->status));
     COMMAND_REPLY_ERROR;
     goto out;
   }
@@ -907,10 +895,10 @@ SILC_CLIENT_CMD_REPLY_FUNC(join)
 
   SILC_LOG_DEBUG(("Start"));
 
-  if (cmd->error != SILC_STATUS_OK) {
-    if (cmd->error != SILC_STATUS_ERR_USER_ON_CHANNEL)
+  if (cmd->status != SILC_STATUS_OK) {
+    if (cmd->status != SILC_STATUS_ERR_USER_ON_CHANNEL)
       SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
-         "%s", silc_client_command_status_message(cmd->error));
+         "%s", silc_client_command_status_message(cmd->status));
     COMMAND_REPLY_ERROR;
     goto out;
   }
@@ -1087,9 +1075,9 @@ SILC_CLIENT_CMD_REPLY_FUNC(motd)
   SilcUInt32 argc, i;
   char *motd = NULL, *cp, line[256];
 
-  if (cmd->error != SILC_STATUS_OK) {
+  if (cmd->status != SILC_STATUS_OK) {
     SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
-       "%s", silc_client_command_status_message(cmd->error));
+       "%s", silc_client_command_status_message(cmd->status));
     COMMAND_REPLY_ERROR;
     return;
   }
@@ -1144,9 +1132,9 @@ SILC_CLIENT_CMD_REPLY_FUNC(umode)
   unsigned char *tmp;
   SilcUInt32 mode;
 
-  if (cmd->error != SILC_STATUS_OK) {
+  if (cmd->status != SILC_STATUS_OK) {
     SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
-       "%s", silc_client_command_status_message(cmd->error));
+       "%s", silc_client_command_status_message(cmd->status));
     COMMAND_REPLY_ERROR;
     goto out;
   }
@@ -1180,9 +1168,9 @@ SILC_CLIENT_CMD_REPLY_FUNC(cmode)
   SilcChannelEntry channel;
   SilcUInt32 len;
 
-  if (cmd->error != SILC_STATUS_OK) {
+  if (cmd->status != SILC_STATUS_OK) {
     SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
-       "%s", silc_client_command_status_message(cmd->error));
+       "%s", silc_client_command_status_message(cmd->status));
     COMMAND_REPLY_ERROR;
     goto out;
   }
@@ -1239,9 +1227,9 @@ SILC_CLIENT_CMD_REPLY_FUNC(cumode)
   unsigned char *modev, *tmp, *id;
   SilcUInt32 len, mode;
   
-  if (cmd->error != SILC_STATUS_OK) {
+  if (cmd->status != SILC_STATUS_OK) {
     SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
-       "%s", silc_client_command_status_message(cmd->error));
+       "%s", silc_client_command_status_message(cmd->status));
     COMMAND_REPLY_ERROR;
     goto out;
   }
@@ -1313,9 +1301,9 @@ SILC_CLIENT_CMD_REPLY_FUNC(kick)
   SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
   SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
 
-  if (cmd->error != SILC_STATUS_OK) {
+  if (cmd->status != SILC_STATUS_OK) {
     SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
-       "%s", silc_client_command_status_message(cmd->error));
+       "%s", silc_client_command_status_message(cmd->status));
     COMMAND_REPLY_ERROR;
     goto out;
   }
@@ -1333,9 +1321,9 @@ SILC_CLIENT_CMD_REPLY_FUNC(silcoper)
   SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
   SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
 
-  if (cmd->error != SILC_STATUS_OK) {
+  if (cmd->status != SILC_STATUS_OK) {
     SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
-       "%s", silc_client_command_status_message(cmd->error));
+       "%s", silc_client_command_status_message(cmd->status));
     COMMAND_REPLY_ERROR;
     goto out;
   }
@@ -1353,9 +1341,9 @@ SILC_CLIENT_CMD_REPLY_FUNC(oper)
   SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
   SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
 
-  if (cmd->error != SILC_STATUS_OK) {
+  if (cmd->status != SILC_STATUS_OK) {
     SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
-       "%s", silc_client_command_status_message(cmd->error));
+       "%s", silc_client_command_status_message(cmd->status));
     COMMAND_REPLY_ERROR;
     goto out;
   }
@@ -1368,15 +1356,14 @@ SILC_CLIENT_CMD_REPLY_FUNC(oper)
   silc_client_command_reply_free(cmd);
 }
 
-SILC_CLIENT_CMD_REPLY_FUNC(detach)
+SILC_CLIENT_CMD_REPLY_FUNC(connect)
 {
   SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
   SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
-  SilcBuffer detach;
 
-  if (cmd->error != SILC_STATUS_OK) {
+  if (cmd->status != SILC_STATUS_OK) {
     SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
-       "%s", silc_client_command_status_message(cmd->error));
+       "%s", silc_client_command_status_message(cmd->status));
     COMMAND_REPLY_ERROR;
     goto out;
   }
@@ -1384,17 +1371,8 @@ SILC_CLIENT_CMD_REPLY_FUNC(detach)
   /* Notify application */
   COMMAND_REPLY((ARGS));
 
-  /* Generate the detachment data and deliver it to the client in the
-     detach client operation */
-  detach = silc_client_get_detach_data(cmd->client, conn);
-  if (detach) {
-    cmd->client->internal->ops->detach(cmd->client, conn, 
-                                      detach->data, detach->len);
-    silc_buffer_free(detach);
-  }
-
  out:
-  SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_DETACH);
+  SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_CONNECT);
   silc_client_command_reply_free(cmd);
 }
 
@@ -1407,9 +1385,9 @@ SILC_CLIENT_CMD_REPLY_FUNC(ban)
   unsigned char *tmp;
   SilcUInt32 len;
 
-  if (cmd->error != SILC_STATUS_OK) {
+  if (cmd->status != SILC_STATUS_OK) {
     SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
-       "%s", silc_client_command_status_message(cmd->error));
+       "%s", silc_client_command_status_message(cmd->status));
     COMMAND_REPLY_ERROR;
     goto out;
   }
@@ -1442,44 +1420,62 @@ SILC_CLIENT_CMD_REPLY_FUNC(ban)
   silc_client_command_reply_free(cmd);
 }
 
-/* Reply to LEAVE command. */
+SILC_CLIENT_CMD_REPLY_FUNC(close)
+{
+  SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
+  SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
 
-SILC_CLIENT_CMD_REPLY_FUNC(leave)
+  if (cmd->status != SILC_STATUS_OK) {
+    SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
+       "%s", silc_client_command_status_message(cmd->status));
+    COMMAND_REPLY_ERROR;
+    goto out;
+  }
+
+  /* Notify application */
+  COMMAND_REPLY((ARGS));
+
+ out:
+  SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_CLOSE);
+  silc_client_command_reply_free(cmd);
+}
+SILC_CLIENT_CMD_REPLY_FUNC(shutdown)
 {
   SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
   SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
-  SilcChannelID *channel_id;
-  SilcChannelEntry channel = NULL;
-  unsigned char *tmp;
-  SilcUInt32 len;
 
-  if (cmd->error != SILC_STATUS_OK) {
+  if (cmd->status != SILC_STATUS_OK) {
     SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
-       "%s", silc_client_command_status_message(cmd->error));
+       "%s", silc_client_command_status_message(cmd->status));
     COMMAND_REPLY_ERROR;
     goto out;
   }
 
-  /* From protocol version 1.1 we get the channel ID of the left channel */
-  tmp = silc_argument_get_arg_type(cmd->args, 2, &len);
-  if (tmp) {
-    channel_id = silc_id_payload_parse_id(tmp, len, NULL);
-    if (!channel_id)
-      goto out;
+  /* Notify application */
+  COMMAND_REPLY((ARGS));
 
-    /* Get the channel entry */
-    channel = silc_client_get_channel_by_id(cmd->client, conn, channel_id);
-    if (!channel) {
-      silc_free(channel_id);
-      COMMAND_REPLY_ERROR;
-      goto out;
-    }
+ out:
+  SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_SHUTDOWN);
+  silc_client_command_reply_free(cmd);
+}
+/* Reply to LEAVE command. */
 
-    silc_free(channel_id);
+SILC_CLIENT_CMD_REPLY_FUNC(leave)
+{
+  SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
+  SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
+
+  if (cmd->status != SILC_STATUS_OK) {
+    SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
+       "%s", silc_client_command_status_message(cmd->status));
+    COMMAND_REPLY_ERROR;
+    goto out;
   }
 
   /* Notify application */
-  COMMAND_REPLY((ARGS, channel));
+  COMMAND_REPLY((ARGS));
 
  out:
   SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_LEAVE);
@@ -1497,10 +1493,10 @@ static void silc_client_command_reply_users_cb(SilcClient client,
   if (!channels_count) {
     SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
     SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
+    SilcCommandStatus status = SILC_STATUS_ERR_NO_SUCH_CHANNEL;
 
-    cmd->status = cmd->error = SILC_STATUS_ERR_NO_SUCH_CHANNEL;
     SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
-       "%s", silc_client_command_status_message(cmd->error));
+       "%s", silc_client_command_status_message(status));
     COMMAND_REPLY_ERROR;
     SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_USERS);
     silc_client_command_reply_free(cmd);
@@ -1510,28 +1506,34 @@ static void silc_client_command_reply_users_cb(SilcClient client,
   silc_client_command_reply_users(context, NULL);
 }
 
-static int
-silc_client_command_reply_users_save(SilcClientCommandReplyContext cmd,
-                                    SilcCommandStatus status,
-                                    bool notify,
-                                    SilcGetChannelCallback get_channel,
-                                    SilcCommandCb get_clients)
+/* Reply to USERS command. Received list of client ID's and theirs modes
+   on the channel we requested. */
+
+SILC_CLIENT_CMD_REPLY_FUNC(users)
 {
+  SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
   SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
   SilcChannelEntry channel;
   SilcClientEntry client_entry;
   SilcChannelUser chu;
   SilcChannelID *channel_id = NULL;
-  SilcBufferStruct client_id_list, client_mode_list;
+  SilcBuffer client_id_list = NULL;
+  SilcBuffer client_mode_list = NULL;
   unsigned char *tmp;
   SilcUInt32 tmp_len, list_count;
   int i;
   unsigned char **res_argv = NULL;
   SilcUInt32 *res_argv_lens = NULL, *res_argv_types = NULL, res_argc = 0;
-  bool wait_res = FALSE;
 
   SILC_LOG_DEBUG(("Start"));
 
+  if (cmd->status != SILC_STATUS_OK) {
+    SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
+       "%s", silc_client_command_status_message(cmd->status));
+    COMMAND_REPLY_ERROR;
+    goto out;
+  }
+
   /* Get channel ID */
   tmp = silc_argument_get_arg_type(cmd->args, 2, &tmp_len);
   if (!tmp) {
@@ -1558,7 +1560,10 @@ silc_client_command_reply_users_save(SilcClientCommandReplyContext cmd,
     COMMAND_REPLY_ERROR;
     goto out;
   }
-  silc_buffer_set(&client_id_list, tmp, tmp_len);
+
+  client_id_list = silc_buffer_alloc(tmp_len);
+  silc_buffer_pull_tail(client_id_list, tmp_len);
+  silc_buffer_put(client_id_list, tmp, tmp_len);
 
   /* Get client mode list */
   tmp = silc_argument_get_arg_type(cmd->args, 5, &tmp_len);
@@ -1566,20 +1571,26 @@ silc_client_command_reply_users_save(SilcClientCommandReplyContext cmd,
     COMMAND_REPLY_ERROR;
     goto out;
   }
-  silc_buffer_set(&client_mode_list, tmp, tmp_len);
+
+  client_mode_list = silc_buffer_alloc(tmp_len);
+  silc_buffer_pull_tail(client_mode_list, tmp_len);
+  silc_buffer_put(client_mode_list, tmp, tmp_len);
 
   /* Get channel entry */
   channel = silc_client_get_channel_by_id(cmd->client, conn, channel_id);
   if (!channel) {
     /* Resolve the channel from server */
     silc_client_get_channel_by_id_resolve(cmd->client, conn, channel_id,
-                                         get_channel, cmd);
+                                         silc_client_command_reply_users_cb,
+                                         cmd);
     silc_free(channel_id);
-    return 1;
+    if (client_id_list)
+      silc_buffer_free(client_id_list);
+    if (client_mode_list)
+      silc_buffer_free(client_mode_list);
+    return;
   }
 
-  SILC_LOG_DEBUG(("channel %s, %d users", channel->channel_name, list_count));
-
   /* Cache the received Client ID's and modes. */
   for (i = 0; i < list_count; i++) {
     SilcUInt16 idp_len;
@@ -1587,32 +1598,25 @@ silc_client_command_reply_users_save(SilcClientCommandReplyContext cmd,
     SilcClientID *client_id;
 
     /* Client ID */
-    SILC_GET16_MSB(idp_len, client_id_list.data + 2);
+    SILC_GET16_MSB(idp_len, client_id_list->data + 2);
     idp_len += 4;
-    client_id = silc_id_payload_parse_id(client_id_list.data, idp_len, NULL);
+    client_id = silc_id_payload_parse_id(client_id_list->data, idp_len, NULL);
     if (!client_id)
       continue;
 
     /* Mode */
-    SILC_GET32_MSB(mode, client_mode_list.data);
+    SILC_GET32_MSB(mode, client_mode_list->data);
 
     /* Check if we have this client cached already. */
     client_entry = silc_client_get_client_by_id(cmd->client, conn, client_id);
     if (!client_entry || !client_entry->username || !client_entry->realname) {
       if (client_entry) {
        if (client_entry->status & SILC_CLIENT_STATUS_RESOLVING) {
-         /* Attach to this resolving and wait until it finishes */
-         silc_client_command_pending(conn, SILC_COMMAND_NONE, 
-                                     client_entry->resolve_cmd_ident,
-                                     get_clients, cmd);
-         wait_res = TRUE;
-
-         silc_buffer_pull(&client_id_list, idp_len);
-         silc_buffer_pull(&client_mode_list, 4);
+         silc_buffer_pull(client_id_list, idp_len);
+         silc_buffer_pull(client_mode_list, 4);
          continue;
        }
        client_entry->status |= SILC_CLIENT_STATUS_RESOLVING;
-       client_entry->resolve_cmd_ident = conn->cmd_ident + 1;
       }
 
       /* No we don't have it (or it is incomplete in information), query
@@ -1624,7 +1628,7 @@ silc_client_command_reply_users_save(SilcClientCommandReplyContext cmd,
                                   (res_argc + 1));
       res_argv_types = silc_realloc(res_argv_types, sizeof(*res_argv_types) *
                                    (res_argc + 1));
-      res_argv[res_argc] = client_id_list.data;
+      res_argv[res_argc] = client_id_list->data;
       res_argv_lens[res_argc] = idp_len;
       res_argv_types[res_argc] = res_argc + 3;
       res_argc++;
@@ -1640,8 +1644,8 @@ silc_client_command_reply_users_save(SilcClientCommandReplyContext cmd,
     }
 
     silc_free(client_id);
-    silc_buffer_pull(&client_id_list, idp_len);
-    silc_buffer_pull(&client_mode_list, 4);
+    silc_buffer_pull(client_id_list, idp_len);
+    silc_buffer_pull(client_mode_list, 4);
   }
 
   /* Query the client information from server if the list included clients
@@ -1664,59 +1668,36 @@ silc_client_command_reply_users_save(SilcClientCommandReplyContext cmd,
        command reply we will reprocess this command reply by re-calling this
        USERS command reply callback. */
     silc_client_command_pending(conn, SILC_COMMAND_WHOIS, conn->cmd_ident,
-                               get_clients, cmd);
+                               silc_client_command_reply_users, cmd);
 
     silc_buffer_free(res_cmd);
     silc_free(channel_id);
     silc_free(res_argv);
     silc_free(res_argv_lens);
     silc_free(res_argv_types);
-    return 1;
+    if (client_id_list)
+      silc_buffer_free(client_id_list);
+    if (client_mode_list)
+      silc_buffer_free(client_mode_list);
+    return;
   }
-
-  if (wait_res)
-    return 1;
-
-  silc_buffer_push(&client_id_list, (client_id_list.data - 
-                                    client_id_list.head));
-  silc_buffer_push(&client_mode_list, (client_mode_list.data - 
-                                      client_mode_list.head));
+  
+  silc_buffer_push(client_id_list, (client_id_list->data - 
+                                   client_id_list->head));
+  silc_buffer_push(client_mode_list, (client_mode_list->data - 
+                                     client_mode_list->head));
 
   /* Notify application */
-  if (notify)
-    COMMAND_REPLY((ARGS, channel, list_count, &client_id_list, 
-                  &client_mode_list));
-
- out:
-  silc_free(channel_id);
-  return 0;
-}
-
-/* Reply to USERS command. Received list of client ID's and theirs modes
-   on the channel we requested. */
-
-SILC_CLIENT_CMD_REPLY_FUNC(users)
-{
-  SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
-  SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
-
-  SILC_LOG_DEBUG(("Start"));
-
-  if (cmd->error != SILC_STATUS_OK) {
-    SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
-       "%s", silc_client_command_status_message(cmd->error));
-    COMMAND_REPLY_ERROR;
-    goto out;
-  }
-
-  if (silc_client_command_reply_users_save(cmd, cmd->status, TRUE,
-                                          silc_client_command_reply_users_cb,
-                                          silc_client_command_reply_users))
-    return;
+  COMMAND_REPLY((ARGS, channel, list_count, client_id_list, client_mode_list));
 
  out:
   SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_USERS);
   silc_client_command_reply_free(cmd);
+  silc_free(channel_id);
+  if (client_id_list)
+    silc_buffer_free(client_id_list);
+  if (client_mode_list)
+    silc_buffer_free(client_mode_list);
 }
 
 /* Received command reply to GETKEY command. WE've received the remote
@@ -1740,9 +1721,9 @@ SILC_CLIENT_CMD_REPLY_FUNC(getkey)
 
   SILC_LOG_DEBUG(("Start"));
 
-  if (cmd->error != SILC_STATUS_OK) {
+  if (cmd->status != SILC_STATUS_OK) {
     SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
-       "%s", silc_client_command_status_message(cmd->error));
+       "%s", silc_client_command_status_message(cmd->status));
     COMMAND_REPLY_ERROR;
     goto out;
   }
@@ -1826,7 +1807,10 @@ SILC_CLIENT_CMD_REPLY_FUNC(whois_i)
 
   SILC_LOG_DEBUG(("Start"));
 
-  if (cmd->error != SILC_STATUS_OK)
+  if (cmd->status != SILC_STATUS_OK &&
+      cmd->status != SILC_STATUS_LIST_START &&
+      cmd->status != SILC_STATUS_LIST_ITEM &&
+      cmd->status != SILC_STATUS_LIST_END)
     goto out;
 
   /* Save WHOIS info */
@@ -1844,7 +1828,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(whois_i)
 
   /* If we received notify for invalid ID we'll remove the ID if we
      have it cached. */
-  if (cmd->error == SILC_STATUS_ERR_NO_SUCH_CLIENT_ID) {
+  if (cmd->status == SILC_STATUS_ERR_NO_SUCH_CLIENT_ID) {
     SilcClientEntry client_entry;
     SilcUInt32 tmp_len;
     unsigned char *tmp =
@@ -1877,7 +1861,10 @@ SILC_CLIENT_CMD_REPLY_FUNC(identify_i)
 
   SILC_LOG_DEBUG(("Start"));
 
-  if (cmd->error != SILC_STATUS_OK)
+  if (cmd->status != SILC_STATUS_OK &&
+      cmd->status != SILC_STATUS_LIST_START &&
+      cmd->status != SILC_STATUS_LIST_ITEM &&
+      cmd->status != SILC_STATUS_LIST_END)
     goto out;
 
   /* Save IDENTIFY info */
@@ -1895,7 +1882,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(identify_i)
 
   /* If we received notify for invalid ID we'll remove the ID if we
      have it cached. */
-  if (cmd->error == SILC_STATUS_ERR_NO_SUCH_CLIENT_ID) {
+  if (cmd->status == SILC_STATUS_ERR_NO_SUCH_CLIENT_ID) {
     SilcClientEntry client_entry;
     SilcUInt32 tmp_len;
     unsigned char *tmp =
@@ -1933,7 +1920,7 @@ SILC_CLIENT_CMD_REPLY_FUNC(info_i)
 
   SILC_LOG_DEBUG(("Start"));
 
-  if (cmd->error != SILC_STATUS_OK)
+  if (cmd->status != SILC_STATUS_OK)
     goto out;
 
   /* Get server ID */
@@ -1968,115 +1955,3 @@ SILC_CLIENT_CMD_REPLY_FUNC(info_i)
   silc_free(server_id);
   silc_client_command_reply_free(cmd);
 }
-
-static void silc_client_command_reply_users_i_cb(SilcClient client,
-                                                SilcClientConnection conn,
-                                                SilcChannelEntry *channels,
-                                                SilcUInt32 channels_count,
-                                                void *context)
-{
-  if (!channels_count) {
-    SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
-    SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
-
-    cmd->status = cmd->error = SILC_STATUS_ERR_NO_SUCH_CHANNEL;
-    SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
-       "%s", silc_client_command_status_message(cmd->error));
-    COMMAND_REPLY_ERROR;
-    SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_USERS);
-    silc_client_command_reply_free(cmd);
-    return;
-  }
-
-  silc_client_command_reply_users_i(context, NULL);
-}
-
-SILC_CLIENT_CMD_REPLY_FUNC(users_i)
-{
-  SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
-
-  SILC_LOG_DEBUG(("Start"));
-
-  if (cmd->error != SILC_STATUS_OK)
-    goto out;
-
-  /* Save USERS info */
-  if (silc_client_command_reply_users_save(
-                                   cmd, cmd->status, FALSE,
-                                   silc_client_command_reply_users_i_cb,
-                                   silc_client_command_reply_users_i))
-    return;
-
- out:
-  SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_USERS);
-
-  /* Unregister this command reply */
-  silc_client_command_unregister(cmd->client, SILC_COMMAND_USERS,
-                                NULL, silc_client_command_reply_users_i,
-                                cmd->ident);
-
-  silc_client_command_reply_free(cmd);
-}
-
-/* Private range commands, specific to this implementation (and compatible
-   with SILC Server >= 0.9). */
-
-SILC_CLIENT_CMD_REPLY_FUNC(connect)
-{
-  SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
-  SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
-
-  if (cmd->error != SILC_STATUS_OK) {
-    SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
-       "%s", silc_client_command_status_message(cmd->error));
-    COMMAND_REPLY_ERROR;
-    goto out;
-  }
-
-  /* Notify application */
-  COMMAND_REPLY((ARGS));
-
- out:
-  SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_PRIV_CONNECT);
-  silc_client_command_reply_free(cmd);
-}
-
-SILC_CLIENT_CMD_REPLY_FUNC(close)
-{
-  SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
-  SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
-
-  if (cmd->error != SILC_STATUS_OK) {
-    SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
-       "%s", silc_client_command_status_message(cmd->error));
-    COMMAND_REPLY_ERROR;
-    goto out;
-  }
-
-  /* Notify application */
-  COMMAND_REPLY((ARGS));
-
- out:
-  SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_PRIV_CLOSE);
-  silc_client_command_reply_free(cmd);
-}
-SILC_CLIENT_CMD_REPLY_FUNC(shutdown)
-{
-  SilcClientCommandReplyContext cmd = (SilcClientCommandReplyContext)context;
-  SilcClientConnection conn = (SilcClientConnection)cmd->sock->user_data;
-
-  if (cmd->error != SILC_STATUS_OK) {
-    SAY(cmd->client, conn, SILC_CLIENT_MESSAGE_ERROR,
-       "%s", silc_client_command_status_message(cmd->error));
-    COMMAND_REPLY_ERROR;
-    goto out;
-  }
-
-  /* Notify application */
-  COMMAND_REPLY((ARGS));
-
- out:
-  SILC_CLIENT_PENDING_EXEC(cmd, SILC_COMMAND_PRIV_SHUTDOWN);
-  silc_client_command_reply_free(cmd);
-}
index f950447d35f8944fd3c28eeff6e71e47e339c300..afc14f9a1802335f7201a1dd215108ad8072ab37 100644 (file)
@@ -26,41 +26,23 @@ typedef struct {
   SilcCommand cmd;
 } SilcClientCommandReply;
 
-/* Context holding pending command callbacks. */
-typedef struct {
-  SilcCommandCb callback;
-  void *context;
-} *SilcClientCommandPendingCallbacks;
-
 /* Context sent as argument to all command reply functions */
 struct SilcClientCommandReplyContextStruct {
   SilcClient client;
   SilcSocketConnection sock;
   SilcCommandPayload payload;
   SilcCommandStatus status;
-  SilcCommandStatus error;
   SilcArgumentPayload args;
   SilcPacketContext *packet;
 
   /* If defined this executes the pending command. */
-  SilcClientCommandPendingCallbacks callbacks;
-  SilcUInt32 callbacks_count;
+  SilcCommandCb callback;
+  void *context;
   SilcUInt16 ident;
 };
 
 /* Macros */
 
-/* Command reply operation that is called at the end of all command replys. 
-   Usage: COMMAND_REPLY((ARGS, argument1, argument2, etc...)), */
-#define COMMAND_REPLY(args) cmd->client->internal->ops->command_reply args
-#define ARGS cmd->client, cmd->sock->user_data,                                \
-             cmd->payload, TRUE, silc_command_get(cmd->payload), cmd->status
-
-/* Error reply to application. Usage: COMMAND_REPLY_ERROR; */
-#define COMMAND_REPLY_ERROR cmd->client->internal->ops->               \
-  command_reply(cmd->client, cmd->sock->user_data, cmd->payload,       \
-  FALSE, silc_command_get(cmd->payload), cmd->status)
-
 /* Macro used to declare command reply functions */
 #define SILC_CLIENT_CMD_REPLY_FUNC(func)                               \
 void silc_client_command_reply_##func(void *context, void *context2)
@@ -81,7 +63,6 @@ void silc_client_command_reply_process(SilcClient client,
                                       SilcSocketConnection sock,
                                       SilcPacketContext *packet);
 char *silc_client_command_status_message(SilcCommandStatus status);
-void silc_client_command_reply_free(SilcClientCommandReplyContext cmd);
 SILC_CLIENT_CMD_REPLY_FUNC(whois);
 SILC_CLIENT_CMD_REPLY_FUNC(whowas);
 SILC_CLIENT_CMD_REPLY_FUNC(identify);
@@ -91,8 +72,12 @@ SILC_CLIENT_CMD_REPLY_FUNC(topic);
 SILC_CLIENT_CMD_REPLY_FUNC(invite);
 SILC_CLIENT_CMD_REPLY_FUNC(kill);
 SILC_CLIENT_CMD_REPLY_FUNC(info);
+SILC_CLIENT_CMD_REPLY_FUNC(links);
 SILC_CLIENT_CMD_REPLY_FUNC(stats);
+SILC_CLIENT_CMD_REPLY_FUNC(users);
+SILC_CLIENT_CMD_REPLY_FUNC(connect);
 SILC_CLIENT_CMD_REPLY_FUNC(ping);
+SILC_CLIENT_CMD_REPLY_FUNC(pong);
 SILC_CLIENT_CMD_REPLY_FUNC(oper);
 SILC_CLIENT_CMD_REPLY_FUNC(join);
 SILC_CLIENT_CMD_REPLY_FUNC(motd);
@@ -101,7 +86,8 @@ SILC_CLIENT_CMD_REPLY_FUNC(cmode);
 SILC_CLIENT_CMD_REPLY_FUNC(cumode);
 SILC_CLIENT_CMD_REPLY_FUNC(kick);
 SILC_CLIENT_CMD_REPLY_FUNC(ban);
-SILC_CLIENT_CMD_REPLY_FUNC(detach);
+SILC_CLIENT_CMD_REPLY_FUNC(close);
+SILC_CLIENT_CMD_REPLY_FUNC(shutdown);
 SILC_CLIENT_CMD_REPLY_FUNC(silcoper);
 SILC_CLIENT_CMD_REPLY_FUNC(leave);
 SILC_CLIENT_CMD_REPLY_FUNC(users);
@@ -112,10 +98,5 @@ SILC_CLIENT_CMD_REPLY_FUNC(quit);
 SILC_CLIENT_CMD_REPLY_FUNC(whois_i);
 SILC_CLIENT_CMD_REPLY_FUNC(identify_i);
 SILC_CLIENT_CMD_REPLY_FUNC(info_i);
-SILC_CLIENT_CMD_REPLY_FUNC(users_i);
-
-SILC_CLIENT_CMD_REPLY_FUNC(connect);
-SILC_CLIENT_CMD_REPLY_FUNC(close);
-SILC_CLIENT_CMD_REPLY_FUNC(shutdown);
 
 #endif
index 2d5a8c0cdb8f2fc780605d6252cdbc32b5a828e1..15455b69d509f46cdb74b353692475eab9429d0b 100644 (file)
@@ -362,7 +362,6 @@ void silc_client_get_clients_by_list(SilcClient client,
   unsigned char **res_argv = NULL;
   SilcUInt32 *res_argv_lens = NULL, *res_argv_types = NULL, res_argc = 0;
   GetClientsByListInternal in;
-  bool wait_res = FALSE;
 
   SILC_LOG_DEBUG(("Start"));
 
@@ -378,7 +377,6 @@ void silc_client_get_clients_by_list(SilcClient client,
     SilcUInt16 idp_len;
     SilcClientID *client_id;
     SilcClientEntry entry;
-    bool ret;
 
     /* Get Client ID */
     SILC_GET16_MSB(idp_len, client_id_list->data + 2);
@@ -390,34 +388,26 @@ void silc_client_get_clients_by_list(SilcClient client,
     }
 
     /* Check if we have this client cached already. */
-    ret =
-      silc_idcache_find_by_id_one_ext(conn->client_cache, (void *)client_id, 
-                                     NULL, NULL, 
-                                     silc_hash_client_id_compare, NULL,
-                                     &id_cache);
+    id_cache = NULL;
+    silc_idcache_find_by_id_one_ext(conn->client_cache, (void *)client_id, 
+                                   NULL, NULL, 
+                                   silc_hash_client_id_compare, NULL,
+                                   &id_cache);
 
     /* If we don't have the entry or it has incomplete info, then resolve
        it from the server. */
-    if (!ret || !((SilcClientEntry)id_cache->context)->nickname) {
-      entry = ret ? (SilcClientEntry)id_cache->context : NULL;
+    entry = id_cache ? (SilcClientEntry)id_cache->context : NULL;
+    if (!id_cache || !entry->nickname) {
 
       if (entry) {
        if (entry->status & SILC_CLIENT_STATUS_RESOLVING) {
-         /* Attach to this resolving and wait until it finishes */
-         silc_client_command_pending(
-                           conn, SILC_COMMAND_NONE, 
-                           entry->resolve_cmd_ident,
-                           silc_client_command_get_clients_list_callback, 
-                           (void *)in);
-         wait_res = TRUE;
-
+         entry->status &= ~SILC_CLIENT_STATUS_RESOLVING;
          silc_free(client_id);
          silc_buffer_pull(client_id_list, idp_len);
          continue;
        }
 
        entry->status |= SILC_CLIENT_STATUS_RESOLVING;
-       entry->resolve_cmd_ident = conn->cmd_ident + 1;
       }
 
       /* No we don't have it, query it from the server. Assemble argument
@@ -438,9 +428,6 @@ void silc_client_get_clients_by_list(SilcClient client,
     silc_buffer_pull(client_id_list, idp_len);
   }
 
-  silc_buffer_push(client_id_list, client_id_list->data - 
-                  client_id_list->head);
-
   /* Query the client information from server if the list included clients
      that we don't know about. */
   if (res_argc) {
@@ -464,6 +451,8 @@ void silc_client_get_clients_by_list(SilcClient client,
                                silc_client_command_get_clients_list_callback, 
                                (void *)in);
 
+    silc_buffer_push(client_id_list, client_id_list->data - 
+                    client_id_list->head);
     silc_buffer_free(res_cmd);
     silc_free(res_argv);
     silc_free(res_argv_lens);
@@ -471,8 +460,8 @@ void silc_client_get_clients_by_list(SilcClient client,
     return;
   }
 
-  if (wait_res)
-    return;
+  silc_buffer_push(client_id_list, client_id_list->data - 
+                  client_id_list->head);
 
   /* We have the clients in cache, get them and call the completion */
   silc_client_command_get_clients_list_callback((void *)in, NULL);
@@ -517,13 +506,10 @@ SILC_CLIENT_CMD_FUNC(get_client_by_id_callback)
 
   /* Get the client */
   entry = silc_client_get_client_by_id(i->client, i->conn, i->client_id);
-  if (entry) {
-    if (i->completion)
-      i->completion(i->client, i->conn, &entry, 1, i->context);
-  } else {
-    if (i->completion)
-      i->completion(i->client, i->conn, NULL, 0, i->context);
-  }
+  if (entry)
+    i->completion(i->client, i->conn, &entry, 1, i->context);
+  else
+    i->completion(i->client, i->conn, NULL, 0, i->context);
 
   silc_free(i->client_id);
   silc_free(i);
index 3e7eb25306a5a51f55afe9965445ab69c3d46e98..ffca34d40945aea947efd3b4322744b800784aa3 100644 (file)
@@ -36,22 +36,22 @@ struct SilcClientEntryStruct {
   char *hostname;              /* hostname */
   char *server;                        /* SILC server name */
   char *realname;              /* Realname (userinfo) */
-  SilcUInt32 mode;             /* User mode in SILC */
+  SilcUInt32 num;
+  SilcUInt32 mode;                     /* User mode in SILC */
   SilcClientID *id;            /* The Client ID */
   unsigned char *fingerprint;  /* Fingerprint of client's public key */
   SilcUInt32 fingerprint_len;  /* Length of the fingerprint */
+  bool valid;                  /* FALSE if this entry is not valid */
   SilcCipher send_key;         /* Private message key for sending */
   SilcCipher receive_key;      /* Private message key for receiving */
-  SilcClientKeyAgreement ke;   /* Current key agreement context or NULL */
-  SilcClientStatus status;     /* Status mask */
-  SilcHashTable channels;      /* All channels client has joined */
   unsigned char *key;          /* Set only if appliation provided the
                                   key material. NULL if the library 
                                   generated the key. */
-  SilcUInt32 key_len;          /* Key length */
-  SilcUInt16 resolve_cmd_ident;        /* Command identifier when resolving */
-  bool generated;              /* TRUE if library generated `key' */
-  bool valid;                  /* FALSE if this entry is not valid */
+  SilcUInt32 key_len;
+  bool generated;              /* TRUE if library generated the key */
+  SilcClientKeyAgreement ke;   /* Current key agreement context or NULL */
+  SilcClientStatus status;     /* Status mask */
+  SilcHashTable channels;      /* All channels client has joined */
 };
 
 /* Client and its mode on a channel */
index 6ab25d6806b4d7a7fbb8050961be574bb91abc34..932bd3abcf391f1b6d9af6ae1b3aec35f51b0abe 100644 (file)
@@ -171,36 +171,53 @@ SilcSKEStatus silc_ske_check_version(SilcSKE ske, unsigned char *version,
 {
   SilcClientConnection conn = (SilcClientConnection)ske->sock->user_data;
   SilcClient client = (SilcClient)ske->user_data;
-  SilcUInt32 l_protocol_version = 0, r_protocol_version = 0;
+  SilcSKEStatus status = SILC_SKE_STATUS_OK;
+  char *cp;
+  int maj = 0, min = 0, build = 0, maj2 = 0, min2 = 0, build2 = 0;
 
-  if (!silc_parse_version_string(version, &r_protocol_version, NULL, NULL,
-                                NULL, NULL)) {
-    client->internal->ops->say(client, conn, SILC_CLIENT_MESSAGE_AUDIT,
-                              "We don't support server version `%s'", 
-                              version);
-    return SILC_SKE_STATUS_BAD_VERSION;
-  }
+  /* Check for initial version string. Allowed "SILC-1.x-". */
+  if (!strstr(version, "SILC-1."))
+    status = SILC_SKE_STATUS_BAD_VERSION;
 
-  if (!silc_parse_version_string(client->internal->silc_client_version, 
-                                &l_protocol_version, NULL, NULL,
-                                NULL, NULL)) {
-    client->internal->ops->say(client, conn, SILC_CLIENT_MESSAGE_AUDIT,
-                              "We don't support server version `%s'", 
-                              version);
-    return SILC_SKE_STATUS_BAD_VERSION;
+  /* Check software version */
+
+  cp = version + 9;
+  if (!cp)
+    status = SILC_SKE_STATUS_BAD_VERSION;
+
+  maj = atoi(cp);
+  cp = strchr(cp, '.');
+  if (cp) {
+    min = atoi(cp + 1);
+    cp++;
   }
+  cp = strchr(cp, '.');
+  if (cp)
+    build = atoi(cp + 1);
+
+  cp = client->internal->silc_client_version + 9;
+  if (!cp)
+    status = SILC_SKE_STATUS_BAD_VERSION;
+
+  maj2 = atoi(cp);
+  cp = strchr(cp, '.');
+  if (cp) {
+    min2 = atoi(cp + 1);
+    cp++;
+  }
+  cp = strchr(cp, '.');
+  if (cp)
+    build2 = atoi(cp + 1);
+
+  if (maj != maj2)
+    status = SILC_SKE_STATUS_BAD_VERSION;
 
-  /* If remote is too new, don't connect */
-  if (l_protocol_version < r_protocol_version) {
+  if (status != SILC_SKE_STATUS_OK)
     client->internal->ops->say(client, conn, SILC_CLIENT_MESSAGE_AUDIT,
                               "We don't support server version `%s'", 
                               version);
-    return SILC_SKE_STATUS_BAD_VERSION;
-  }
-
-  ske->sock->version = r_protocol_version;
 
-  return SILC_SKE_STATUS_OK;
+  return status;
 }
 
 /* Callback that is called by the SKE to indicate that it is safe to
@@ -572,21 +589,9 @@ silc_client_conn_auth_continue(unsigned char *auth_data,
   SilcClient client = (SilcClient)ctx->client;
   SilcBuffer packet;
   int payload_len = 0;
-  unsigned char *autf8 = NULL;
 
   SILC_LOG_DEBUG(("Start"));
 
-  /* Passphrase must be UTF-8 encoded, if it isn't encode it */
-  if (ctx->auth_meth == SILC_AUTH_PASSWORD && 
-      !silc_utf8_valid(auth_data, auth_data_len)) {
-    payload_len = silc_utf8_encoded_len(auth_data, auth_data_len, 
-                                       SILC_STRING_ASCII);
-    autf8 = silc_calloc(payload_len, sizeof(*autf8));
-    auth_data_len = silc_utf8_encode(auth_data, auth_data_len, 
-                                    SILC_STRING_ASCII, autf8, payload_len);
-    auth_data = autf8;
-  }
-
   payload_len = 4 + auth_data_len;
   packet = silc_buffer_alloc(payload_len);
   silc_buffer_pull_tail(packet, SILC_BUFFER_END(packet));
@@ -602,7 +607,6 @@ silc_client_conn_auth_continue(unsigned char *auth_data,
                          NULL, 0, NULL, NULL,
                          packet->data, packet->len, TRUE);
   silc_buffer_free(packet);
-  silc_free(autf8);
       
   /* Next state is end of protocol */
   protocol->state = SILC_PROTOCOL_STATE_END;
index 928650c788e8bfff98e8dd81c6b9bbec974bf0ad..1e069138a4b53a51c70a7eed51f7c75c4af4082d 100644 (file)
@@ -183,9 +183,7 @@ typedef struct SilcChannelPrivateKeyStruct {
  *
  *    Ask passphrase callback. This is called by the application when the
  *    library calls `ask_passphrase' client operation.  The callback delivers
- *    the passphrase to the library.  The passphrases in SILC protocol
- *    MUST be in UTF-8 encoding, therefore the `passphrase' SHOULD be UTF-8
- *    encoded, and if it is not then library will attempt to encode it.
+ *    the passphrase to the library.
  *
  ***/
 typedef void (*SilcAskPassphrase)(unsigned char *passphrase,
@@ -254,28 +252,6 @@ typedef enum {
 } SilcClientMessageType;
 /***/
 
-/****d* silcclient/SilcClientAPI/SilcClientConnectionStatus
- *
- * NAME
- *
- *    typedef enum { ... } SilcClientConnectionStatus
- *
- * DESCRIPTION
- *
- *    This type is returned to the `connect' client operation to indicate
- *    the status of the created connection.  It can indicated if it was
- *    successful or whether an error occurred.
- *
- * SOURCE
- */
-typedef enum {
-  SILC_CLIENT_CONN_SUCCESS,           /* Successfully connected */
-  SILC_CLIENT_CONN_SUCCESS_RESUME,     /* Successfully connected and
-                                         resumed old detached session */
-  SILC_CLIENT_CONN_ERROR,             /* Error occurred during connecting */
-} SilcClientConnectionStatus;
-/***/
-
 /****s* silcclient/SilcClientAPI/SilcClientOperations
  *
  * NAME
@@ -305,16 +281,13 @@ typedef struct {
      `msg' maybe NULL. */
   void (*channel_message)(SilcClient client, SilcClientConnection conn, 
                          SilcClientEntry sender, SilcChannelEntry channel, 
-                         SilcMessageFlags flags,
-                         const unsigned char *message,
-                         SilcUInt32 message_len);
+                         SilcMessageFlags flags, char *msg);
 
   /* Private message to the client. The `sender' is the sender of the
      message. */
   void (*private_message)(SilcClient client, SilcClientConnection conn,
                          SilcClientEntry sender, SilcMessageFlags flags,
-                         const unsigned char *message,
-                         SilcUInt32 message_len);
+                         char *msg);
 
   /* Notify message to the client. The notify arguments are sent in the
      same order as servers sends them. The arguments are same as received
@@ -354,25 +327,17 @@ typedef struct {
      the command reply status server returned. The `command' is the command
      reply being processed. The function has variable argument list and each
      command defines the number and type of arguments it passes to the
-     application (on error they are not sent).
-
-     The arguments are sent in the same order as servers sends them.  The 
-     arguments are same as received from the server except for ID's.  If 
-     ID is received application receives the corresponding entry to the 
-     ID. For example, if Client ID is receives application receives 
-     SilcClientEntry. */
+     application (on error they are not sent). */
   void (*command_reply)(SilcClient client, SilcClientConnection conn,
                        SilcCommandPayload cmd_payload, int success,
                        SilcCommand command, SilcCommandStatus status, ...);
 
   /* Called to indicate that connection was either successfully established
      or connecting failed.  This is also the first time application receives
-     the SilcClientConnection object which it should save somewhere.
-     The `status' indicated whether the connection were successful.  If it
-     is error value the application must always call the function
+     the SilcClientConnection objecet which it should save somewhere.
+     If the `success' is FALSE the application must always call the function
      silc_client_close_connection. */
-  void (*connect)(SilcClient client, SilcClientConnection conn,
-                 SilcClientConnectionStatus status);
+  void (*connect)(SilcClient client, SilcClientConnection conn, int success);
 
   /* Called to indicate that connection was disconnected to the server. */
   void (*disconnect)(SilcClient client, SilcClientConnection conn);
@@ -397,8 +362,7 @@ typedef struct {
 
   /* Ask (interact, that is) a passphrase from user. The passphrase is
      returned to the library by calling the `completion' callback with
-     the `context'. The returned passphrase SHOULD be in UTF-8 encoded,
-     if not then the library will attempt to encode. */
+     the `context'. */
   void (*ask_passphrase)(SilcClient client, SilcClientConnection conn,
                         SilcAskPassphrase completion, void *context);
 
@@ -433,26 +397,6 @@ typedef struct {
   void (*ftp)(SilcClient client, SilcClientConnection conn,
              SilcClientEntry client_entry, SilcUInt32 session_id,
              const char *hostname, SilcUInt16 port);
-
-  /* Delivers SILC session detachment data indicated by `detach_data' to the
-     application.  If application has issued SILC_COMMAND_DETACH command     
-     the client session in the SILC network is not quit.  The client remains 
-     in the network but is detached.  The detachment data may be used later
-     to resume the session in the SILC Network.  The appliation is   
-     responsible of saving the `detach_data', to for example in a file.
-
-     The detachment data can be given as argument to the functions
-     silc_client_connect_to_server, or silc_client_add_connection when
-     creating connection to remote server, inside SilcClientConnectionParams
-     structure.  If it is provided the client library will attempt to resume
-     the session in the network.  After the connection is created
-     successfully, the application is responsible of setting the user
-     interface for user into the same state it was before detaching (showing
-     same channels, channel modes, etc).  It can do this by fetching the
-     information (like joined channels) from the client library. */
-  void (*detach)(SilcClient client, SilcClientConnection conn,
-                const unsigned char *detach_data,
-                SilcUInt32 detach_data_len);
 } SilcClientOperations;
 /***/
 
@@ -577,8 +521,7 @@ typedef struct {
  *    the client. The `application' is application specific user data pointer
  *    and caller must free it. The `silc_version' is the application version
  *    that will be used to compare against remote host's (usually a server)
- *    version string.  The `application' context is accessible by the
- *    application by client->application, client being SilcClient.
+ *    version string.
  *
  ***/
 SilcClient silc_client_alloc(SilcClientOperations *ops, 
@@ -667,45 +610,12 @@ void silc_client_stop(SilcClient client);
 
 /* Connecting functions (client.c) */
 
-/****s* silcclient/SilcClientAPI/SilcClientConnectionParams
- *
- * NAME
- *
- *    typedef struct { ... } SilcClientConnectionParams;
- *
- * DESCRIPTION
- *
- *    Client connection parameters.  This can be filled by the application
- *    and given as argument to silc_client_connect_to_server or to
- *    silc_client_add_connection.
- *
- * SOURCE
- */
-typedef struct {
-  /* The SILC session detachment data that was returned by `detach' client
-     operation when the application detached from the network.  Application
-     is responsible of saving the data and giving it as argument here
-     for resuming the session in the SILC network.
-
-     If this is provided here the client library will attempt to resume
-     the session in the network.  After the connection is created
-     successfully, the application is responsible of setting the user
-     interface for user into the same state it was before detaching (showing
-     same channels, channel modes, etc).  It can do this by fetching the
-     information (like joined channels) from the client library. */
-  unsigned char *detach_data;
-  SilcUInt32 detach_data_len;
-
-} SilcClientConnectionParams;
-/***/
-
 /****f* silcclient/SilcClientAPI/silc_client_connect_to_server
  *
  * SYNOPSIS
  *
- *    int silc_client_connect_to_server(SilcClient client, 
- *                                      SilcClientConnectionParams *params,
- *                                      int port, char *host, void *context);
+ *    int silc_client_connect_to_server(SilcClient client, int port,
+ *                                      char *host, void *context);
  *
  * DESCRIPTION
  *
@@ -715,24 +625,20 @@ typedef struct {
  *    that is created after the connection is created. Note that application
  *    may handle the connecting process outside the library. If this is the
  *    case then this function is not used at all. When the connecting is
- *    done the `connect' client operation is called, and the `context' is
- *    accessible with conn->context, conn being SilcClientConnection.
- *    If the `params' is provided they are used by the routine.
+ *    done the `connect' client operation is called.
  *
  ***/
-int silc_client_connect_to_server(SilcClient client, 
-                                 SilcClientConnectionParams *params,
-                                 int port, char *host, void *context);
+int silc_client_connect_to_server(SilcClient client, int port,
+                                 char *host, void *context);
 
 /****f* silcclient/SilcClientAPI/silc_client_add_connection
  *
  * SYNOPSIS
  *
- *
- *    SilcClientConnection
- *    silc_client_add_connection(SilcClient client,
- *                               SilcClientConnectionParams *params,
- *                               char *hostname, int port, void *context);
+ *    SilcClientConnection silc_client_add_connection(SilcClient client,
+ *                                                    char *hostname,
+ *                                                   int port,
+ *                                                   void *context);
  *
  * DESCRIPTION
  *
@@ -740,21 +646,15 @@ int silc_client_connect_to_server(SilcClient client,
  *    connection to the connection table and returns a pointer to it. A client
  *    can have multiple connections to multiple servers. Every connection must
  *    be added to the client using this function. User data `context' may
- *    be sent as argument.  If the `params' is provided they are used by 
- *    the routine.
- *
- * NOTES
- *
- *    This function is normally used only if the application performed 
- *    the connecting outside the library, and did not called the
- *    silc_client_connect_to_server function at all. The library
+ *    be sent as argument. This function is normally used only if the 
+ *    application performed the connecting outside the library. The library
  *    however may use this internally.
  *
  ***/
-SilcClientConnection
-silc_client_add_connection(SilcClient client,
-                          SilcClientConnectionParams *params,
-                          char *hostname, int port, void *context);
+SilcClientConnection silc_client_add_connection(SilcClient client,
+                                               char *hostname,
+                                               int port,
+                                               void *context);
 
 /****f* silcclient/SilcClientAPI/silc_client_del_connection
  *
@@ -833,15 +733,22 @@ void silc_client_start_key_exchange(SilcClient client,
  * SYNOPSIS
  *
  *    void silc_client_close_connection(SilcClient client,
+ *                                      SilcSocketConnection sock,
  *                                      SilcClientConnection conn);
  *
  * DESCRIPTION
  *
  *    Closes connection to remote end. Free's all allocated data except
  *    for some information such as nickname etc. that are valid at all time. 
+ *    If the `sock' is NULL then the conn->sock will be used.  If `sock' is
+ *    provided it will be checked whether the sock and `conn->sock' are the
+ *    same (they can be different, ie. a socket can use `conn' as its
+ *    connection but `conn->sock' might be actually a different connection
+ *    than the `sock'). 
  *
  ***/
 void silc_client_close_connection(SilcClient client,
+                                 SilcSocketConnection sock,
                                  SilcClientConnection conn);
 
 
index e38eff0b3b5171e918271e8fbb8c5963fc083d40..6e73a9f468bff84c7d84f0ee993e1bc32c613d22 100644 (file)
@@ -92,28 +92,13 @@ SilcBuffer silc_auth_payload_encode(SilcAuthMethod method,
 {
   SilcBuffer buffer;
   SilcUInt32 len;
-  unsigned char *autf8 = NULL;
-  SilcUInt32 autf8_len;
 
   SILC_LOG_DEBUG(("Encoding Authentication Payload"));
 
-  /* Passphrase MUST be UTF-8 encoded, encode if it is not */
-  if (method == SILC_AUTH_PASSWORD && !silc_utf8_valid(auth_data, auth_len)) {
-    autf8_len = silc_utf8_encoded_len(auth_data, auth_len, 0);
-    if (!autf8_len)
-      return NULL;
-    autf8 = silc_calloc(autf8_len, sizeof(*autf8));
-    auth_len = silc_utf8_encode(auth_data, auth_len, 0, autf8, autf8_len);
-    auth_data = (const unsigned char *)autf8;
-  }
-
   len = 2 + 2 + 2 + random_len + 2 + auth_len;
   buffer = silc_buffer_alloc_size(len);
-  if (!buffer) {
-    silc_free(autf8);
+  if (!buffer)
     return NULL;
-  }
-
   silc_buffer_format(buffer,
                     SILC_STR_UI_SHORT(len),
                     SILC_STR_UI_SHORT(method),
@@ -123,7 +108,6 @@ SilcBuffer silc_auth_payload_encode(SilcAuthMethod method,
                     SILC_STR_UI_XNSTRING(auth_data, auth_len),
                     SILC_STR_END);
 
-  silc_free(autf8);
   return buffer;
 }
 
@@ -151,7 +135,7 @@ SilcAuthMethod silc_auth_get_method(SilcAuthPayload payload)
   return payload->auth_method;
 }
 
-/* Get the authentication data. If this is passphrase it is UTF-8 encoded. */
+/* Get the authentication data */
 
 unsigned char *silc_auth_get_data(SilcAuthPayload payload,
                                  SilcUInt32 *auth_len)
@@ -408,8 +392,7 @@ bool silc_auth_verify(SilcAuthPayload payload, SilcAuthMethod auth_method,
 
 /* Same as above but parses the authentication payload before verify. */
 
-bool silc_auth_verify_data(const unsigned char *payload, 
-                          SilcUInt32 payload_len,
+bool silc_auth_verify_data(const unsigned char *payload, SilcUInt32 payload_len,
                           SilcAuthMethod auth_method, const void *auth_data,
                           SilcUInt32 auth_data_len, SilcHash hash, 
                           const void *id, SilcIdType type)
index f66621324107bbc403b2c85a45f4b05b270b920c..38a0a418b3938aa1b00b8c244547c78dee667ad0 100644 (file)
@@ -129,10 +129,7 @@ SilcAuthPayload silc_auth_payload_parse(const unsigned char *data,
  *
  *    Encodes authentication payload into buffer and returns it.
  *    The `random_data' is provided only if doing public key authentication.
- *    The `auth_data' is the actual authentication data.  If the
- *    `method' is SILC_AUTH_PASSWORD the passphase in `auth_data' sent as
- *    argument SHOULD be UTF-8 encoded, if not library will attempt to
- *    encode it.
+ *    The `auth_data' is the actual authentication data.
  *
  ***/
 SilcBuffer silc_auth_payload_encode(SilcAuthMethod method,
@@ -176,9 +173,7 @@ SilcAuthMethod silc_auth_get_method(SilcAuthPayload payload);
  *
  * DESCRIPTION
  *
- *    Get the authentication data. The caller must not free the data.  If
- *    the authentication method is passphrase, then the returned string
- *    is UTF-8 encoded passphrase.
+ *    Get the authentication data. The caller must not free the data.
  *
  ***/
 unsigned char *silc_auth_get_data(SilcAuthPayload payload,
@@ -271,9 +266,9 @@ bool silc_auth_public_key_auth_verify_data(const unsigned char *payload,
  *    Verifies the authentication data directly from the Authentication 
  *    Payload. Supports all authentication methods. If the authentication
  *    method is passphrase based then the `auth_data' and `auth_data_len'
- *    are the passphrase and its length.  The passphrase MUST be UTF-8
- *    encoded.  If the method is public key authentication then the
- *    `auth_data' is the SilcPublicKey and the `auth_data_len' is ignored.
+ *    are the passphrase and its length. If the method is public key
+ *    authentication then the `auth_data' is the SilcPublicKey and the
+ *    `auth_data_len' is ignored.
  *
  ***/
 bool silc_auth_verify(SilcAuthPayload payload, SilcAuthMethod auth_method,
@@ -297,13 +292,12 @@ bool silc_auth_verify(SilcAuthPayload payload, SilcAuthMethod auth_method,
  *    Verifies the authentication data directly from the Authentication 
  *    Payload. Supports all authentication methods. If the authentication
  *    method is passphrase based then the `auth_data' and `auth_data_len'
- *    are the passphrase and its length.  The passphrase MUST be UTF-8
- *    encoded.  If the method is public key authentication then the
- *    `auth_data' is the SilcPublicKey and the `auth_data_len' is ignored.
+ *    are the passphrase and its length. If the method is public key
+ *    authentication then the `auth_data' is the SilcPublicKey and the
+ *    `auth_data_len' is ignored.
  *
  ***/
-bool silc_auth_verify_data(const unsigned char *payload, 
-                          SilcUInt32 payload_len,
+bool silc_auth_verify_data(const unsigned char *payload, SilcUInt32 payload_len,
                           SilcAuthMethod auth_method, const void *auth_data,
                           SilcUInt32 auth_data_len, SilcHash hash, 
                           const void *id, SilcIdType type);
index 5254c9ed59eb23d9b51b94623a058ba5d271c749..2a853548826575e08387eabd0d4c843de3ae7320 100644 (file)
@@ -299,23 +299,11 @@ bool silc_channel_message_payload_decrypt(unsigned char *data,
 
     /* Check the MAC of the message */
     SILC_LOG_DEBUG(("Checking channel message MACs"));
-    silc_hmac_init(hmac);
-    silc_hmac_update(hmac, dst, (data_len - iv_len - mac_len));
-    silc_hmac_update(hmac, data + (data_len - iv_len), iv_len);
-    silc_hmac_final(hmac, mac2, &mac_len);
+    silc_hmac_make(hmac, dst, (data_len - iv_len - mac_len), mac2, &mac_len);
     if (memcmp(mac, mac2, mac_len)) {
-#if 1
-      /* Backwards support for old mac checking, remove in 1.0 */
-      silc_hmac_make(hmac, dst, (data_len - iv_len - mac_len), mac2, &mac_len);
-      if (memcmp(mac, mac2, mac_len)) {
-#endif
-
       SILC_LOG_DEBUG(("Channel message MACs does not match"));
       silc_free(dst);
       return FALSE;
-#if 1
-      }
-#endif
     }
     SILC_LOG_DEBUG(("MAC is Ok"));
 
@@ -407,10 +395,7 @@ bool silc_channel_message_payload_encrypt(unsigned char *data,
   SilcBufferStruct buf;
 
   /* Compute the MAC of the channel message data */
-  silc_hmac_init(hmac);
-  silc_hmac_update(hmac, data, data_len);
-  silc_hmac_update(hmac, iv, iv_len);
-  silc_hmac_final(hmac, mac, &mac_len);
+  silc_hmac_make(hmac, data, data_len, mac, &mac_len);
 
   /* Put rest of the data to the payload */
   silc_buffer_set(&buf, data, true_len);
index 788ef384cbfdbf6216eb17c0faf793e53a7a85f4..6d97e1a251a7ae483550910a70bc928ba8ac4268 100644 (file)
@@ -111,10 +111,8 @@ typedef SilcUInt16 SilcMessageFlags;
 #define SILC_MESSAGE_FLAG_NOTICE      0x0008
 #define SILC_MESSAGE_FLAG_REQUEST     0x0010
 #define SILC_MESSAGE_FLAG_SIGNED      0x0020
-#define SILC_MESSAGE_FLAG_REPLY       0x0040
-#define SILC_MESSAGE_FLAG_DATA        0x0080
-#define SILC_MESSAGE_FLAG_RESERVED    0x0100 /* to 0x0800 */
-#define SILC_MESSAGE_FLAG_PRIVATE     0x1000 /* to 0x8000 */
+#define SILC_MESSAGE_FLAG_RESERVED    0x0040 /* to 0x0200 */
+#define SILC_MESSAGE_FLAG_PRIVATE     0x0400 /* to 0x8000 */
 /***/
 
 /* Prototypes */
index 20b90c66535918c43917306e7d59d03f5109aeef..3be0583e3a04006ffbf3573184aaea3804abc9c0 100644 (file)
@@ -82,8 +82,7 @@ SilcCommandPayload silc_command_payload_parse(const unsigned char *payload,
 
   silc_buffer_pull(&buffer, SILC_COMMAND_PAYLOAD_LEN);
   if (args_num) {
-    newp->args = silc_argument_payload_parse(buffer.data, buffer.len, 
-                                            args_num);
+    newp->args = silc_argument_payload_parse(buffer.data, buffer.len, args_num);
     if (!newp->args) {
       silc_free(newp);
       return NULL;
@@ -272,7 +271,6 @@ SilcBuffer silc_command_payload_encode_vap(SilcCommand cmd,
 SilcBuffer 
 silc_command_reply_payload_encode_va(SilcCommand cmd, 
                                     SilcCommandStatus status,
-                                    SilcCommandStatus error,
                                     SilcUInt16 ident,
                                     SilcUInt32 argc, ...)
 {
@@ -280,8 +278,7 @@ silc_command_reply_payload_encode_va(SilcCommand cmd,
   SilcBuffer buffer;
 
   va_start(ap, argc);
-  buffer = silc_command_reply_payload_encode_vap(cmd, status, error,
-                                                ident, argc, ap);
+  buffer = silc_command_reply_payload_encode_vap(cmd, status, ident, argc, ap);
   va_end(ap);
 
   return buffer;
@@ -290,7 +287,6 @@ silc_command_reply_payload_encode_va(SilcCommand cmd,
 SilcBuffer 
 silc_command_reply_payload_encode_vap(SilcCommand cmd, 
                                      SilcCommandStatus status,
-                                     SilcCommandStatus error,
                                      SilcUInt16 ident, SilcUInt32 argc, 
                                      va_list ap)
 {
@@ -319,8 +315,7 @@ silc_command_reply_payload_encode_vap(SilcCommand cmd,
     return NULL;
   }
 
-  status_data[0] = status;
-  status_data[1] = error;
+  SILC_PUT16_MSB(status, status_data);
   argv[0] = silc_memdup(status_data, sizeof(status_data));
   if (!argv[0]) {
     silc_free(argv_types);
@@ -393,45 +388,19 @@ SilcUInt16 silc_command_get_ident(SilcCommandPayload payload)
 
 /* Return command status */
 
-bool silc_command_get_status(SilcCommandPayload payload, 
-                            SilcCommandStatus *status,
-                            SilcCommandStatus *error)
+SilcCommandStatus silc_command_get_status(SilcCommandPayload payload)
 {
   unsigned char *tmp;
-  SilcUInt32 tmp_len;
+  SilcCommandStatus status;
 
   if (!payload->args)
     return 0;
-  tmp = silc_argument_get_arg_type(payload->args, 1, &tmp_len);
-  if (!tmp || tmp_len != 2)
+  tmp = silc_argument_get_arg_type(payload->args, 1, NULL);
+  if (!tmp)
     return 0;
 
-  /* Check for 1.0 protocol version which didn't have `error' */
-  if (tmp[0] == 0 && tmp[1] != 0) {
-    /* Protocol 1.0 version */
-    SilcCommandStatus s;
-    SILC_GET16_MSB(s, tmp);
-    if (status)
-      *status = s;
-    if (error)
-      *error = 0;
-    if (s >= SILC_STATUS_ERR_NO_SUCH_NICK && error)
-      *error = s;
-    return (s < SILC_STATUS_ERR_NO_SUCH_NICK);
-  }
-
-  /* Take both status and possible error */
-  if (status)
-    *status = (SilcCommandStatus)tmp[0];
-  if (error)
-    *error = (SilcCommandStatus)tmp[1];
-
-  /* If single error occurred have the both `status' and `error' indicate
-     the error value for convenience. */
-  if (tmp[0] >= SILC_STATUS_ERR_NO_SUCH_NICK && error)
-    *error = tmp[0];
-
-  return (tmp[0] < SILC_STATUS_ERR_NO_SUCH_NICK && tmp[1] == SILC_STATUS_OK);
+  SILC_GET16_MSB(status, tmp);
+  return status;
 }
 
 /* Function to set identifier to already allocated Command Payload. Command
index 531f1935aa114e9c66b939c02db1d810fad226a9..a34f3d68fc87c32d975a4938b65201f9857e98fb 100644 (file)
@@ -134,7 +134,7 @@ typedef unsigned char SilcCommand;
 #define SILC_COMMAND_QUIT              8
 #define SILC_COMMAND_KILL              9
 #define SILC_COMMAND_INFO              10
-#define SILC_COMMAND_STATS             11
+#define SILC_COMMAND_CONNECT           11
 #define SILC_COMMAND_PING              12
 #define SILC_COMMAND_OPER              13
 #define SILC_COMMAND_JOIN              14
@@ -144,17 +144,13 @@ typedef unsigned char SilcCommand;
 #define SILC_COMMAND_CUMODE            18
 #define SILC_COMMAND_KICK              19
 #define SILC_COMMAND_BAN               20
-#define SILC_COMMAND_DETACH            21
+#define        SILC_COMMAND_CLOSE              21
+#define        SILC_COMMAND_SHUTDOWN           22
 #define SILC_COMMAND_SILCOPER          23
 #define SILC_COMMAND_LEAVE             24
 #define SILC_COMMAND_USERS             25
 #define SILC_COMMAND_GETKEY            26
 
-/* Private range start */
-#define SILC_COMMAND_PRIV_CONNECT       200
-#define SILC_COMMAND_PRIV_CLOSE         201
-#define SILC_COMMAND_PRIV_SHUTDOWN      202
-
 /* Reserved */
 #define SILC_COMMAND_RESERVED           255
 /***/
@@ -163,7 +159,7 @@ typedef unsigned char SilcCommand;
  *
  * NAME
  * 
- *    typedef SilcUInt8 SilcCommandStatus;
+ *    typedef SilcUInt16 SilcCommandStatus;
  *
  * DESCRIPTION
  *
@@ -173,7 +169,7 @@ typedef unsigned char SilcCommand;
  *
  * SOURCE
  */
-typedef SilcUInt8 SilcCommandStatus;
+typedef SilcUInt16 SilcCommandStatus;
 
 /* Command Status messages */
 #define SILC_STATUS_OK                      0
@@ -325,35 +321,20 @@ SilcBuffer silc_command_payload_encode_vap(SilcCommand cmd,
  *    SilcBuffer 
  *    silc_command_reply_payload_encode_va(SilcCommand cmd, 
  *                                         SilcCommandStatus status,
- *                                         SilcCommandStatus error,
  *                                         SilcUInt16 ident,
  *                                         SilcUInt32 argc, ...);
  *
  * DESCRIPTION
  *
  *    Same as silc_command_payload_encode_va except that this is used to 
- *    encode strictly command reply packets.  The `argc' must not count 
- *    `status' and `error' as arguments.  The `status' includes the
- *    command reply status.  If single reply will be sent then it includes
- *    SILC_STATUS_OK if error did not occur.  It includes an error value
- *    if error did occur.  In this case `error' field is ignored.  If
- *    there will be multiple successful command replies then the `status'
- *    includes a list value and `error' is ignored.  If there will
- *    multiple error replies the `status' includes a list value, and
- *    the `error' includes an error value.  Thus, the `error' value is
- *    specified only if there will be list of errors.
- *
- * NOTES
- *
- *    Protocol defines that it is possible to send both list of successful
- *    and list of error replies at the same time, as long as the error
- *    replies are sent after the successful replies.
+ *    encode strictly command reply packets. The command status message
+ *    to be returned is sent as extra argument to this function. The `argc'
+ *    must not count `status' as on argument.
  *
  ***/
 SilcBuffer 
 silc_command_reply_payload_encode_va(SilcCommand cmd, 
                                     SilcCommandStatus status,
-                                    SilcCommandStatus error,
                                     SilcUInt16 ident,
                                     SilcUInt32 argc, ...);
 
@@ -364,7 +345,6 @@ silc_command_reply_payload_encode_va(SilcCommand cmd,
  *    SilcBuffer 
  *    silc_command_reply_payload_encode_vap(SilcCommand cmd, 
  *                                          SilcCommandStatus status,
- *                                          SilcCommandStatus error,
  *                                          SilcUInt16 ident, SilcUInt32 argc,
  *                                          va_list ap);
  *
@@ -377,7 +357,6 @@ silc_command_reply_payload_encode_va(SilcCommand cmd,
 SilcBuffer 
 silc_command_reply_payload_encode_vap(SilcCommand cmd, 
                                      SilcCommandStatus status,
-                                     SilcCommandStatus error,
                                      SilcUInt16 ident, SilcUInt32 argc, 
                                      va_list ap);
 
@@ -441,23 +420,15 @@ SilcUInt16 silc_command_get_ident(SilcCommandPayload payload);
  *
  * SYNOPSIS
  *
- *    bool silc_command_get_status(SilcCommandPayload payload, 
- *                                 SilcCommandStatus *status,
- *                                 SilcCommandStatus *error);
+ *    SilcCommandStatus silc_command_get_status(SilcCommandPayload payload);
  *
  * DESCRIPTION
  *
- *    This function returns the command reply status into `status' and
- *    error status, if error occurred into the `error'.  The function
- *    returns TRUE if command reply status is not error, and FALSE if
- *    error occurred.  In this case the `error' will include the actual
- *    error status.  The `status' can be in this case some list value
- *    which indicates that there will be list of errors.
+ *    Returns the SilcCommandStatus from command reply payload's argument 
+ *    payload.  Status can be returned only from command reply payload.
  *
  ***/
-bool silc_command_get_status(SilcCommandPayload payload, 
-                            SilcCommandStatus *status,
-                            SilcCommandStatus *error);
+SilcCommandStatus silc_command_get_status(SilcCommandPayload payload);
 
 /****f* silccore/SilcCommandAPI/silc_command_set_ident
  *
index 6e892c087b2a8dedb675bbf4206408873fe48637..6a7fb8f2c72c38c20902cd95f137045b61b32c00 100644 (file)
@@ -62,9 +62,6 @@ SilcIDPayload silc_id_payload_parse(const unsigned char *payload,
   if (ret == -1)
     goto err;
 
-  if (newp->type > SILC_ID_CHANNEL)
-    goto err;
-
   silc_buffer_pull(&buffer, 4);
 
   if (newp->len > buffer.len || newp->len > SILC_PACKET_MAX_ID_LEN)
@@ -105,9 +102,6 @@ void *silc_id_payload_parse_id(const unsigned char *data, SilcUInt32 len,
   if (ret == -1)
     return NULL;
 
-  if (type > SILC_ID_CHANNEL)
-    return NULL;
-
   silc_buffer_pull(&buffer, 4);
 
   if (idlen > buffer.len || idlen > SILC_PACKET_MAX_ID_LEN)
@@ -215,9 +209,6 @@ unsigned char *silc_id_id2str(const void *id, SilcIdType type)
   SilcChannelID *channel_id;
   SilcUInt32 id_len = silc_id_get_len(id, type);
 
-  if (id_len > SILC_PACKET_MAX_ID_LEN)
-    return NULL;
-
   switch(type) {
   case SILC_ID_SERVER:
     server_id = (SilcServerID *)id;
@@ -260,8 +251,6 @@ unsigned char *silc_id_id2str(const void *id, SilcIdType type)
 void *silc_id_str2id(const unsigned char *id, SilcUInt32 id_len, 
                     SilcIdType type)
 {
-  if (id_len > SILC_PACKET_MAX_ID_LEN)
-    return NULL;
 
   switch(type) {
   case SILC_ID_SERVER:
index 4205ada288dc048dac48aa56884de5d3437afcb8..82141bd9f5a765cde6de2ded3edd8382dedb9200 100644 (file)
@@ -455,8 +455,7 @@ unsigned char *silc_id_id2str(const void *id, SilcIdType type);
  *    ID out of data that has been taken for example from packet.
  *
  ***/
-void *silc_id_str2id(const unsigned char *id, SilcUInt32 id_len,
-                    SilcIdType type);
+void *silc_id_str2id(const unsigned char *id, SilcUInt32 id_len, SilcIdType type);
 
 /****f* silccore/SilcIDAPI/silc_id_get_len
  *
index a56d5b4a5241024d4741d447f209f85acda12c58..4e365bf75c01d05a37644b4dd0d47986abd31c45 100644 (file)
 #define SILC_CHANNEL_MODE_CIPHER       0x0080 /* sets cipher of the channel */
 #define SILC_CHANNEL_MODE_HMAC         0x0100 /* sets hmac of the channel */
 #define SILC_CHANNEL_MODE_FOUNDER_AUTH 0x0200 /* sets founder auth data */
-#define SILC_CHANNEL_MODE_SILENCE_USERS 0x0400 /* sets founder auth data */
-#define SILC_CHANNEL_MODE_SILENCE_OPERS 0x0800 /* sets founder auth data */
 /***/
 
 /****d* silccore/Modes/ChannelUserModes
  *
  * DESCRIPTION
  *
- *    All user modes on channel.  These indicate the user's status on the
- *    channel.  Some of the modes can be set by channel founder and channel
- *    operator.  Some modes may be set by users themself.
+ *    All user modes on channel
  *
  * SOURCE
  */
-#define SILC_CHANNEL_UMODE_NONE            0x00000000 /* Normal user */
-#define SILC_CHANNEL_UMODE_CHANFO          0x00000001 /* channel founder */
-#define SILC_CHANNEL_UMODE_CHANOP          0x00000002 /* channel operator */
-#define SILC_CHANNEL_UMODE_BLOCK_MESSAGES  0x00000004 /* messages blocked */
+#define SILC_CHANNEL_UMODE_NONE        0x0000 /* Normal user */
+#define SILC_CHANNEL_UMODE_CHANFO      0x0001 /* channel founder */
+#define SILC_CHANNEL_UMODE_CHANOP      0x0002 /* channel operator */
 /***/
 
 /****d* silccore/Modes/SilcUserMode
  *
  * DESCRIPTION
  *
- *    SILC User modes. These indicate the status and presence of the client
- *    in the SILC network.
+ *    SILC User modes. These indicate the status of the client in the
+ *    SILC network.
  *
  * SOURCE
  */
-#define SILC_UMODE_NONE              0x00000000 /* Normal SILC user */
-#define SILC_UMODE_SERVER_OPERATOR   0x00000001 /* Server operator */
-#define SILC_UMODE_ROUTER_OPERATOR   0x00000002 /* Router (SILC) operator */
-#define SILC_UMODE_GONE              0x00000004 /* Client is gone */
-#define SILC_UMODE_INDISPOSED        0x00000008 /* Client is indisposed */
-#define SILC_UMODE_BUSY              0x00000010 /* Client is busy */
-#define SILC_UMODE_PAGE              0x00000020 /* Client requests paging */
-#define SILC_UMODE_HYPER             0x00000040 /* Client is hyper active */
-#define SILC_UMODE_ROBOT             0x00000080 /* Client is a robot */
-#define SILC_UMODE_ANONYMOUS         0x00000100 /* Client is anonymous */
-#define SILC_UMODE_BLOCK_PRIVMSG     0x00000200 /* Client blocks privmsgs */
-#define SILC_UMODE_DETACHED          0x00000400 /* Client is detached */
+#define SILC_UMODE_NONE                0x0000 /* Normal SILC user */
+#define SILC_UMODE_SERVER_OPERATOR     0x0001 /* Server operator */
+#define SILC_UMODE_ROUTER_OPERATOR     0x0002 /* Router (SILC) operator */
+#define SILC_UMODE_GONE                0x0004 /* Client is gone */
 /***/
 
 #endif
index 56312006ddeb3d29157e344f810bc0faf739579d..7c3f2b0d90cb40a5f0a49d5646f3b3209f923571 100644 (file)
@@ -585,7 +585,6 @@ SilcPacketType silc_packet_parse(SilcPacketContext *ctx, SilcCipher cipher)
   SilcBuffer buffer = ctx->buffer;
   SilcUInt8 tmp;
   int len, ret;
-  SilcUInt8 src_id_len, src_id_type, dst_id_len, dst_id_type, padlen;
 
   SILC_LOG_DEBUG(("Parsing incoming packet"));
 
@@ -600,46 +599,34 @@ SilcPacketType silc_packet_parse(SilcPacketContext *ctx, SilcCipher cipher)
                             SILC_STR_UI_SHORT(&ctx->truelen),
                             SILC_STR_UI_CHAR(&ctx->flags),
                             SILC_STR_UI_CHAR(&ctx->type),
-                            SILC_STR_UI_CHAR(&padlen),
+                            SILC_STR_UI_CHAR(&ctx->padlen),
                             SILC_STR_UI_CHAR(&tmp),
-                            SILC_STR_UI_CHAR(&src_id_len),
-                            SILC_STR_UI_CHAR(&dst_id_len),
-                            SILC_STR_UI_CHAR(&src_id_type),
+                            SILC_STR_UI_CHAR(&ctx->src_id_len),
+                            SILC_STR_UI_CHAR(&ctx->dst_id_len),
+                            SILC_STR_UI_CHAR(&ctx->src_id_type),
                             SILC_STR_END);
   if (len == -1 || tmp != 0)
     return SILC_PACKET_NONE;
 
-  if (src_id_len > SILC_PACKET_MAX_ID_LEN ||
-      dst_id_len > SILC_PACKET_MAX_ID_LEN) {
+  if (ctx->src_id_len > SILC_PACKET_MAX_ID_LEN ||
+      ctx->dst_id_len > SILC_PACKET_MAX_ID_LEN) {
     SILC_LOG_ERROR(("Bad ID lengths in packet (%d and %d)",
-                   src_id_len, dst_id_len));
+                   ctx->src_id_len, ctx->dst_id_len));
     return SILC_PACKET_NONE;
   }
 
   silc_buffer_pull(buffer, len);
   ret = silc_buffer_unformat(buffer, 
                             SILC_STR_UI_XNSTRING_ALLOC(&ctx->src_id,
-                                                       src_id_len),
-                            SILC_STR_UI_CHAR(&dst_id_type),
+                                                       ctx->src_id_len),
+                            SILC_STR_UI_CHAR(&ctx->dst_id_type),
                             SILC_STR_UI_XNSTRING_ALLOC(&ctx->dst_id,
-                                                       dst_id_len),
-                            SILC_STR_UI_XNSTRING(NULL, padlen),
+                                                       ctx->dst_id_len),
+                            SILC_STR_UI_XNSTRING(NULL, ctx->padlen),
                             SILC_STR_END);
   if (ret == -1)
     return SILC_PACKET_NONE;
 
-  if (src_id_type > SILC_ID_CHANNEL || dst_id_type > SILC_ID_CHANNEL) {
-    SILC_LOG_ERROR(("Bad ID types in packet (%d and %d)",
-                  src_id_type, dst_id_type));
-    return SILC_PACKET_NONE;
-  }
-
-  ctx->src_id_len = src_id_len;
-  ctx->dst_id_len = dst_id_len;
-  ctx->src_id_type = src_id_type;
-  ctx->dst_id_type = dst_id_type;
-  ctx->padlen = padlen;
-
   silc_buffer_push(buffer, len);
 
   SILC_LOG_HEXDUMP(("parsed packet, len %d", ctx->buffer->len), 
@@ -666,7 +653,6 @@ SilcPacketType silc_packet_parse_special(SilcPacketContext *ctx,
   SilcBuffer buffer = ctx->buffer;
   SilcUInt8 tmp;
   int len, ret;
-  SilcUInt8 src_id_len, src_id_type, dst_id_len, dst_id_type, padlen;
 
   SILC_LOG_DEBUG(("Parsing incoming packet"));
 
@@ -681,50 +667,38 @@ SilcPacketType silc_packet_parse_special(SilcPacketContext *ctx,
                             SILC_STR_UI_SHORT(&ctx->truelen),
                             SILC_STR_UI_CHAR(&ctx->flags),
                             SILC_STR_UI_CHAR(&ctx->type),
-                            SILC_STR_UI_CHAR(&padlen),
+                            SILC_STR_UI_CHAR(&ctx->padlen),
                             SILC_STR_UI_CHAR(&tmp),
-                            SILC_STR_UI_CHAR(&src_id_len),
-                            SILC_STR_UI_CHAR(&dst_id_len),
-                            SILC_STR_UI_CHAR(&src_id_type),
+                            SILC_STR_UI_CHAR(&ctx->src_id_len),
+                            SILC_STR_UI_CHAR(&ctx->dst_id_len),
+                            SILC_STR_UI_CHAR(&ctx->src_id_type),
                             SILC_STR_END);
   if (len == -1 || tmp != 0) {
     SILC_LOG_ERROR(("Malformed packet header, packet dropped"));
     return SILC_PACKET_NONE;
   }
 
-  if (src_id_len > SILC_PACKET_MAX_ID_LEN ||
-      dst_id_len > SILC_PACKET_MAX_ID_LEN) {
+  if (ctx->src_id_len > SILC_PACKET_MAX_ID_LEN ||
+      ctx->dst_id_len > SILC_PACKET_MAX_ID_LEN) {
     SILC_LOG_ERROR(("Bad ID lengths in packet (%d and %d)",
-                   src_id_len, dst_id_len));
+                   ctx->src_id_len, ctx->dst_id_len));
     return SILC_PACKET_NONE;
   }
 
   silc_buffer_pull(buffer, len);
   ret = silc_buffer_unformat(buffer, 
                             SILC_STR_UI_XNSTRING_ALLOC(&ctx->src_id,
-                                                       src_id_len),
-                            SILC_STR_UI_CHAR(&dst_id_type),
+                                                       ctx->src_id_len),
+                            SILC_STR_UI_CHAR(&ctx->dst_id_type),
                             SILC_STR_UI_XNSTRING_ALLOC(&ctx->dst_id,
-                                                       dst_id_len),
-                            SILC_STR_UI_XNSTRING(NULL, padlen),
+                                                       ctx->dst_id_len),
+                            SILC_STR_UI_XNSTRING(NULL, ctx->padlen),
                             SILC_STR_END);
   if (ret == -1) {
     SILC_LOG_ERROR(("Malformed packet header, packet dropped"));
     return SILC_PACKET_NONE;
   }
 
-  if (src_id_type > SILC_ID_CHANNEL || dst_id_type > SILC_ID_CHANNEL) {
-    SILC_LOG_ERROR(("Bad ID types in packet (%d and %d)",
-                  src_id_type, dst_id_type));
-    return SILC_PACKET_NONE;
-  }
-
-  ctx->src_id_len = src_id_len;
-  ctx->dst_id_len = dst_id_len;
-  ctx->src_id_type = src_id_type;
-  ctx->dst_id_type = dst_id_type;
-  ctx->padlen = padlen;
-
   silc_buffer_push(buffer, len);
 
   SILC_LOG_HEXDUMP(("parsed packet, len %d", ctx->buffer->len), 
index a1e64a88c60fd3bc20a90931090ac3d5d2855d20..e3c4b6ea6174464585accc969666629a8608c47f 100644 (file)
@@ -100,7 +100,6 @@ typedef unsigned char SilcPacketType;
 #define SILC_PACKET_KEY_AGREEMENT        25      /* Key Agreement request */
 #define SILC_PACKET_RESUME_ROUTER        26      /* Backup router resume */
 #define SILC_PACKET_FTP                  27      /* File Transfer */
-#define SILC_PACKET_RESUME_CLIENT        28      /* Client resume */
 
 #define SILC_PACKET_PRIVATE              200     /* Private range start  */
 #define SILC_PACKET_MAX                  255     /* RESERVED */
@@ -165,81 +164,73 @@ typedef unsigned char SilcPacketFlags;
  *
  *    Short description of the fields following:
  *
- *    SilcUInt16 truelen
- *
- *      True length of the packet.  This may be set by the caller before
- *      calling any of the silc_packet_* routines.  If not provided the
- *      library will calculate the values.
- *
- *    SilcPacketFlags flags
+ *    SilcBuffer buffer
  *
- *      Packet flags. Flags are defined above.
+ *      The data buffer.
  *
  *    SilcPacketType type
  *
  *      Type of the packet. Types are defined below.
  *
+ *    SilcPacketFlags flags
+ *
+ *      Packet flags. Flags are defined above.
+ *
  *    unsigned char *src_id
  *    SilcUInt8 src_id_len
- *    SilcUInt8 src_id_type
+ *    unsigned char src_id_type
  *
  *      Source ID, its length and type. On packet reception retuned ID's
  *      are always the hash values of the ID's from the packet.
  *
  *    unsigned char *dst_id;
  *    SilcUInt8 dst_id_len;
- *    SilcUInt8 src_id_type;
+ *    unsigned char src_id_type;
  *
  *      Destination ID, its length and type. On packet reception retuned
  *      ID's are always the hash values of the ID's from the packet.
  *
- *    bool long_pad
- * 
- *      If set to TRUE the packet will include the maximum padding allowed
- *      in SILC packet, which is 128 bytes.  If FALSE only the amount of
- *      padding needed will be applied.
+ *    SilcUInt16 truelen
+ *    SilcUInt8 padlen
  *
- *    SilcUInt16 users;
+ *      The true lenght of the packet and the padded length of the packet.
+ *      These may be set by the caller before calling any of the 
+ *      silc_packet_* routines. If not provided the library will calculate
+ *      the values.
+ *
+ *    int users;
  *
  *      Reference counter for this context. The context is freed only 
  *      after the reference counter hits zero. The counter is added
  *      calling silc_packet_context_dup and decreased by calling the
  *      silc_packet_context_free.
  *
- *    SilcUInt8 padlen
- *
- *      The padded length of the packet.  This may be set by the caller
- *      before calling any of the silc_packet_* routines. If not provided
- *      the library will calculate the values.
- *
  *    SilcUInt32 sequence;
  *
- *      Packet sequence number.  Set only when this context is a parsed
- *      packet.
- *
- *    SilcBuffer buffer
- *
- *      The actual packet data.  Set only when this context is a parsed
- *      packet.
+ *      Packet sequence number.
  *
  ***/
 typedef struct {
+  SilcBuffer buffer;
+
   SilcUInt16 truelen;
   SilcPacketFlags flags;
   SilcPacketType type;
+  SilcUInt8 padlen;
 
   unsigned char *src_id;
+  SilcUInt8 src_id_len;
+  SilcUInt8 src_id_type;
+
   unsigned char *dst_id;
-  unsigned int src_id_len : 5;
-  unsigned int src_id_type : 2;
-  unsigned int dst_id_len : 5;
-  unsigned int dst_id_type : 2;
-  unsigned int long_pad : 1;     /* Set when maximum padding in packet */
-  unsigned int users : 9;        /* Reference counter */
-  unsigned int padlen : 8;
+  SilcUInt8 dst_id_len;
+  SilcUInt8 dst_id_type;
+
+  int users;
+  bool long_pad;               /* Set to TRUE to use maximum padding
+                                  in packet (up to 256 bytes). */
 
   SilcUInt32 sequence;
-  SilcBuffer buffer;
 } SilcPacketContext;
 
 /****s* silccore/SilcPacketAPI/SilcPacketParserContext
index ba13a02234d91ca6f72f96b958f4562e68247e0c..27e63395a30f9e27efc0d410235e2984b89b73ff 100644 (file)
@@ -90,7 +90,7 @@ const SilcCipherObject silc_default_ciphers[] =
    registered. Therefore, if memory has been allocated for the object sent
    as argument it has to be free'd after this function returns succesfully. */
 
-bool silc_cipher_register(const SilcCipherObject *cipher)
+bool silc_cipher_register(SilcCipherObject *cipher)
 {
 #ifndef SILC_EPOC
   SilcCipherObject *new;
@@ -168,7 +168,7 @@ bool silc_cipher_register_default(void)
   int i;
 
   for (i = 0; silc_default_ciphers[i].name; i++)
-    silc_cipher_register(&(silc_default_ciphers[i]));
+    silc_cipher_register((SilcCipherObject *)&(silc_default_ciphers[i]));
 
 #endif /* SILC_EPOC */
   return TRUE;
index f33ef64f3f24cc9dad60bf391cdeb453dd1c428a..3c1d549aca3b2efe1034df22f5b42680b888c8ef 100644 (file)
@@ -117,7 +117,7 @@ bool silc_##cipher##_decrypt_cbc(void *context,                     \
 SilcUInt32 silc_##cipher##_context_len()
 
 /* Prototypes */
-bool silc_cipher_register(const SilcCipherObject *cipher);
+bool silc_cipher_register(SilcCipherObject *cipher);
 bool silc_cipher_unregister(SilcCipherObject *cipher);
 bool silc_cipher_register_default(void);
 bool silc_cipher_alloc(const unsigned char *name, SilcCipher *new_cipher);
index 5e740df5c9baebe29d528b3997e38ee321dc05f9..4ec2a925d0f39ca68134695c7a61beb5b8e4157f 100644 (file)
@@ -43,7 +43,7 @@ const SilcHashObject silc_default_hash[] =
 /* Registers a new hash function into the SILC. This function is used at
    the initialization of the SILC. */
 
-bool silc_hash_register(const SilcHashObject *hash)
+bool silc_hash_register(SilcHashObject *hash)
 {
 #ifndef SILC_EPOC
   SilcHashObject *new;
@@ -119,7 +119,7 @@ bool silc_hash_register_default(void)
   int i;
 
   for (i = 0; silc_default_hash[i].name; i++)
-    silc_hash_register(&(silc_default_hash[i]));
+    silc_hash_register((SilcHashObject *)&(silc_default_hash[i]));
 
 #endif /* SILC_EPOC */
   return TRUE;
index cf4a6be4a7e4dd4c6c7a7216acaa5023ce6ff5f6..c5091240990ee53e4c978fb9f614d0a56d967446 100644 (file)
@@ -84,7 +84,7 @@ void silc_##hash##_transform(SilcUInt32 *state,                       \
 SilcUInt32 silc_##hash##_context_len()
 
 /* Prototypes */
-bool silc_hash_register(const SilcHashObject *hash);
+bool silc_hash_register(SilcHashObject *hash);
 bool silc_hash_unregister(SilcHashObject *hash);
 bool silc_hash_register_default(void);
 bool silc_hash_alloc(const unsigned char *name, SilcHash *new_hash);
index dfde14da034cb6333c9da80c2863d9c6cf0759c5..21bb1e5f94a73e29dfa252dfd3c93421f702a35d 100644 (file)
@@ -82,7 +82,7 @@ static void silc_hmac_init_internal(SilcHmac hmac, unsigned char *key,
 /* Registers a new HMAC into the SILC. This function is used at the
    initialization of the SILC. */
 
-bool silc_hmac_register(const SilcHmacObject *hmac)
+bool silc_hmac_register(SilcHmacObject *hmac)
 {
 #ifndef SILC_EPOC
   SilcHmacObject *new;
@@ -152,7 +152,7 @@ bool silc_hmac_register_default(void)
   int i;
 
   for (i = 0; silc_default_hmacs[i].name; i++)
-    silc_hmac_register(&(silc_default_hmacs[i]));
+    silc_hmac_register((SilcHmacObject *)&(silc_default_hmacs[i]));
 
 #endif /* SILC_EPOC */
   return TRUE;
index ae9ab2e3d35b4cdfdc4c9b0e3e0833de6ecad17f..a64b5366f0b5693d6dacf55c75672b1ab0dd2bbd 100644 (file)
@@ -84,7 +84,7 @@ extern DLLAPI const SilcHmacObject silc_default_hmacs[];
  *
  * SYNOPSIS
  *
- *    bool silc_hmac_register(const SilcHmacObject *hmac);
+ *    bool silc_hmac_register(SilcHmacObject *hmac);
  *
  * DESCRIPTION
  *
@@ -97,7 +97,7 @@ extern DLLAPI const SilcHmacObject silc_default_hmacs[];
  *    that are builtin the sources.  Returns FALSE on error.
  *
  ***/
-bool silc_hmac_register(const SilcHmacObject *hmac);
+bool silc_hmac_register(SilcHmacObject *hmac);
 
 /****f* silccrypt/SilcHMACAPI/silc_hmac_unregister
  *
index db3a8e2581ef882d32032b6c3140adc3f2a762e0..d61ed0c826db0ca0e7933954661cc7bd36acd35b 100644 (file)
@@ -58,7 +58,7 @@ const SilcPKCSObject silc_default_pkcs[] =
 /* Register a new PKCS into SILC. This is used at the initialization of
    the SILC. */
 
-bool silc_pkcs_register(const SilcPKCSObject *pkcs)
+bool silc_pkcs_register(SilcPKCSObject *pkcs)
 {
 #ifndef SILC_EPOC
   SilcPKCSObject *new;
@@ -128,7 +128,7 @@ bool silc_pkcs_register_default(void)
   int i;
 
   for (i = 0; silc_default_pkcs[i].name; i++)
-    silc_pkcs_register(&(silc_default_pkcs[i]));
+    silc_pkcs_register((SilcPKCSObject *)&(silc_default_pkcs[i]));
 
 #endif /* SILC_EPOC */
   return TRUE;
@@ -945,7 +945,7 @@ static int silc_pkcs_save_public_key_internal(char *filename,
   case SILC_PKCS_FILE_BIN:
     break;
   case SILC_PKCS_FILE_PEM:
-    data = silc_pem_encode_file(data, data_len);
+    data = silc_encode_pem_file(data, data_len);
     data_len = strlen(data);
     break;
   }
@@ -1008,7 +1008,7 @@ static int silc_pkcs_save_private_key_internal(char *filename,
   case SILC_PKCS_FILE_BIN:
     break;
   case SILC_PKCS_FILE_PEM:
-    data = silc_pem_encode_file(data, data_len);
+    data = silc_encode_pem_file(data, data_len);
     data_len = strlen(data);
     break;
   }
@@ -1097,7 +1097,7 @@ int silc_pkcs_load_public_key(char *filename, SilcPublicKey *public_key,
     case SILC_PKCS_FILE_BIN:
       break;
     case SILC_PKCS_FILE_PEM:
-      data = silc_pem_decode(data, len, &len);
+      data = silc_decode_pem(data, len, &len);
       memset(old, 0, data_len);
       silc_free(old);
       old = data; 
@@ -1154,7 +1154,7 @@ int silc_pkcs_load_private_key(char *filename, SilcPrivateKey *private_key,
     case SILC_PKCS_FILE_BIN:
       break;
     case SILC_PKCS_FILE_PEM:
-      data = silc_pem_decode(data, len, &len);
+      data = silc_decode_pem(data, len, &len);
       break;
     }
 
index 8e9ad2e1688a816575b6e33b422a7e30109a4d1c..15bb8b521d68d0e77bdc000ec1c3759df54b77ab 100644 (file)
@@ -172,7 +172,7 @@ int silc_##pkcs##_verify(void *context, \
                         SilcUInt32 data_len)
 
 /* Prototypes */
-bool silc_pkcs_register(const SilcPKCSObject *pkcs);
+bool silc_pkcs_register(SilcPKCSObject *pkcs);
 bool silc_pkcs_unregister(SilcPKCSObject *pkcs);
 bool silc_pkcs_register_default(void);
 bool silc_pkcs_alloc(const unsigned char *name, SilcPKCS *new_pkcs);
index 5ac53706a16739180c30dcf3fb4c145f09dd030b..621fdee7873e14973c1f5cbead303870674adbee 100644 (file)
 
 const struct SilcSFTPFilesystemOpsStruct silc_sftp_fs_memory;
 
+/* Memory filesystem entry */
 typedef struct MemFSEntryStruct {
+  char *name;                       /* Name of the entry */
+  char *data;                      /* Data of the entry */
+  bool directory;                  /* TRUE if this is directory */
+  SilcSFTPFSMemoryPerm perm;       /* Permissions */
   struct MemFSEntryStruct **entry;  /* Files and sub-directories */
-  SilcUInt32 entry_count;                  /* Number of files and sub-directories */
+  SilcUInt32 entry_count;                  /* Number of files and sub-directories */
   struct MemFSEntryStruct *parent;  /* non-NULL if `directory' is TRUE,
                                       includes parent directory. */
   unsigned long created;           /* Time of creation */
-  char *name;                       /* Name of the entry */
-  char *data;                      /* Data of the entry */
-  unsigned int directory : 1;      /* Set if this is directory */
-  unsigned int perm : 7;           /* Permissions */
 } *MemFSEntry;
 
 /* File handle. */
index 756d505d52f78f536c822ee02494d2839aa5c159..4694104599e0ad2afe2586cf8cceb6c72bd3d190 100644 (file)
@@ -81,7 +81,6 @@ void silc_ske_free(SilcSKE ske)
       silc_ske_payload_ke_free(ske->ke1_payload);
     if (ske->ke2_payload)
       silc_ske_payload_ke_free(ske->ke2_payload);
-    silc_free(ske->remote_version);
 
     /* Free rest */
     if (ske->prop) {
@@ -1217,8 +1216,6 @@ silc_ske_select_security_properties(SilcSKE ske,
     }
   }
 
-  ske->remote_version = silc_memdup(rp->version, rp->version_len);
-
   /* Flags are returned unchanged. */
   payload->flags = rp->flags;
 
@@ -2009,7 +2006,7 @@ bool silc_ske_parse_version(SilcSKE ske,
                            char **software_version_string,
                            char **vendor_version)
 {
-  return silc_parse_version_string(ske->remote_version,
+  return silc_parse_version_string(ske->start_payload->version,
                                   protocol_version, 
                                   protocol_version_string, 
                                   software_version,
index 4db724bf630713908e9dc721a434a24d263afb2f..7d0aab9e82543def58db09c3ab366d3774654ca0 100644 (file)
@@ -335,7 +335,6 @@ struct SilcSKEStruct {
   SilcSKEStartPayload *start_payload;
   SilcSKEKEPayload *ke1_payload;
   SilcSKEKEPayload *ke2_payload;
-  unsigned char *remote_version;
 
   /* Temporary copy of the KE Start Payload used in the
      HASH computation. */
index 37b0a95e1f205c2170efc2be506658b13f59d93b..66e1d3a6933cb5ecb30fc5463c98de01218439f4 100644 (file)
@@ -15,7 +15,6 @@
 @LINK=silcprotocol.html:SILC Protocol Interface
 @LINK=silcconfig.html:SILC Config Interface
 @LINK=silcfileutil.html:SILC File Util Interface
-@LINK=silcstrutil.html:SILC String Util Interface
 @LINK=silcutil.html:SILC Util Interface
 @LINK=silclist.html:SILC List Interface
 @LINK=silcdlist.html:SILC Dynamic List Interface
index 2b65ce0f3360726fcbf8ac52e3050f4f7a0d57d2..5b7f020e0d5aef7749c220f1dfdc74769d2222c2 100644 (file)
@@ -45,7 +45,6 @@ libsilcutil_a_SOURCES = \
        silcnet.c \
        silcschedule.c \
        silcfileutil.c \
-       silcstrutil.c \
        silcutil.c \
        silchashtable.c \
        silcsockconn.c  \
@@ -69,7 +68,6 @@ include_HEADERS =     \
        silcdlist.h     \
        silcfileutil.h  \
        silcutil.h      \
-       silcstrutil.h   \
        silctypes.h
 endif
 
diff --git a/lib/silcutil/beos/.cvsignore b/lib/silcutil/beos/.cvsignore
deleted file mode 100644 (file)
index 282522d..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-Makefile
-Makefile.in
diff --git a/lib/silcutil/os2/.cvsignore b/lib/silcutil/os2/.cvsignore
deleted file mode 100644 (file)
index 282522d..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-Makefile
-Makefile.in
index e0214337d7b8322b937d921d89d8ed358f5df2e4..b495296e613240dfeefec9282789a15ab2ab7743 100644 (file)
@@ -157,9 +157,7 @@ static inline
 void silc_buffer_free(SilcBuffer sb)
 {
   if (sb) {
-#ifdef SILC_DEBUG
     memset(sb->head, 'F', sb->truelen);
-#endif
     silc_free(sb->head);
     silc_free(sb);
   }
index 1435da0d97ff53aa7820b4e74e2b256edcdd6d1d..0bb65962fad2774478c7d710d86b55c01ae31027 100644 (file)
@@ -61,8 +61,7 @@ int silc_file_close(int fd)
 
 /* Writes a buffer to the file. */
 
-int silc_file_writefile(const char *filename, const char *buffer, 
-                       SilcUInt32 len)
+int silc_file_writefile(const char *filename, const char *buffer, SilcUInt32 len)
 {
   int fd;
         
index 76dcf69239ed1f92e490336ab2a05225671a2be6..2d56241e98ca7c03562bb30b7f8ff980d3b57c9f 100644 (file)
@@ -117,7 +117,7 @@ typedef struct {
  *
  ***/
 #define silc_list_init(list, type, field) \
-  __silc_list_init(&(list), silc_offsetof(type, field))
+  __silc_list_init(&(list), offsetof(type, field))
 
 static inline void __silc_list_init(SilcList *list, int offset)
 {
index db939c3ad201df748aa4f7fde12362d681245dde..345381094e3036c94a160edc6afd38e2fa263505 100644 (file)
@@ -109,12 +109,12 @@ do {                                                              \
 /* SILC Task object. Represents one task in the scheduler. */
 struct SilcTaskStruct {
   SilcUInt32 fd;
-  SilcTaskCallback callback;      /* Task callback */
-  void *context;                  /* Task callback context */
-  struct timeval timeout;         /* Set for timeout tasks */
-  unsigned int valid : 1;         /* Set when task is valid */
-  unsigned int priority : 2;      /* Priority of the task */
-  unsigned int type : 5;           /* Type of the task */
+  struct timeval timeout;
+  SilcTaskCallback callback;
+  void *context;
+  bool valid;
+  SilcTaskPriority priority;
+  SilcTaskType type;
 
   /* Pointers forming doubly linked circular list */
   struct SilcTaskStruct *next;
@@ -936,7 +936,6 @@ static void silc_task_queue_alloc(SilcTaskQueue *queue)
 static void silc_task_queue_free(SilcTaskQueue queue)
 {
   silc_mutex_free(queue->lock);
-  memset(queue, 'F', sizeof(*queue));
   silc_free(queue);
 }
 
@@ -1173,11 +1172,10 @@ static int silc_schedule_task_remove(SilcTaskQueue queue, SilcTask task)
     next = first;
 
     while(1) {
-      old = next->next;
-      silc_free(next);
-      if (old == first)
+      next = next->next;
+      silc_free(next->prev);
+      if (next == first)
        break;
-      next = old;
     }
 
     queue->task = NULL;
index f10bd8306ad34e373993902c470732f122164ace..1bc5d4a85d522788bde172967937c41cc1b3cc0f 100644 (file)
@@ -119,7 +119,7 @@ typedef struct SilcTaskStruct *SilcTask;
 typedef enum {
   /* File descriptor task that performs some event over file descriptors.
      These tasks are for example network connections. */
-  SILC_TASK_FD           = 0,
+  SILC_TASK_FD,
 
   /* Timeout tasks are tasks that are executed after the specified 
      time has elapsed. After the task is executed the task is removed
@@ -190,7 +190,7 @@ typedef enum {
      has expired only and only when every other task with higher priority 
      has already been run. For non-timeout tasks this priority behaves
      same way. Life is not fair for tasks with this priority. */
-  SILC_TASK_PRI_LOW      = 0,
+  SILC_TASK_PRI_LOW,
 
   /* Normal priority that is used mostly in SILC. This is priority that
      should always be used unless you specificly need some other priority.
index d7acdf95834fec56ec665effca95ac3846eeb539..7f6ea5f9c35ec0a6f0a02218205ed69e49549802 100644 (file)
@@ -153,9 +153,12 @@ typedef enum {
  *      Reference counter. When allocated it is set to one (1) and it won't
  *      be freed until it hits zero (0).
  *
- *    SilcSocketConnectionHB hb
+ *    char *hostname
+ *    char *ip
+ *    SilcUInt16 port
  *
- *      The heartbeat context.  If NULL, heartbeat is not performed.
+ *      Resolved hostname, IP address and port of the connection who owns
+ *      this object.
  *
  *    SilcBuffer inbuf
  *    SilcBuffer outbuf
@@ -165,12 +168,9 @@ typedef enum {
  *      inbuf buffer and outgoing data after encryption is put to the outbuf
  *      buffer.
  *
- *    char *hostname
- *    char *ip
- *    SilcUInt16 port
+ *    SilcSocketConnectionHB hb
  *
- *      Resolved hostname, IP address and port of the connection who owns
- *      this object.
+ *      The heartbeat context.  If NULL, heartbeat is not performed.
  *
  ***/
 struct SilcSocketConnectionStruct {
@@ -179,25 +179,21 @@ struct SilcSocketConnectionStruct {
   void *user_data;
   SilcProtocol protocol;
   SilcUInt32 flags;
+  SilcUInt8 sock_error;
   int users;
 
-  SilcSocketConnectionHB hb;
+  char *hostname;
+  char *ip;
+  SilcUInt16 port;
 
   SilcBuffer inbuf;
   SilcBuffer outbuf;
 
-  char *hostname;
-  char *ip;
-  SilcUInt16 port;
-  SilcUInt8 sock_error;
-  SilcUInt8 version;
+  SilcSocketConnectionHB hb;
 };
 
 /* Macros */
 
-/* Check for specific protocol version */
-#define SILC_PROTOCOL_VERSION(s, maj, min) (s->version == maj##min)
-
 /* Amount of bytes to be read from the socket connection at once. */
 #define SILC_SOCKET_READ_SIZE 16384
 
diff --git a/lib/silcutil/silcstrutil.c b/lib/silcutil/silcstrutil.c
deleted file mode 100644 (file)
index d1f0488..0000000
+++ /dev/null
@@ -1,410 +0,0 @@
-/*
-
-  silcstrutil.c 
-
-  Author: Pekka Riikonen <priikone@silcnet.org>
-
-  Copyright (C) 2002 Pekka Riikonen
-
-  This program is free software; you can redistribute it and/or modify
-  it under the terms of the GNU General Public License as published by
-  the Free Software Foundation; version 2 of the License.
-
-  This program is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  GNU General Public License for more details.
-
-*/
-/* $Id$ */
-
-#include "silcincludes.h"
-#include "silcstrutil.h"
-
-static unsigned char pem_enc[64] =
-"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-
-/* Encodes data into PEM encoding. Returns NULL terminated PEM encoded
-   data string. Note: This is originally public domain code and is
-   still PD. */
-
-char *silc_pem_encode(unsigned char *data, SilcUInt32 len)
-{
-  int i, j;
-  SilcUInt32 bits, c, char_count;
-  char *pem;
-
-  char_count = 0;
-  bits = 0;
-  j = 0;
-
-  pem = silc_calloc(((len * 8 + 5) / 6) + 5, sizeof(*pem));
-
-  for (i = 0; i < len; i++) {
-    c = data[i];
-    bits += c;
-    char_count++;
-
-    if (char_count == 3) {
-      pem[j++] = pem_enc[bits  >> 18];
-      pem[j++] = pem_enc[(bits >> 12) & 0x3f];
-      pem[j++] = pem_enc[(bits >> 6)  & 0x3f];
-      pem[j++] = pem_enc[bits & 0x3f];
-      bits = 0;
-      char_count = 0;
-    } else {
-      bits <<= 8;
-    }
-  }
-
-  if (char_count != 0) {
-    bits <<= 16 - (8 * char_count);
-    pem[j++] = pem_enc[bits >> 18];
-    pem[j++] = pem_enc[(bits >> 12) & 0x3f];
-
-    if (char_count == 1) {
-      pem[j++] = '=';
-      pem[j] = '=';
-    } else {
-      pem[j++] = pem_enc[(bits >> 6) & 0x3f];
-      pem[j] = '=';
-    }
-  }
-
-  return pem;
-}
-
-/* Same as above but puts newline ('\n') every 72 characters. */
-
-char *silc_pem_encode_file(unsigned char *data, SilcUInt32 data_len)
-{
-  int i, j;
-  SilcUInt32 len, cols;
-  char *pem, *pem2;
-
-  pem = silc_pem_encode(data, data_len);
-  len = strlen(pem);
-
-  pem2 = silc_calloc(len + (len / 72) + 1, sizeof(*pem2));
-
-  for (i = 0, j = 0, cols = 1; i < len; i++, cols++) {
-    if (cols == 72) {
-      pem2[i] = '\n';
-      cols = 0;
-      len++;
-      continue;
-    }
-
-    pem2[i] = pem[j++];
-  }
-
-  silc_free(pem);
-  return pem2;
-}
-
-/* Decodes PEM into data. Returns the decoded data. Note: This is
-   originally public domain code and is still PD. */
-
-unsigned char *silc_pem_decode(unsigned char *pem, SilcUInt32 pem_len,
-                              SilcUInt32 *ret_len)
-{
-  int i, j;
-  SilcUInt32 len, c, char_count, bits;
-  unsigned char *data;
-  static char ialpha[256], decoder[256];
-
-  for (i = 64 - 1; i >= 0; i--) {
-    ialpha[pem_enc[i]] = 1;
-    decoder[pem_enc[i]] = i;
-  }
-
-  char_count = 0;
-  bits = 0;
-  j = 0;
-
-  if (!pem_len)
-    len = strlen(pem);
-  else
-    len = pem_len;
-
-  data = silc_calloc(((len * 6) / 8), sizeof(*data));
-
-  for (i = 0; i < len; i++) {
-    c = pem[i];
-
-    if (c == '=')
-      break;
-
-    if (c > 127 || !ialpha[c])
-      continue;
-
-    bits += decoder[c];
-    char_count++;
-
-    if (char_count == 4) {
-      data[j++] = bits >> 16;
-      data[j++] = (bits >> 8) & 0xff;
-      data[j++] = bits & 0xff;
-      bits = 0;
-      char_count = 0;
-    } else {
-      bits <<= 6;
-    }
-  }
-
-  switch(char_count) {
-  case 1:
-    silc_free(data);
-    return NULL;
-    break;
-  case 2:
-    data[j++] = bits >> 10;
-    break;
-  case 3:
-    data[j++] = bits >> 16;
-    data[j++] = (bits >> 8) & 0xff;
-    break;
-  }
-
-  if (ret_len)
-    *ret_len = j;
-
-  return data;
-}
-
-/* Encodes the string `bin' of which encoding is `bin_encoding' to the
-   UTF-8 encoding into the buffer `utf8' which is of size of `utf8_size'.
-   Returns the length of the UTF-8 encoded string, or zero (0) on error.
-   By default `bin_encoding' is ASCII, and the caller needs to know the
-   encoding of the input string if it is anything else. */
-
-SilcUInt32 silc_utf8_encode(const unsigned char *bin, SilcUInt32 bin_len,
-                           SilcStringEncoding bin_encoding,
-                           unsigned char *utf8, SilcUInt32 utf8_size)
-{
-  SilcUInt32 enclen = 0, i, charval = 0;
-
-  if (!bin || !bin_len)
-    return 0;
-
-  for (i = 0; i < bin_len; i++) {
-    switch (bin_encoding) {
-    case SILC_STRING_ASCII:
-      charval = bin[i];
-      break;
-    case SILC_STRING_ASCII_ESC:
-      break;
-    case SILC_STRING_BMP:
-      break;
-    case SILC_STRING_UNIVERSAL:
-      break;
-    }
-
-    if (charval < 0x80) {
-      if (utf8) {
-       if (enclen > utf8_size)
-         return 0;
-
-       utf8[enclen] = (unsigned char)charval;
-      }
-      enclen++;
-    } else if (charval < 0x800) {
-      if (utf8) {
-       if (enclen + 2 > utf8_size)
-         return 0;
-
-       utf8[enclen    ] = (unsigned char )(((charval >> 6)  & 0x1f) | 0xc0);
-       utf8[enclen + 1] = (unsigned char )((charval & 0x3f) | 0x80);
-      }
-      enclen += 2;
-    } else if (charval < 0x10000) {
-      if (utf8) {
-       if (enclen + 3 > utf8_size)
-         return 0;
-
-       utf8[enclen    ] = (unsigned char )(((charval >> 12) & 0xf)  | 0xe0);
-       utf8[enclen + 1] = (unsigned char )(((charval >> 6)  & 0x3f) | 0x80);
-       utf8[enclen + 2] = (unsigned char )((charval & 0x3f) | 0x80);
-      }
-      enclen += 3;
-    } else if (charval < 0x200000) {
-      if (utf8) {
-       if (enclen + 4 > utf8_size)
-         return 0;
-
-       utf8[enclen    ] = (unsigned char )(((charval >> 18) & 0x7)  | 0xf0);
-       utf8[enclen + 1] = (unsigned char )(((charval >> 12) & 0x3f) | 0x80);
-       utf8[enclen + 2] = (unsigned char )(((charval >> 6)  & 0x3f) | 0x80);
-       utf8[enclen + 3] = (unsigned char )((charval & 0x3f) | 0x80);
-      }
-      enclen += 4;
-    } else if (charval < 0x4000000) {
-      if (utf8) {
-       if (enclen + 5 > utf8_size)
-         return 0;
-
-       utf8[enclen    ] = (unsigned char )(((charval >> 24) & 0x3)  | 0xf8);
-       utf8[enclen + 1] = (unsigned char )(((charval >> 18) & 0x3f) | 0x80);
-       utf8[enclen + 2] = (unsigned char )(((charval >> 12) & 0x3f) | 0x80);
-       utf8[enclen + 3] = (unsigned char )(((charval >> 6)  & 0x3f) | 0x80);
-       utf8[enclen + 4] = (unsigned char )((charval & 0x3f) | 0x80);
-      }
-      enclen += 5;
-    } else {
-      if (utf8) {
-       if (enclen + 6 > utf8_size)
-         return 0;
-
-       utf8[enclen    ] = (unsigned char )(((charval >> 30) & 0x1)  | 0xfc);
-       utf8[enclen + 1] = (unsigned char )(((charval >> 24) & 0x3f) | 0x80);
-       utf8[enclen + 2] = (unsigned char )(((charval >> 18) & 0x3f) | 0x80);
-       utf8[enclen + 3] = (unsigned char )(((charval >> 12) & 0x3f) | 0x80);
-       utf8[enclen + 4] = (unsigned char )(((charval >> 6)  & 0x3f) | 0x80);
-       utf8[enclen + 5] = (unsigned char )((charval & 0x3f) | 0x80);
-      }
-      enclen += 6;
-    }
-  }
-
-  return enclen;
-}
-
-/* Decodes UTF-8 encoded string `utf8' to string of which encoding is
-   to be `bin_encoding', into the `bin' buffer of size of `bin_size'.
-   Returns the length of the decoded buffer, or zero (0) on error.
-   By default `bin_encoding' is ASCII, and the caller needs to know to
-   which encoding the output string is to be encoded if ASCII is not
-   desired. */
-
-SilcUInt32 silc_utf8_decode(const unsigned char *utf8, SilcUInt32 utf8_len,
-                           SilcStringEncoding bin_encoding,
-                           unsigned char *bin, SilcUInt32 bin_size)
-{
-  SilcUInt32 enclen = 0, i, charval;
-
-  if (!utf8 || !utf8_len)
-    return 0;
-
-  for (i = 0; i < utf8_len; i++) {
-    if ((utf8[i] & 0x80) == 0x00) {
-      charval = utf8[i] & 0x7f;
-    } else if ((utf8[i] & 0xe0) == 0xc0) {
-      if (utf8_len < 2)
-        return 0;
-
-      if ((utf8[i + 1] & 0xc0) != 0x80)
-        return 0;
-
-      charval = (utf8[i++] & 0x1f) << 6;
-      charval |= utf8[i] & 0x3f;
-      if (charval < 0x80)
-        return 0;
-    } else if ((utf8[i] & 0xf0) == 0xe0) {
-      if (utf8_len < 3)
-        return 0;
-
-      if (((utf8[i + 1] & 0xc0) != 0x80) || 
-         ((utf8[i + 2] & 0xc0) != 0x80))
-        return 0;
-
-      charval = (utf8[i++]  & 0xf)  << 12;
-      charval |= (utf8[i++] & 0x3f) << 6;
-      charval |= utf8[i] & 0x3f;
-      if (charval < 0x800)
-        return 0;
-    } else if ((utf8[i] & 0xf8) == 0xf0) {
-      if (utf8_len < 4)
-        return 0;
-
-      if (((utf8[i + 1] & 0xc0) != 0x80) || 
-         ((utf8[i + 2] & 0xc0) != 0x80) ||
-         ((utf8[i + 3] & 0xc0) != 0x80))
-        return 0;
-
-      charval = ((SilcUInt32)(utf8[i++] & 0x7)) << 18;
-      charval |= (utf8[i++] & 0x3f) << 12;
-      charval |= (utf8[i++] & 0x3f) << 6;
-      charval |= utf8[i] & 0x3f;
-      if (charval < 0x10000)
-        return 0;
-    } else if ((utf8[i] & 0xfc) == 0xf8) {
-      if (utf8_len < 5)
-        return 0;
-
-      if (((utf8[i + 1] & 0xc0) != 0x80) || 
-         ((utf8[i + 2] & 0xc0) != 0x80) ||
-         ((utf8[i + 3] & 0xc0) != 0x80) ||
-         ((utf8[i + 4] & 0xc0) != 0x80))
-        return 0;
-
-      charval = ((SilcUInt32)(utf8[i++]  & 0x3))  << 24;
-      charval |= ((SilcUInt32)(utf8[i++] & 0x3f)) << 18;
-      charval |= ((SilcUInt32)(utf8[i++] & 0x3f)) << 12;
-      charval |= (utf8[i++] & 0x3f) << 6;
-      charval |= utf8[i] & 0x3f;
-      if (charval < 0x200000)
-        return 0;
-    } else if ((utf8[i] & 0xfe) == 0xfc) {
-      if (utf8_len < 6)
-        return 0;
-
-      if (((utf8[i + 1] & 0xc0) != 0x80) || 
-         ((utf8[i + 2] & 0xc0) != 0x80) ||
-         ((utf8[i + 3] & 0xc0) != 0x80) ||
-         ((utf8[i + 4] & 0xc0) != 0x80) ||
-         ((utf8[i + 5] & 0xc0) != 0x80))
-        return 0;
-
-      charval = ((SilcUInt32)(utf8[i++]  & 0x1))  << 30;
-      charval |= ((SilcUInt32)(utf8[i++] & 0x3f)) << 24;
-      charval |= ((SilcUInt32)(utf8[i++] & 0x3f)) << 18;
-      charval |= ((SilcUInt32)(utf8[i++] & 0x3f)) << 12;
-      charval |= (utf8[i++] & 0x3f) << 6;
-      charval |= utf8[i] & 0x3f;
-      if (charval < 0x4000000)
-        return 0;
-    } else {
-      return 0;
-    }
-
-    switch (bin_encoding) {
-    case SILC_STRING_ASCII:
-      if (bin) {
-        if (enclen + 1 > bin_size)
-          return 0;
-
-        bin[enclen] = (unsigned char)charval;
-      }
-      enclen++;
-      break;
-    case SILC_STRING_ASCII_ESC:
-      return 0;
-      break;
-    case SILC_STRING_BMP:
-      return 0;
-      break;
-    case SILC_STRING_UNIVERSAL:
-      return 0;
-      break;
-    }
-  }
-
-  return enclen;
-}
-
-/* Returns the length of UTF-8 encoded string if the `bin' of
-   encoding of `bin_encoding' is encoded with silc_utf8_encode. */
-
-SilcUInt32 silc_utf8_encoded_len(const unsigned char *bin, SilcUInt32 bin_len,
-                                SilcStringEncoding bin_encoding)
-{
-  return silc_utf8_encode(bin, bin_len, bin_encoding, NULL, 0);
-}
-
-/* Returns TRUE if the `utf8' string of length of `utf8_len' is valid
-   UTF-8 encoded string, FALSE if it is not UTF-8 encoded string. */
-
-bool silc_utf8_valid(const unsigned char *utf8, SilcUInt32 utf8_len)
-{
-  return silc_utf8_decode(utf8, utf8_len, 0, NULL, 0) != 0;
-}
diff --git a/lib/silcutil/silcstrutil.h b/lib/silcutil/silcstrutil.h
deleted file mode 100644 (file)
index 868fdc8..0000000
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
-
-  silcstrutil.h 
-
-  Author: Pekka Riikonen <priikone@silcnet.org>
-
-  Copyright (C) 2002 Pekka Riikonen
-
-  This program is free software; you can redistribute it and/or modify
-  it under the terms of the GNU General Public License as published by
-  the Free Software Foundation; version 2 of the License.
-
-  This program is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  GNU General Public License for more details.
-
-*/
-
-/****h* silcutil/SILC String Utilities
- *
- * DESCRIPTION
- *
- *    String manipulation utility routines.  These routines provides
- *    various helper functions for encoding, decoding and otherwise
- *    managing strings.
- *
- ***/
-
-#ifndef SILCSTRUTIL_H
-#define SILCSTRUTIL_H
-
-/****f* silcutil/SilcStrUtilAPI/silc_pem_encode
- *
- * SYNOPSIS
- *
- *    char *silc_pem_encode(unsigned char *data, SilcUInt32 len);
- *
- * DESCRIPTION
- *
- *    Encodes data into PEM encoding. Returns NULL terminated PEM encoded
- *    data string. Note: This is originally public domain code and is
- *    still PD.
- *
- ***/
-char *silc_pem_encode(unsigned char *data, SilcUInt32 len);
-
-/****f* silcutil/SilcStrUtilAPI/silc_pem_encode_file
- *
- * SYNOPSIS
- *
- *    char *silc_pem_encode_file(unsigned char *data, SilcUInt32 data_len);
- *
- * DESCRIPTION
- *
- *    Same as silc_pem_encode() but puts newline ('\n') every 72 characters.
- *
- ***/
-char *silc_pem_encode_file(unsigned char *data, SilcUInt32 data_len);
-
-/****f* silcutil/SilcStrUtilAPI/silc_pem_decode
- *
- * SYNOPSIS
- *
- *    unsigned char *silc_pem_decode(unsigned char *pem, SilcUInt32 pem_len,
- *                                   SilcUInt32 *ret_len);
- *
- * DESCRIPTION
- *
- *    Decodes PEM into data. Returns the decoded data. Note: This is
- *    originally public domain code and is still PD.
- *
- ***/
-unsigned char *silc_pem_decode(unsigned char *pem, SilcUInt32 pem_len,
-                              SilcUInt32 *ret_len);
-
-/****d* silcutil/SilcStrUtilAPI/SilcStringEncoding
- *
- * NAME
- * 
- *    typedef enum { ... } SilcStringEncoding;
- *
- * DESCRIPTION
- *
- *    String encoding definitions used with the UTF-8 encoding and
- *    decoding functions.
- *
- * SOURCE
- */
-typedef enum {
-  SILC_STRING_ASCII     = 0,   /* Any 8 bit ASCII encoding (default) */
-
-  /* Rest are not implemented yet */
-  SILC_STRING_ASCII_ESC = 1,   /* 7 bit ASCII (>0x7f escaped) */
-  SILC_STRING_BMP       = 2,   /* 16 bit, UCS-2, BMP, ISO/IEC 10646 */
-  SILC_STRING_UNIVERSAL = 3,   /* 32 bit, UCS-4, Universal, ISO/IEC 10646 */
-} SilcStringEncoding;
-/***/
-
-/****f* silcutil/SilcStrUtilAPI/silc_utf8_encode
- *
- * SYNOPSIS
- *
- *    SilcUInt32 silc_utf8_encode(const unsigned char *bin, SilcUInt32 bin_len,
- *                                SilcStringEncoding bin_encoding,
- *                                unsigned char *utf8, SilcUInt32 utf8_size);
- *
- * DESCRIPTION
- *
- *    Encodes the string `bin' of which encoding is `bin_encoding' to the
- *    UTF-8 encoding into the buffer `utf8' which is of size of `utf8_size'.
- *    Returns the length of the UTF-8 encoded string, or zero (0) on error.
- *    By default `bin_encoding' is ASCII, and the caller needs to know the
- *    encoding of the input string if it is anything else.
- *
- ***/
-SilcUInt32 silc_utf8_encode(const unsigned char *bin, SilcUInt32 bin_len,
-                           SilcStringEncoding bin_encoding,
-                           unsigned char *utf8, SilcUInt32 utf8_size);
-
-/****f* silcutil/SilcStrUtilAPI/silc_utf8_decode
- *
- * SYNOPSIS
- *
- *    SilcUInt32 silc_utf8_decode(const unsigned char *utf8, 
- *                                SilcUInt32 utf8_len,
- *                                SilcStringEncoding bin_encoding,
- *                                unsigned char *bin, SilcUInt32 bin_size);
- *
- * DESCRIPTION
- *
- *    Decodes UTF-8 encoded string `utf8' to string of which encoding is
- *    to be `bin_encoding', into the `bin' buffer of size of `bin_size'.
- *    Returns the length of the decoded buffer, or zero (0) on error.
- *    By default `bin_encoding' is ASCII, and the caller needs to know to
- *    which encoding the output string is to be encoded if ASCII is not
- *    desired. 
- *
- ***/
-SilcUInt32 silc_utf8_decode(const unsigned char *utf8, SilcUInt32 utf8_len,
-                           SilcStringEncoding bin_encoding,
-                           unsigned char *bin, SilcUInt32 bin_size);
-
-/****f* silcutil/SilcStrUtilAPI/silc_utf8_encoded_len
- *
- * SYNOPSIS
- *
- *    SilcUInt32 silc_utf8_encoded_len(const unsigned char *bin, 
- *                                     SilcUInt32 bin_len,
- *                                     SilcStringEncoding bin_encoding);
- *
- * DESCRIPTION
- *
- *    Returns the length of UTF-8 encoded string if the `bin' of
- *    encoding of `bin_encoding' is encoded with silc_utf8_encode.
- *
- ***/
-SilcUInt32 silc_utf8_encoded_len(const unsigned char *bin, SilcUInt32 bin_len,
-                                SilcStringEncoding bin_encoding);
-
-/****f* silcutil/SilcStrUtilAPI/silc_utf8_valid
- *
- * SYNOPSIS
- *
- *    bool silc_utf8_valid(const unsigned char *utf8, SilcUInt32 utf8_len);
- *
- * DESCRIPTION
- *
- *    Returns TRUE if the `utf8' string of length of `utf8_len' is valid
- *    UTF-8 encoded string, FALSE if it is not UTF-8 encoded string.
- *
- ***/
-bool silc_utf8_valid(const unsigned char *utf8, SilcUInt32 utf8_len);
-
-
-#endif /* SILCSTRUTIL_H */
index 04a9d88672228ad7a718c69f154f2f7b62216a9b..7c6bdd514b29437993bd7fd99669e5f6436f9fd5 100644 (file)
 #endif
 /***/
 
-#define silc_offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
+/* Define offsetof */
+#ifndef offsetof
+#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
+#endif
 
 #if SILC_SIZEOF_SHORT > 2
 #error "size of the short must be 2 bytes"
index e3778bb7b2f8b78ef25112a90f46ccac7cb0a73b..1473fc80d1619f8dfb748d59f294da60f5e9f018 100644 (file)
@@ -105,6 +105,157 @@ char *silc_to_upper(char *string)
   return ret;
 }
 
+static unsigned char pem_enc[64] =
+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+
+/* Encodes data into PEM encoding. Returns NULL terminated PEM encoded
+   data string. Note: This is originally public domain code and is
+   still PD. */
+
+char *silc_encode_pem(unsigned char *data, SilcUInt32 len)
+{
+  int i, j;
+  SilcUInt32 bits, c, char_count;
+  char *pem;
+
+  char_count = 0;
+  bits = 0;
+  j = 0;
+
+  pem = silc_calloc(((len * 8 + 5) / 6) + 5, sizeof(*pem));
+
+  for (i = 0; i < len; i++) {
+    c = data[i];
+    bits += c;
+    char_count++;
+
+    if (char_count == 3) {
+      pem[j++] = pem_enc[bits  >> 18];
+      pem[j++] = pem_enc[(bits >> 12) & 0x3f];
+      pem[j++] = pem_enc[(bits >> 6)  & 0x3f];
+      pem[j++] = pem_enc[bits & 0x3f];
+      bits = 0;
+      char_count = 0;
+    } else {
+      bits <<= 8;
+    }
+  }
+
+  if (char_count != 0) {
+    bits <<= 16 - (8 * char_count);
+    pem[j++] = pem_enc[bits >> 18];
+    pem[j++] = pem_enc[(bits >> 12) & 0x3f];
+
+    if (char_count == 1) {
+      pem[j++] = '=';
+      pem[j] = '=';
+    } else {
+      pem[j++] = pem_enc[(bits >> 6) & 0x3f];
+      pem[j] = '=';
+    }
+  }
+
+  return pem;
+}
+
+/* Same as above but puts newline ('\n') every 72 characters. */
+
+char *silc_encode_pem_file(unsigned char *data, SilcUInt32 data_len)
+{
+  int i, j;
+  SilcUInt32 len, cols;
+  char *pem, *pem2;
+
+  pem = silc_encode_pem(data, data_len);
+  len = strlen(pem);
+
+  pem2 = silc_calloc(len + (len / 72) + 1, sizeof(*pem2));
+
+  for (i = 0, j = 0, cols = 1; i < len; i++, cols++) {
+    if (cols == 72) {
+      pem2[i] = '\n';
+      cols = 0;
+      len++;
+      continue;
+    }
+
+    pem2[i] = pem[j++];
+  }
+
+  silc_free(pem);
+  return pem2;
+}
+
+/* Decodes PEM into data. Returns the decoded data. Note: This is
+   originally public domain code and is still PD. */
+
+unsigned char *silc_decode_pem(unsigned char *pem, SilcUInt32 pem_len,
+                              SilcUInt32 *ret_len)
+{
+  int i, j;
+  SilcUInt32 len, c, char_count, bits;
+  unsigned char *data;
+  static char ialpha[256], decoder[256];
+
+  for (i = 64 - 1; i >= 0; i--) {
+    ialpha[pem_enc[i]] = 1;
+    decoder[pem_enc[i]] = i;
+  }
+
+  char_count = 0;
+  bits = 0;
+  j = 0;
+
+  if (!pem_len)
+    len = strlen(pem);
+  else
+    len = pem_len;
+
+  data = silc_calloc(((len * 6) / 8), sizeof(*data));
+
+  for (i = 0; i < len; i++) {
+    c = pem[i];
+
+    if (c == '=')
+      break;
+
+    if (c > 127 || !ialpha[c])
+      continue;
+
+    bits += decoder[c];
+    char_count++;
+
+    if (char_count == 4) {
+      data[j++] = bits >> 16;
+      data[j++] = (bits >> 8) & 0xff;
+      data[j++] = bits & 0xff;
+      bits = 0;
+      char_count = 0;
+    } else {
+      bits <<= 6;
+    }
+  }
+
+  switch(char_count) {
+  case 1:
+    silc_free(data);
+    return NULL;
+    break;
+  case 2:
+    data[j++] = bits >> 10;
+    break;
+  case 3:
+    data[j++] = bits >> 16;
+    data[j++] = (bits >> 8) & 0xff;
+    break;
+  }
+
+  if (ret_len)
+    *ret_len = j;
+
+  return data;
+}
+
 /* Parse userfqdn string which is in user@fqdn format. */
 
 bool silc_parse_userfqdn(const char *string, char **left, char **right)
@@ -618,12 +769,6 @@ char *silc_client_chmode(SilcUInt32 mode, const char *cipher, const char *hmac)
   if (mode & SILC_CHANNEL_MODE_FOUNDER_AUTH)
     strncat(string, "f", 1);
 
-  if (mode & SILC_CHANNEL_MODE_SILENCE_USERS)
-    strncat(string, "m", 1);
-
-  if (mode & SILC_CHANNEL_MODE_SILENCE_OPERS)
-    strncat(string, "M", 1);
-
   if (mode & SILC_CHANNEL_MODE_CIPHER)
     strncat(string, cipher, strlen(cipher));
 
@@ -652,9 +797,6 @@ char *silc_client_chumode(SilcUInt32 mode)
   if (mode & SILC_CHANNEL_UMODE_CHANOP)
     strncat(string, "o", 1);
 
-  if (mode & SILC_CHANNEL_UMODE_BLOCK_MESSAGES)
-    strncat(string, "b", 1);
-
   return strdup(string);
 }
 
@@ -900,25 +1042,3 @@ char *silc_get_input(const char *prompt, bool echo_off)
   return NULL;
 #endif /* SILC_UNIX */
 }
-
-/* Return mode list */
-
-bool silc_get_mode_list(SilcBuffer mode_list, SilcUInt32 mode_list_count,
-                       SilcUInt32 **list)
-{
-  int i;
-
-  if (mode_list->len / 4 != mode_list_count)
-    return FALSE;
-
-  *list = silc_calloc(mode_list_count, sizeof(**list));
-
-  for (i = 0; i < mode_list_count; i++) {
-    SILC_GET32_MSB((*list)[i], mode_list->data);
-    silc_buffer_pull(mode_list, 4);
-  }
-
-  silc_buffer_push(mode_list, mode_list->data - mode_list->head);
-
-  return TRUE;
-}
index ecaf5796e326315291d3134fcf1ade643fe14383..266c4692c79f5ece622ccf918165e8559226327a 100644 (file)
@@ -21,7 +21,7 @@
  *
  * DESCRIPTION
  *
- *    Utility functions.
+ *    XXX
  *
  ***/
 
@@ -85,6 +85,50 @@ char *silc_get_time();
  ***/
 char *silc_to_upper(char *string);
 
+/****f* silcutil/SilcUtilAPI/silc_encode_pem
+ *
+ * SYNOPSIS
+ *
+ *    char *silc_encode_pem(unsigned char *data, SilcUInt32 len);
+ *
+ * DESCRIPTION
+ *
+ *    Encodes data into PEM encoding. Returns NULL terminated PEM encoded
+ *    data string. Note: This is originally public domain code and is
+ *    still PD.
+ *
+ ***/
+char *silc_encode_pem(unsigned char *data, SilcUInt32 len);
+
+/****f* silcutil/SilcUtilAPI/silc_encode_pem_file
+ *
+ * SYNOPSIS
+ *
+ *    char *silc_encode_pem_file(unsigned char *data, SilcUInt32 data_len);
+ *
+ * DESCRIPTION
+ *
+ *    Same as silc_encode_pem() but puts newline ('\n') every 72 characters.
+ *
+ ***/
+char *silc_encode_pem_file(unsigned char *data, SilcUInt32 data_len);
+
+/****f* silcutil/SilcUtilAPI/silc_decode_pem
+ *
+ * SYNOPSIS
+ *
+ *    unsigned char *silc_decode_pem(unsigned char *pem, SilcUInt32 pem_len,
+ *                                   SilcUInt32 *ret_len);
+ *
+ * DESCRIPTION
+ *
+ *    Decodes PEM into data. Returns the decoded data. Note: This is
+ *    originally public domain code and is still PD.
+ *
+ ***/
+unsigned char *silc_decode_pem(unsigned char *pem, SilcUInt32 pem_len,
+                              SilcUInt32 *ret_len);
+
 /****f* silcutil/SilcUtilAPI/silc_parse_userfqdn
  *
  * SYNOPSIS
@@ -529,22 +573,4 @@ char *silc_get_username();
  ***/
 char *silc_get_real_name();
 
-/****f* silcutil/SilcUtilAPI/silc_get_mode_list
- *
- * SYNOPSIS
- *
- *    bool silc_get_mode_list(SilcBuffer mode_list, SilcUInt32 mode_list_count,
- *                            SilcUInt32 **list);
- *
- * DESCRIPTION
- *
- *    Returns modes from list of 32 bit MSB first order values that are
- *    encoded one after the other in the `mode_list' into the `list'
- *    array.  The caller must free the returned list.  Return FALSE if
- *    there is error parsing the list.
- *
- ***/
-bool silc_get_mode_list(SilcBuffer mode_list, SilcUInt32 mode_list_count,
-                       SilcUInt32 **list);
-
 #endif /* !SILCUTIL_H */
diff --git a/lib/silcutil/symbian/.cvsignore b/lib/silcutil/symbian/.cvsignore
deleted file mode 100644 (file)
index 282522d..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-Makefile
-Makefile.in
diff --git a/lib/silcutil/unix/.cvsignore b/lib/silcutil/unix/.cvsignore
deleted file mode 100644 (file)
index 282522d..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-Makefile
-Makefile.in
diff --git a/lib/silcutil/win32/.cvsignore b/lib/silcutil/win32/.cvsignore
deleted file mode 100644 (file)
index 282522d..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-Makefile
-Makefile.in
diff --git a/prepare b/prepare
index f5cfff57183be5e2f33aa19250a525bfc3f2940a..71c75d6343baa58f0f573ca2a8ecf06a2dca4e47 100755 (executable)
--- a/prepare
+++ b/prepare
@@ -142,7 +142,7 @@ file=includes/version_internal.h
 echo "/* Automatically generated by ./prepare */" >$file
 echo "#define SILC_VERSION_STRING \"$version\"" >>$file
 echo "#define SILC_DIST_VERSION_STRING \"$dist_version\"" >>$file
-echo "#define SILC_PROTOCOL_VERSION_STRING \"SILC-1.1-$version\"" >>$file
+echo "#define SILC_PROTOCOL_VERSION_STRING \"SILC-1.0-$version\"" >>$file
 echo "#define SILC_NAME \"SILC $distribution\"" >>$file
 
 # preparing irssi
diff --git a/scripts/stripspaces.tcl b/scripts/stripspaces.tcl
deleted file mode 100755 (executable)
index 4bdcdee..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-#! /usr/bin/tcl
-#
-#  stripspaces.tcl - strip trailing spaces from source files
-#
-#  Author: Johnny Mnemonic <johnny@themnemonic.org>
-#
-#  Copyright (C) 2002 Johnny Mnemonic
-#
-#  This program is free software; you can redistribute it and/or modify
-#  it under the terms of the GNU General Public License as published by
-#  the Free Software Foundation; version 2 of the License.
-#
-#  This program is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY; without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#  GNU General Public License for more details.
-#
-
-# Procedures
-# ---
-proc do_strip_main {in_file out_file} {
-  set lines 0
-  if {[catch {set fd [open "$in_file" r]} errtmp]} {return -1}
-  if {[catch {set fw [open "$out_file" w]} errtmp]} {return -1}
-
-  while {![eof $fd]} {
-    set str [string trimright [gets $fd]]
-    if {![eof $fd]} {
-      incr lines
-      puts $fw $str;
-    }
-  }
-
-  close $fd
-  close $fw
-  return $lines
-}
-
-# Main
-# ---
-if {$argc < 1} {
-  puts stderr "Usage: `./stripspaces.tcl <file> \[output\]'"
-  puts stderr ""
-  exit 1
-}
-
-set in_file [lindex $argv 0]
-
-if {![file readable $in_file]} {
-  puts stderr "Error: Cannot open file \"$in_file\"."
-  puts stderr ""
-  exit 1
-}
-
-if {$argc > 1} {
-  set out_file [lindex $argv 1]
-} else {
-  set out_file "$in_file.strip"
-}
-
-puts stderr "Stripping trailing spaces from \"$in_file\" (output: \"$out_file\")"
-
-set ret [do_strip_main $in_file $out_file]
-
-if {$ret < 0} {
-  puts stderr "Failed. Couldn't open the input/output filename."
-  puts stderr ""
-} else {
-  puts stderr "Done. Parsed $ret lines."
-}