updates.
authorPekka Riikonen <priikone@silcnet.org>
Wed, 28 Mar 2001 20:57:27 +0000 (20:57 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Wed, 28 Mar 2001 20:57:27 +0000 (20:57 +0000)
CHANGES
lib/silcclient/client_channel.c
lib/silcclient/client_prvmsg.c
lib/silccore/silcchannel.c
lib/silccore/silcchannel.h

diff --git a/CHANGES b/CHANGES
index 0a8babd9850841846a43bdae980fd30fb5c8788c..f603d4365b6dbe55b4946b5317460e5732639952 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,7 +2,8 @@ Wed Mar 28 20:50:47 EEST 2001  Pekka Riikonen <priikone@poseidon.pspt.fi>
 
        * Redefined the Private Message Payload to support private message
          keys and to support the new private message flags.  Updated
-         the protocol specs.
+         the protocol specs.  Flags makes it possible to have for example
+         CTCP style messages.
 
        * Added new type SilcPrivateMessagePayload and defined an API
          for it in the lib/silcclient/silcprivate.[ch].
@@ -11,6 +12,14 @@ Wed Mar 28 20:50:47 EEST 2001  Pekka Riikonen <priikone@poseidon.pspt.fi>
          private message key set, unset and list commands with the new
          KEY command.
 
+       * Redefined the Channel Message Payload to include the channel
+         message flags (equal with private message flags) to support
+         for example CTCP style messages.
+
+       * Defined some of the message (for channel and private message)
+         flags.  Updated the protocol specs and added the flags to the
+         lib/silccore/silcchannel.h.
+
 Wed Mar 28 15:52:36 EEST 2001  Pekka Riikonen <priikone@poseidon.pspt.fi>
 
        * Added SilcKeyAgreementStatus type to the key agreement routines
index 2eec830d3f24ac3565bb154c6f31be7fc16aba9c..bec415ab8ff218d60e7916e138ea1e631f8a4a34 100644 (file)
@@ -98,9 +98,8 @@ void silc_client_send_channel_message(SilcClient client,
     silc_hash_make(client->md5hash, channel->iv, iv_len, channel->iv);
 
   /* Encode the channel payload. This also encrypts the message payload. */
-  payload = silc_channel_message_payload_encode(data_len, data, iv_len, 
-                                               channel->iv, cipher, hmac,
-                                               client->rng);
+  payload = silc_channel_message_payload_encode(0, data_len, data, iv_len, 
+                                               channel->iv, cipher, hmac);
 
   /* Get data used in packet header encryption, keys and stuff. */
   cipher = conn->send_key;
index 56748bf477e99a66b96e17168e448f8d231e528d..698f51cb36def47984e112bdfa66cae5f65626e7 100644 (file)
@@ -48,8 +48,8 @@ void silc_client_send_private_message(SilcClient client,
   SILC_LOG_DEBUG(("Sending private message"));
 
   /* Encode private message payload */
-  buffer = silc_private_message_payload_encode(strlen(conn->nickname),
-                                              conn->nickname, 0,
+  buffer = silc_private_message_payload_encode(0, strlen(conn->nickname),
+                                              conn->nickname,
                                               data_len, data,
                                               client_entry->send_key);
 
index 74265436e31032d13dfb8a98b77c508ab45976f4..5d1dd7d9261359662ba18f8578898a1c1ad37455 100644 (file)
@@ -221,6 +221,7 @@ unsigned int silc_channel_get_mode(SilcChannelPayload payload)
 /* Channel Message Payload structure. Contents of this structure is parsed
    from SILC packets. */
 struct SilcChannelMessagePayloadStruct {
+  unsigned short flags;
   unsigned short data_len;
   unsigned char *data;
   unsigned char *mac;
@@ -295,6 +296,7 @@ silc_channel_message_payload_parse(SilcBuffer buffer,
 
   /* Parse the Channel Message Payload. Ignore the padding. */
   ret = silc_buffer_unformat(buffer,
+                            SILC_STR_UI_SHORT(&new->flags),
                             SILC_STR_UI16_NSTRING_ALLOC(&new->data, 
                                                         &new->data_len),
                             SILC_STR_UI16_NSTRING(NULL, NULL),
@@ -322,13 +324,13 @@ silc_channel_message_payload_parse(SilcBuffer buffer,
    encrypted separately from other parts of the packet padding must
    be applied to the payload. */
 
-SilcBuffer silc_channel_message_payload_encode(unsigned short data_len,
+SilcBuffer silc_channel_message_payload_encode(unsigned short flags,
+                                              unsigned short data_len,
                                               unsigned char *data,
                                               unsigned short iv_len,
                                               unsigned char *iv,
                                               SilcCipher cipher,
-                                              SilcHmac hmac,
-                                              SilcRng rng)
+                                              SilcHmac hmac)
 {
   int i;
   SilcBuffer buffer;
@@ -341,7 +343,7 @@ SilcBuffer silc_channel_message_payload_encode(unsigned short data_len,
   /* Calculate length of padding. IV is not included into the calculation
      since it is not encrypted. */
   mac_len = silc_hmac_len(hmac);
-  len = 4 + data_len + mac_len;
+  len = 6 + data_len + mac_len;
   pad_len = SILC_PACKET_PADLEN((len + 2));
 
   /* Allocate channel payload buffer */
@@ -349,11 +351,12 @@ SilcBuffer silc_channel_message_payload_encode(unsigned short data_len,
   buffer = silc_buffer_alloc(len);
 
   /* Generate padding */
-  for (i = 0; i < pad_len; i++) pad[i] = silc_rng_get_byte(rng);
+  for (i = 0; i < pad_len; i++) pad[i] = silc_rng_global_get_byte();
 
   /* Encode the Channel Message Payload */
-  silc_buffer_pull_tail(buffer, 4 + data_len + pad_len);
+  silc_buffer_pull_tail(buffer, 6 + data_len + pad_len);
   silc_buffer_format(buffer, 
+                    SILC_STR_UI_SHORT(flags),
                     SILC_STR_UI_SHORT(data_len),
                     SILC_STR_UI_XNSTRING(data, data_len),
                     SILC_STR_UI_SHORT(pad_len),
@@ -365,12 +368,12 @@ SilcBuffer silc_channel_message_payload_encode(unsigned short data_len,
 
   /* Put rest of the data to the payload */
   silc_buffer_pull_tail(buffer, mac_len + iv_len);
-  silc_buffer_pull(buffer, 4 + data_len + pad_len);
+  silc_buffer_pull(buffer, 6 + data_len + pad_len);
   silc_buffer_format(buffer, 
                     SILC_STR_UI_XNSTRING(mac, mac_len),
                     SILC_STR_UI_XNSTRING(iv, iv_len),
                     SILC_STR_END);
-  silc_buffer_push(buffer, 4 + data_len + pad_len);
+  silc_buffer_push(buffer, 6 + data_len + pad_len);
 
   /* Encrypt payload of the packet. This is encrypted with the channel key. */
   silc_cipher_encrypt(cipher, buffer->data, buffer->data, 
index 50e40041dfd5488fe580244265fcf2e296889a04..2bd14d101c3f51327098eb46b51b39447d616b73 100644 (file)
@@ -35,6 +35,17 @@ typedef struct SilcChannelMessagePayloadStruct *SilcChannelMessagePayload;
    actual structure is defined in source file and is private data. */
 typedef struct SilcChannelKeyPayloadStruct *SilcChannelKeyPayload;
 
+/* The Message flag type */
+typedef unsigned short SilcMessageFlags;
+
+/* The message flags (shared by both channel and private messages) */
+#define SILC_MESSAGE_FLAG_NONE        0x0000
+#define SILC_MESSAGE_FLAG_AUTOREPLY   0x0001
+#define SILC_MESSAGE_FLAG_NOREPLY     0x0002
+#define SILC_MESSAGE_FLAG_ACTION      0x0004
+#define SILC_MESSAGE_FLAG_RESERVED    0x0008 /* to 0x0200 */
+#define SILC_MESSAGE_FLAG_PRIVATE     0x0400 /* to 0x8000 */
+
 /* Prototypes */
 SilcChannelPayload silc_channel_payload_parse(SilcBuffer buffer);
 SilcDList silc_channel_payload_parse_list(SilcBuffer buffer);
@@ -59,13 +70,13 @@ SilcChannelMessagePayload
 silc_channel_message_payload_parse(SilcBuffer buffer,
                                   SilcCipher cipher,
                                   SilcHmac hmac);
-SilcBuffer silc_channel_message_payload_encode(unsigned short data_len,
+SilcBuffer silc_channel_message_payload_encode(unsigned short flags,
+                                              unsigned short data_len,
                                               unsigned char *data,
                                               unsigned short iv_len,
                                               unsigned char *iv,
                                               SilcCipher cipher,
-                                              SilcHmac hmac,
-                                              SilcRng rng);
+                                              SilcHmac hmac);
 void silc_channel_message_payload_free(SilcChannelMessagePayload payload);
 unsigned char *silc_channel_message_get_data(SilcChannelMessagePayload payload,
                                     unsigned int *data_len);