projects
/
silc.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Integer type name change.
[silc.git]
/
lib
/
silccore
/
silcprivate.c
diff --git
a/lib/silccore/silcprivate.c
b/lib/silccore/silcprivate.c
index 60534f6be8735c332d7ca31d4bb943be5914dd4b..26a064297028477ee2dba73f94da60fce0220509 100644
(file)
--- a/
lib/silccore/silcprivate.c
+++ b/
lib/silccore/silcprivate.c
@@
-34,8
+34,8
@@
/* Private Message Payload structure. Contents of this structure is parsed
from SILC packets. */
struct SilcPrivateMessagePayloadStruct {
/* Private Message Payload structure. Contents of this structure is parsed
from SILC packets. */
struct SilcPrivateMessagePayloadStruct {
-
ui
nt16 flags;
-
ui
nt16 message_len;
+
SilcUI
nt16 flags;
+
SilcUI
nt16 message_len;
unsigned char *message;
};
unsigned char *message;
};
@@
-43,22
+43,27
@@
struct SilcPrivateMessagePayloadStruct {
structure. This also decrypts the message if the `cipher' is provided. */
SilcPrivateMessagePayload
structure. This also decrypts the message if the `cipher' is provided. */
SilcPrivateMessagePayload
-silc_private_message_payload_parse(SilcBuffer buffer, SilcCipher cipher)
+silc_private_message_payload_parse(unsigned char *payload,
+ SilcUInt32 payload_len,
+ SilcCipher cipher)
{
{
+ SilcBufferStruct buffer;
SilcPrivateMessagePayload new;
int ret;
SILC_LOG_DEBUG(("Parsing private message payload"));
SilcPrivateMessagePayload new;
int ret;
SILC_LOG_DEBUG(("Parsing private message payload"));
+ silc_buffer_set(&buffer, payload, payload_len);
+
/* Decrypt the payload */
if (cipher)
/* Decrypt the payload */
if (cipher)
- silc_cipher_decrypt(cipher, buffer
->data, buffer->
data,
- buffer
->
len, cipher->iv);
+ silc_cipher_decrypt(cipher, buffer
.data, buffer.
data,
+ buffer
.
len, cipher->iv);
new = silc_calloc(1, sizeof(*new));
/* Parse the Private Message Payload. Ignore the padding. */
new = silc_calloc(1, sizeof(*new));
/* Parse the Private Message Payload. Ignore the padding. */
- ret = silc_buffer_unformat(buffer,
+ ret = silc_buffer_unformat(
&
buffer,
SILC_STR_UI_SHORT(&new->flags),
SILC_STR_UI16_NSTRING_ALLOC(&new->message,
&new->message_len),
SILC_STR_UI_SHORT(&new->flags),
SILC_STR_UI16_NSTRING_ALLOC(&new->message,
&new->message_len),
@@
-68,7
+73,7
@@
silc_private_message_payload_parse(SilcBuffer buffer, SilcCipher cipher)
goto err;
}
goto err;
}
- if ((new->message_len < 1 || new->message_len > buffer
->
len)) {
+ if ((new->message_len < 1 || new->message_len > buffer
.
len)) {
SILC_LOG_DEBUG(("Incorrect private message payload in packet, "
"packet dropped"));
goto err;
SILC_LOG_DEBUG(("Incorrect private message payload in packet, "
"packet dropped"));
goto err;
@@
-85,14
+90,14
@@
silc_private_message_payload_parse(SilcBuffer buffer, SilcCipher cipher)
the cipher is provided the packet is also encrypted here. It is provided
if the private message private keys are used. */
the cipher is provided the packet is also encrypted here. It is provided
if the private message private keys are used. */
-SilcBuffer silc_private_message_payload_encode(
ui
nt16 flags,
-
ui
nt16 data_len,
- unsigned char *data,
+SilcBuffer silc_private_message_payload_encode(
SilcUI
nt16 flags,
+
SilcUI
nt16 data_len,
+
const
unsigned char *data,
SilcCipher cipher)
{
int i;
SilcBuffer buffer;
SilcCipher cipher)
{
int i;
SilcBuffer buffer;
-
ui
nt32 len, pad_len = 0;
+
SilcUI
nt32 len, pad_len = 0;
unsigned char pad[16];
SILC_LOG_DEBUG(("Encoding private message payload"));
unsigned char pad[16];
SILC_LOG_DEBUG(("Encoding private message payload"));
@@
-143,7
+148,7
@@
void silc_private_message_payload_free(SilcPrivateMessagePayload payload)
/* Return flags */
/* Return flags */
-
ui
nt16
+
SilcUI
nt16
silc_private_message_get_flags(SilcPrivateMessagePayload payload)
{
return payload->flags;
silc_private_message_get_flags(SilcPrivateMessagePayload payload)
{
return payload->flags;
@@
-153,7
+158,7
@@
silc_private_message_get_flags(SilcPrivateMessagePayload payload)
unsigned char *
silc_private_message_get_message(SilcPrivateMessagePayload payload,
unsigned char *
silc_private_message_get_message(SilcPrivateMessagePayload payload,
-
ui
nt32 *message_len)
+
SilcUI
nt32 *message_len)
{
if (message_len)
*message_len = payload->message_len;
{
if (message_len)
*message_len = payload->message_len;