updates.
authorPekka Riikonen <priikone@silcnet.org>
Mon, 26 Nov 2001 19:05:57 +0000 (19:05 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Mon, 26 Nov 2001 19:05:57 +0000 (19:05 +0000)
CHANGES
lib/silccore/silcid.c
lib/silccore/silcid.h
lib/silccore/silcpayload.c
lib/silccore/silcpayload.h

diff --git a/CHANGES b/CHANGES
index 12fa4ae564218e9b5b1681dd25a710289f57a545..5bd1c49ad935b96b0961d58c11a226a6678d50e3 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,30 @@
+Mon Nov 26 18:09:48 EET 2001  Pekka Riikonen <priikone@silcnet.org>'
+
+       * Fixed LIST command reply sending in server.  Affected file
+         silcd/command.c.
+
+       * Server now sends the kicker's client ID in the KICK notify
+         to the kicked client.  Affected file silcd/command.c.
+
+       * The client library now parses the kickers client ID and
+         UI displays it.  Affected files lib/silcclient/client_notify.c
+         and irssi/src/silc/core/silc-channels.c, module-formats.c.
+
+       * Made all payload parsing function prototypes consistent.
+         They all take now const unsigned char * and uint32 pair as
+         the payload data instead of SilcBuffer.  Changes all around
+         the source tree.  Other unsigned char* -> const unsigned char*
+         changes around the tree as well.
+
+       * Optimized SFTP client and server packet sending not to
+         allocate new buffer for each packet but to recycle the
+         first allocated buffer.  Affected files are
+         lib/silcsftp/sftp_client.c, sftp_server.c, sftp_util.[ch].
+
+       * Optimized the SFTP client to use SilcList instead of
+         SilcDList for requests, because it is faster.  Affected file
+         is lib/silcsftp/sftp_client.c.
+
 Mon Nov 26 15:01:53 CET 2001  Pekka Riikonen <priikone@silcnet.org>
 
        * If client entry is deleted with active key agreement
index f9ca89dcb2f439ab8776dd301e50afe5725cdc50..bdd1353d60c69417ffb5ca5ee0fc825e5d5efaf0 100644 (file)
@@ -29,7 +29,7 @@
 
 /* Converts ID to string. */
 
-unsigned char *silc_id_id2str(void *id, SilcIdType type)
+unsigned char *silc_id_id2str(const void *id, SilcIdType type)
 {
   unsigned char *ret_id;
   SilcServerID *server_id;
@@ -69,7 +69,7 @@ unsigned char *silc_id_id2str(void *id, SilcIdType type)
 
 /* Converts string to a ID */
 
-void *silc_id_str2id(unsigned char *id, uint32 id_len, SilcIdType type)
+void *silc_id_str2id(const unsigned char *id, uint32 id_len, SilcIdType type)
 {
 
   switch(type) {
@@ -131,7 +131,7 @@ void *silc_id_str2id(unsigned char *id, uint32 id_len, SilcIdType type)
 
 /* Returns length of the ID */
 
-uint32 silc_id_get_len(void *id, SilcIdType type)
+uint32 silc_id_get_len(const void *id, SilcIdType type)
 {
   switch(type) {
   case SILC_ID_SERVER:
@@ -159,7 +159,7 @@ uint32 silc_id_get_len(void *id, SilcIdType type)
 
 /* Duplicate ID data */
 
-void *silc_id_dup(void *id, SilcIdType type)
+void *silc_id_dup(const void *id, SilcIdType type)
 {
   switch(type) {
   case SILC_ID_SERVER:
index ae71ecbaa8f880837afebfeac402b7f801088aef..e28c412a408ee061af49e7165cd9951a80614206 100644 (file)
@@ -264,7 +264,7 @@ typedef struct {
  *
  * SYNOPSIS
  *
- *    unsigned char *silc_id_id2str(void *id, SilcIdType type);
+ *    unsigned char *silc_id_id2str(const void *id, SilcIdType type);
  *
  * DESCRIPTION
  *
@@ -272,13 +272,14 @@ typedef struct {
  *    convert the ID's to data for inclusion in the packets.
  *
  ***/
-unsigned char *silc_id_id2str(void *id, SilcIdType type);
+unsigned char *silc_id_id2str(const void *id, SilcIdType type);
 
 /****f* silccore/SilcIDAPI/silc_id_str2id
  *
  * SYNOPSIS
  *
- *    void *silc_id_str2id(unsigned char *id, uint32 id_len, SilcIdType type);
+ *    void *silc_id_str2id(const unsigned char *id, uint32 id_len, 
+ *                         SilcIdType type);
  *
  * DESCRIPTION
  *
@@ -286,26 +287,26 @@ unsigned char *silc_id_id2str(void *id, SilcIdType type);
  *    ID out of data that has been taken for example from packet.
  *
  ***/
-void *silc_id_str2id(unsigned char *id, uint32 id_len, SilcIdType type);
+void *silc_id_str2id(const unsigned char *id, uint32 id_len, SilcIdType type);
 
 /****f* silccore/SilcIDAPI/silc_id_get_len
  *
  * SYNOPSIS
  *
- *    uint32 silc_id_get_len(void *id, SilcIdType type);
+ *    uint32 silc_id_get_len(const void *id, SilcIdType type);
  *
  * DESCRIPTION
  *
  *    Returns the true length of the ID of the type `type'.
  *
  ***/
-uint32 silc_id_get_len(void *id, SilcIdType type);
+uint32 silc_id_get_len(const void *id, SilcIdType type);
 
 /****f* silccore/SilcIDAPI/silc_id_dup
  *
  * SYNOPSIS
  *
- *    void *silc_id_dup(void *id, SilcIdType type);
+ *    void *silc_id_dup(const void *id, SilcIdType type);
  *
  * DESCRIPTION
  *
@@ -313,6 +314,6 @@ uint32 silc_id_get_len(void *id, SilcIdType type);
  *    duplicated ID.
  *
  ***/
-void *silc_id_dup(void *id, SilcIdType type);
+void *silc_id_dup(const void *id, SilcIdType type);
 
 #endif
index dc2ad30f998423cd8025494e4204c4122db0b64b..cc7071f18a54496a48d9c67a609ecc623e5aa1a7 100644 (file)
@@ -38,55 +38,16 @@ struct SilcIDPayloadStruct {
 
 /* Parses buffer and return ID payload into payload structure */
 
-SilcIDPayload silc_id_payload_parse(SilcBuffer buffer)
+SilcIDPayload silc_id_payload_parse(const unsigned char *payload,
+                                   uint32 payload_len)
 {
-  SilcIDPayload new;
-  int ret;
-
-  SILC_LOG_DEBUG(("Parsing ID payload"));
-
-  new = silc_calloc(1, sizeof(*new));
-
-  ret = silc_buffer_unformat(buffer,
-                            SILC_STR_UI_SHORT(&new->type),
-                            SILC_STR_UI_SHORT(&new->len),
-                            SILC_STR_END);
-  if (ret == -1)
-    goto err;
-
-  silc_buffer_pull(buffer, 4);
-
-  if (new->len > buffer->len)
-    goto err;
-
-  ret = silc_buffer_unformat(buffer,
-                            SILC_STR_UI_XNSTRING_ALLOC(&new->id, new->len),
-                            SILC_STR_END);
-  if (ret == -1)
-    goto err;
-
-  silc_buffer_push(buffer, 4);
-
-  return new;
-
- err:
-  silc_free(new);
-  return NULL;
-}
-
-/* Parses data and return ID payload into payload structure. */
-
-SilcIDPayload silc_id_payload_parse_data(unsigned char *data, 
-                                        uint32 len)
-{
-  SilcIDPayload new;
   SilcBufferStruct buffer;
+  SilcIDPayload new;
   int ret;
 
   SILC_LOG_DEBUG(("Parsing ID payload"));
 
-  silc_buffer_set(&buffer, data, len);
-
+  silc_buffer_set(&buffer, (unsigned char *)payload, payload_len);
   new = silc_calloc(1, sizeof(*new));
 
   ret = silc_buffer_unformat(&buffer,
@@ -107,6 +68,8 @@ SilcIDPayload silc_id_payload_parse_data(unsigned char *data,
   if (ret == -1)
     goto err;
 
+  silc_buffer_push(&buffer, 4);
+
   return new;
 
  err:
@@ -116,7 +79,7 @@ SilcIDPayload silc_id_payload_parse_data(unsigned char *data,
 
 /* Return the ID directly from the raw payload data. */
 
-void *silc_id_payload_parse_id(unsigned char *data, uint32 len)
+void *silc_id_payload_parse_id(const unsigned char *data, uint32 len)
 {
   SilcBufferStruct buffer;
   SilcIdType type;
@@ -125,8 +88,7 @@ void *silc_id_payload_parse_id(unsigned char *data, uint32 len)
   int ret;
   void *id;
 
-  silc_buffer_set(&buffer, data, len);
-
+  silc_buffer_set(&buffer, (unsigned char *)data, len);
   ret = silc_buffer_unformat(&buffer,
                             SILC_STR_UI_SHORT(&type),
                             SILC_STR_UI_SHORT(&idlen),
@@ -155,7 +117,7 @@ void *silc_id_payload_parse_id(unsigned char *data, uint32 len)
 
 /* Encodes ID Payload */
 
-SilcBuffer silc_id_payload_encode(void *id, SilcIdType type)
+SilcBuffer silc_id_payload_encode(const void *id, SilcIdType type)
 {
   SilcBuffer buffer;
   unsigned char *id_data;
@@ -250,11 +212,13 @@ struct SilcArgumentPayloadStruct {
 
 /* Parses arguments and returns them into Argument Payload structure. */
 
-SilcArgumentPayload silc_argument_payload_parse(SilcBuffer buffer,
+SilcArgumentPayload silc_argument_payload_parse(const unsigned char *payload,
+                                               uint32 payload_len,
                                                uint32 argc)
 {
+  SilcBufferStruct buffer;
   SilcArgumentPayload new;
-  uint16 payload_len = 0;
+  uint16 p_len = 0;
   unsigned char arg_num = 0;
   unsigned char arg_type = 0;
   uint32 pull_len = 0;
@@ -262,6 +226,7 @@ SilcArgumentPayload silc_argument_payload_parse(SilcBuffer buffer,
 
   SILC_LOG_DEBUG(("Parsing argument payload"));
 
+  silc_buffer_set(&buffer, (unsigned char *)payload, payload_len);
   new = silc_calloc(1, sizeof(*new));
   new->argv = silc_calloc(argc, sizeof(unsigned char *));
   new->argv_lens = silc_calloc(argc, sizeof(uint32));
@@ -270,39 +235,39 @@ SilcArgumentPayload silc_argument_payload_parse(SilcBuffer buffer,
   /* Get arguments */
   arg_num = 1;
   for (i = 0; i < argc; i++) {
-    ret = silc_buffer_unformat(buffer,
-                              SILC_STR_UI_SHORT(&payload_len),
+    ret = silc_buffer_unformat(&buffer,
+                              SILC_STR_UI_SHORT(&p_len),
                               SILC_STR_UI_CHAR(&arg_type),
                               SILC_STR_END);
     if (ret == -1)
       goto err;
     
-    new->argv_lens[i] = payload_len;
+    new->argv_lens[i] = p_len;
     new->argv_types[i] = arg_type;
 
-    if (payload_len > buffer->len - 3)
+    if (p_len > buffer.len - 3)
       break;
     
     /* Get argument data */
-    silc_buffer_pull(buffer, 3);
-    ret = silc_buffer_unformat(buffer,
+    silc_buffer_pull(&buffer, 3);
+    ret = silc_buffer_unformat(&buffer,
                               SILC_STR_UI_XNSTRING_ALLOC(&new->argv[i], 
-                                                         payload_len),
+                                                         p_len),
                               SILC_STR_END);
     if (ret == -1)
       goto err;
 
-    silc_buffer_pull(buffer, payload_len);
-    pull_len += 3 + payload_len;
+    silc_buffer_pull(&buffer, p_len);
+    pull_len += 3 + p_len;
   }
 
-  if (buffer->len != 0)
+  if (buffer.len != 0)
     goto err;
 
   new->argc = argc;
   new->pos = 0;
 
-  silc_buffer_push(buffer, pull_len);
+  silc_buffer_push(&buffer, pull_len);
 
   return new;
 
index 8f81e53852e55b797ce5aa9b6be4360fd0f117aa..e8a96f7ee75f9ca529de74e797992f1b251b8183 100644 (file)
@@ -70,7 +70,8 @@ typedef struct SilcArgumentPayloadStruct *SilcArgumentPayload;
  *
  * SYNOPSIS
  *
- *    SilcIDPayload silc_id_payload_parse(SilcBuffer buffer);
+ *    SilcIDPayload silc_id_payload_parse(const unsigned char *payload,
+ *                                        uint32 payload_len);
  *
  * DESCRIPTION
  *
@@ -78,30 +79,14 @@ typedef struct SilcArgumentPayloadStruct *SilcArgumentPayload;
  *    `buffer' is raw payload buffer.
  *
  ***/
-SilcIDPayload silc_id_payload_parse(SilcBuffer buffer);
-
-/****f* silccore/SilcGenericPayloadAPI/silc_id_payload_parse_data
- *
- * SYNOPSIS
- *
- *    SilcIDPayload silc_id_payload_parse_data(unsigned char *data, 
- *                                             uint32 len);
- *
- * DESCRIPTION
- *
- *    Parses buffer and return ID payload into payload structure. The
- *    `data' and `len' are the raw payload buffer. This is equivalent
- *    to the silc_id_payload_parse function.
- *
- ***/
-SilcIDPayload silc_id_payload_parse_data(unsigned char *data, 
-                                        uint32 len);
+SilcIDPayload silc_id_payload_parse(const unsigned char *payload,
+                                   uint32 payload_len);
 
 /****f* silccore/SilcGenericPayloadAPI/silc_id_payload_parse_id
  *
  * SYNOPSIS
  *
- *    void *silc_id_payload_parse_id(unsigned char *data, uint32 len);
+ *    void *silc_id_payload_parse_id(const unsigned char *data, uint32 len);
  *
  * DESCRIPTION
  *
@@ -109,13 +94,13 @@ SilcIDPayload silc_id_payload_parse_data(unsigned char *data,
  *    caller must free the returned ID.
  *
  ***/
-void *silc_id_payload_parse_id(unsigned char *data, uint32 len);
+void *silc_id_payload_parse_id(const unsigned char *data, uint32 len);
 
 /****f* silccore/SilcGenericPayloadAPI/silc_id_payload_encode
  *
  * SYNOPSIS
  *
- *    SilcBuffer silc_id_payload_encode(void *id, SilcIdType type);
+ *    SilcBuffer silc_id_payload_encode(const void *id, SilcIdType type);
  *
  * DESCRIPTION
  *
@@ -123,7 +108,7 @@ void *silc_id_payload_parse_id(unsigned char *data, uint32 len);
  *    into the payload. Returns the encoded payload buffer.
  *
  ***/
-SilcBuffer silc_id_payload_encode(void *id, SilcIdType type);
+SilcBuffer silc_id_payload_encode(const void *id, SilcIdType type);
 
 /****f* silccore/SilcGenericPayloadAPI/silc_id_payload_encode_data
  *
@@ -213,8 +198,10 @@ uint32 silc_id_payload_get_len(SilcIDPayload payload);
  *
  * SYNOPSIS
  *
- *    SilcArgumentPayload silc_argument_payload_parse(SilcBuffer buffer,
- *                                                    uint32 argc);
+ *    SilcArgumentPayload 
+ *    silc_argument_payload_parse(const unsigned char *payload,
+ *                                uint32 payload_len,
+ *                                uint32 argc);
  *
  * DESCRIPTION
  *
@@ -226,7 +213,8 @@ uint32 silc_id_payload_get_len(SilcIDPayload payload);
  *    the number of the arguments.
  *
  ***/
-SilcArgumentPayload silc_argument_payload_parse(SilcBuffer buffer,
+SilcArgumentPayload silc_argument_payload_parse(const unsigned char *payload,
+                                               uint32 payload_len,
                                                uint32 argc);
 
 /****f* silccore/SilcGenericPayloadAPI/silc_argument_payload_encode