updates.
[silc.git] / lib / silccore / silcpacket.h
index fe0c81f436ea9f0f8bd125139bb8a35d8d284f54..bdd4e4d676b3e15e69bbb927a6ca66d966017297 100644 (file)
@@ -59,10 +59,10 @@ typedef unsigned char SilcPacketFlags;
 /* All defined packet flags */
 #define SILC_PACKET_FLAG_NONE             0x00
 #define SILC_PACKET_FLAG_PRIVMSG_KEY      0x01
-#define SILC_PACKET_FLAG_FORWARDED        0x02
-#define SILC_PACKET_FLAG_BROADCAST        0x04
-#define SILC_PACKET_FLAG_TUNNELED         0x08
+#define SILC_PACKET_FLAG_BROADCAST        0x02
+#define SILC_PACKET_FLAG_TUNNELED         0x04
 /* Rest of flags still available
+#define SILC_PACKET_FLAG_XXX              0x08
 #define SILC_PACKET_FLAG_XXX              0x10
 #define SILC_PACKET_FLAG_XXX              0x20
 #define SILC_PACKET_FLAG_XXX              0x40
@@ -94,12 +94,19 @@ typedef unsigned char SilcPacketFlags;
        Packet flags. Flags are defined above.
 
    unsigned char *src_id
-   unsigned int src_id_len
-   SilcIdType src_id_type
+   unsigned short src_id_len
+   unsigned char src_id_type
 
        Source ID, its length and type. On packet reception retuned ID's
        are always the hash values of the ID's from the packet.
 
+  unsigned char *dst_id;
+  unsigned short dst_id_len;
+  unsigned char src_id_type;
+
+       Destination ID, its length and type. On packet reception retuned
+       ID's are always the hash values of the ID's from the packet.
+
    SilcHash hash
 
        Pointer to allocated hash object. This must be MD5 hash object.
@@ -112,15 +119,15 @@ typedef struct {
   SilcPacketFlags flags;
 
   unsigned char *src_id;
-  unsigned int src_id_len;
-  SilcIdType src_id_type;
+  unsigned short src_id_len;
+  unsigned char src_id_type;
 
   unsigned char *dst_id;
-  unsigned int dst_id_len;
-  SilcIdType dst_id_type;
+  unsigned short dst_id_len;
+  unsigned char dst_id_type;
 
-  unsigned int truelen;
-  unsigned int padlen;
+  unsigned short truelen;
+  unsigned short padlen;
 
   /* For padding generation */
   SilcRng rng;
@@ -128,6 +135,10 @@ typedef struct {
   /* Back pointers */
   void *context;
   SilcSocketConnection sock;
+
+  /* Reference count for this context. The context is free'd only
+     after the reference count is zero. */
+  int users;
 } SilcPacketContext;
 
 /* 
@@ -211,6 +222,7 @@ typedef void (*SilcPacketParserCallback)(SilcPacketParserContext
 #define SILC_PACKET_REMOVE_CHANNEL_USER  28      /* Remove user from channel */
 #define SILC_PACKET_REKEY                29
 #define SILC_PACKET_REKEY_DONE           30
+#define SILC_PACKET_SET_MODE             31      /* Set mode */
 /* #define SILC_PACKET_MAX               255 */
 
 /* Macros */
@@ -247,6 +259,8 @@ void silc_packet_receive_process(SilcSocketConnection sock,
                                 void *context);
 SilcPacketType silc_packet_parse(SilcPacketContext *ctx);
 SilcPacketType silc_packet_parse_special(SilcPacketContext *ctx);
+SilcPacketContext *silc_packet_context_alloc();
 SilcPacketContext *silc_packet_context_dup(SilcPacketContext *ctx);
+void silc_packet_context_free(SilcPacketContext *ctx);
 
 #endif