projects
/
silc.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
updates.
[silc.git]
/
lib
/
silccore
/
silccommand.c
diff --git
a/lib/silccore/silccommand.c
b/lib/silccore/silccommand.c
index e85c72350ff9246daf77e2dea59dafca93848a1c..ba029871df1814d1b8fdb8d040191fb647a4b347 100644
(file)
--- a/
lib/silccore/silccommand.c
+++ b/
lib/silccore/silccommand.c
@@
-41,20
+41,23
@@
struct SilcCommandPayloadStruct {
/* Parses command payload returning new command payload structure */
/* Parses command payload returning new command payload structure */
-SilcCommandPayload silc_command_payload_parse(SilcBuffer buffer)
+SilcCommandPayload silc_command_payload_parse(const unsigned char *payload,
+ uint32 payload_len)
{
{
+ SilcBufferStruct buffer;
SilcCommandPayload new;
unsigned char args_num;
SilcCommandPayload new;
unsigned char args_num;
- uint16 p
ayload
_len;
+ uint16 p_len;
int ret;
SILC_LOG_DEBUG(("Parsing command payload"));
int ret;
SILC_LOG_DEBUG(("Parsing command payload"));
+ silc_buffer_set(&buffer, (unsigned char *)payload, payload_len);
new = silc_calloc(1, sizeof(*new));
/* Parse the Command Payload */
new = silc_calloc(1, sizeof(*new));
/* Parse the Command Payload */
- ret = silc_buffer_unformat(buffer,
- SILC_STR_UI_SHORT(&p
ayload
_len),
+ ret = silc_buffer_unformat(
&
buffer,
+ SILC_STR_UI_SHORT(&p_len),
SILC_STR_UI_CHAR(&new->cmd),
SILC_STR_UI_CHAR(&args_num),
SILC_STR_UI_SHORT(&new->ident),
SILC_STR_UI_CHAR(&new->cmd),
SILC_STR_UI_CHAR(&args_num),
SILC_STR_UI_SHORT(&new->ident),
@@
-64,7
+67,7
@@
SilcCommandPayload silc_command_payload_parse(SilcBuffer buffer)
return NULL;
}
return NULL;
}
- if (p
ayload_len != buffer->
len) {
+ if (p
_len != buffer.
len) {
SILC_LOG_ERROR(("Incorrect command payload in packet, packet dropped"));
silc_free(new);
return NULL;
SILC_LOG_ERROR(("Incorrect command payload in packet, packet dropped"));
silc_free(new);
return NULL;
@@
-75,15
+78,15
@@
SilcCommandPayload silc_command_payload_parse(SilcBuffer buffer)
return NULL;
}
return NULL;
}
- silc_buffer_pull(buffer, SILC_COMMAND_PAYLOAD_LEN);
+ silc_buffer_pull(
&
buffer, SILC_COMMAND_PAYLOAD_LEN);
if (args_num) {
if (args_num) {
- new->args = silc_argument_payload_parse(buffer, args_num);
+ new->args = silc_argument_payload_parse(buffer
.data, buffer.len
, args_num);
if (!new->args) {
silc_free(new);
return NULL;
}
}
if (!new->args) {
silc_free(new);
return NULL;
}
}
- silc_buffer_push(buffer, SILC_COMMAND_PAYLOAD_LEN);
+ silc_buffer_push(
&
buffer, SILC_COMMAND_PAYLOAD_LEN);
return new;
}
return new;
}