*
* NAME
*
- * typedef unsigned char SilcPacketType;
+ * typedef SilcUInt8 SilcPacketType;
*
* DESCRIPTION
*
*
* SOURCE
*/
-typedef unsigned char SilcPacketType;
+typedef SilcUInt8 SilcPacketType;
/* SILC Packet types. */
#define SILC_PACKET_NONE 0 /* NULL, never sent */
#define SILC_PACKET_KEY_AGREEMENT 25 /* Key Agreement request */
#define SILC_PACKET_RESUME_ROUTER 26 /* Backup router resume */
#define SILC_PACKET_FTP 27 /* File Transfer */
+#define SILC_PACKET_RESUME_CLIENT 28 /* Client resume */
#define SILC_PACKET_PRIVATE 200 /* Private range start */
#define SILC_PACKET_MAX 255 /* RESERVED */
*
* NAME
*
- * typedef unsigned char SilcPacketVersion;
+ * typedef SilcUInt8 SilcPacketVersion;
*
* DESCRIPTION
*
* SILC packet version type definition.
*
***/
-typedef unsigned char SilcPacketVersion;
+typedef SilcUInt8 SilcPacketVersion;
/****d* silccore/SilcPacketAPI/SilcPacketFlags
*
* NAME
*
- * typedef unsigned char SilcPacketFlags;
+ * typedef SilcUInt8 SilcPacketFlags;
*
* DESCRIPTION
*
*
* SOURCE
*/
-typedef unsigned char SilcPacketFlags;
+typedef SilcUInt8 SilcPacketFlags;
/* All defined packet flags */
#define SILC_PACKET_FLAG_NONE 0x00 /* No flags */
#define SILC_PACKET_FLAG_PRIVMSG_KEY 0x01 /* Private message key */
#define SILC_PACKET_FLAG_LIST 0x02 /* Packet is a list */
#define SILC_PACKET_FLAG_BROADCAST 0x04 /* Packet is a broadcast */
+#define SILC_PACKET_FLAG_COMPRESSED 0x08 /* Payload is compressed */
/***/
/* 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
*
* 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 {
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;
*
* SOURCE
*/
-#define SILC_PACKET_LENGTH(__packet, __ret_truelen, __ret_paddedlen) \
-do { \
- SILC_GET16_MSB((__ret_truelen), (__packet)->data); \
- (__ret_paddedlen) = (__ret_truelen) + (__packet)->data[4]; \
+#define SILC_PACKET_LENGTH(__packetdata, __ret_truelen, __ret_paddedlen) \
+do { \
+ SILC_GET16_MSB((__ret_truelen), (__packetdata)); \
+ (__ret_paddedlen) = (__ret_truelen) + (SilcUInt8)(__packetdata)[4]; \
} while(0)
/***/
*
* DESCRIPTION
*
- * Returns the length of the padding in the packet. This is used
+ * Calculates the length of the padding in the packet. This is used
* by various library routines to determine needed padding length.
*
* SOURCE
*/
-#define SILC_PACKET_PADLEN(__packetlen, __blocklen) \
- SILC_PACKET_DEFAULT_PADLEN - (__packetlen) % \
- ((__blocklen) ? (__blocklen) : SILC_PACKET_DEFAULT_PADLEN)
+#define SILC_PACKET_PADLEN(__packetlen, __blocklen, __padlen) \
+do { \
+ __padlen = (SILC_PACKET_DEFAULT_PADLEN - (__packetlen) % \
+ ((__blocklen) ? (__blocklen) : SILC_PACKET_DEFAULT_PADLEN)); \
+ if (__padlen < 8) \
+ __padlen += ((__blocklen) ? (__blocklen) : SILC_PACKET_DEFAULT_PADLEN); \
+} while(0)
/***/
/****d* silccore/SilcPacketAPI/SILC_PACKET_PADLEN_MAX
* DESCRIPTION
*
* Returns the length of the padding up to the maximum length, which
- * is 128 butes. This is used by various library routines to determine
+ * is 128 bytes. This is used by various library routines to determine
* needed padding length.
*
* SOURCE
*/
-#define SILC_PACKET_PADLEN_MAX(__packetlen) \
- SILC_PACKET_MAX_PADLEN - (__packetlen) % SILC_PACKET_MAX_PADLEN
+#define SILC_PACKET_PADLEN_MAX(__packetlen, __blocklen, __padlen) \
+do { \
+ __padlen = (SILC_PACKET_MAX_PADLEN - (__packetlen) % \
+ ((__blocklen) ? (__blocklen) : SILC_PACKET_DEFAULT_PADLEN)); \
+} while(0)
/***/
/* Prototypes */