structure optimizations again.
[silc.git] / lib / silccore / silcpacket.h
index 7912362811eed97c2bb208a6bc36c44ddea334cf..ea7dbbfb9d792b0dd42a91aa73c8ef17450a7c6c 100644 (file)
@@ -180,44 +180,46 @@ typedef unsigned char SilcPacketFlags;
  *
  *    unsigned char *src_id
  *    SilcUInt8 src_id_len
- *    unsigned char src_id_type
+ *    SilcUInt8 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;
  *    SilcUInt8 dst_id_len;
- *    unsigned char src_id_type;
+ *    SilcUInt8 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.
  *
- *    SilcUInt8 padlen
- *
- *      The padded length of the packet.  This may be set by the caller
- *      before calling any of the silc_packet_* routines. If not provided
- *      the library will calculate the values.
- *
- *    unsigned int long_pad
+ *    bool long_pad
  * 
  *      If set to TRUE the packet will include the maximum padding allowed
  *      in SILC packet, which is 128 bytes.  If FALSE only the amount of
  *      padding needed will be applied.
  *
- *    unsigned int users;
+ *    SilcUInt16 users;
  *
  *      Reference counter for this context. The context is freed only 
  *      after the reference counter hits zero. The counter is added
  *      calling silc_packet_context_dup and decreased by calling the
  *      silc_packet_context_free.
  *
+ *    SilcUInt8 padlen
+ *
+ *      The padded length of the packet.  This may be set by the caller
+ *      before calling any of the silc_packet_* routines. If not provided
+ *      the library will calculate the values.
+ *
  *    SilcUInt32 sequence;
  *
- *      Packet sequence number.
+ *      Packet sequence number.  Set only when this context is a parsed
+ *      packet.
  *
  *    SilcBuffer buffer
  *
- *      The actual packet data.
+ *      The actual packet data.  Set only when this context is a parsed
+ *      packet.
  *
  ***/
 typedef struct {
@@ -227,14 +229,13 @@ typedef struct {
 
   unsigned char *src_id;
   unsigned char *dst_id;
-  SilcUInt8 src_id_len;
-  SilcUInt8 src_id_type;
-  SilcUInt8 dst_id_len;
-  SilcUInt8 dst_id_type;
-
-  SilcUInt8 padlen;
-  unsigned int long_pad : 1;   /* Set when maximum padding in packet */
-  unsigned int users : 23;     /* Reference counter */
+  unsigned int src_id_len : 5;
+  unsigned int src_id_type : 2;
+  unsigned int dst_id_len : 5;
+  unsigned int dst_id_type : 2;
+  unsigned int long_pad : 1;     /* Set when maximum padding in packet */
+  unsigned int users : 9;        /* Reference counter */
+  unsigned int padlen : 8;
 
   SilcUInt32 sequence;
   SilcBuffer buffer;