+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
/* 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;
/* 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) {
/* 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:
/* 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:
*
* SYNOPSIS
*
- * unsigned char *silc_id_id2str(void *id, SilcIdType type);
+ * unsigned char *silc_id_id2str(const void *id, SilcIdType type);
*
* DESCRIPTION
*
* 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
*
* 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
*
* duplicated ID.
*
***/
-void *silc_id_dup(void *id, SilcIdType type);
+void *silc_id_dup(const void *id, SilcIdType type);
#endif
/* 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,
if (ret == -1)
goto err;
+ silc_buffer_push(&buffer, 4);
+
return new;
err:
/* 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;
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),
/* 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;
/* 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;
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));
/* 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;
*
* SYNOPSIS
*
- * SilcIDPayload silc_id_payload_parse(SilcBuffer buffer);
+ * SilcIDPayload silc_id_payload_parse(const unsigned char *payload,
+ * uint32 payload_len);
*
* DESCRIPTION
*
* `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
*
* 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
*
* 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
*
*
* 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
*
* 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