#define SILC_PACKET_MAX_LEN 0xffff
/* Maximum length of ID */
-#define SILC_PACKET_MAX_ID_LEN 16
+#define SILC_PACKET_MAX_ID_LEN 28
/****d* silccore/SilcPacketAPI/SilcPacketType
*
*
* Short description of the fields following:
*
- * SilcBuffer buffer
- *
- * The data buffer.
- *
- * SilcPacketType type
+ * SilcUInt16 truelen
*
- * Type of the packet. Types are defined below.
+ * True 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.
*
* SilcPacketFlags flags
*
* Packet flags. Flags are defined above.
*
+ * SilcPacketType type
+ *
+ * Type of the packet. Types are defined below.
+ *
* unsigned char *src_id
* SilcUInt8 src_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.
*
- * SilcUInt16 truelen
* SilcUInt8 padlen
*
- * The true lenght of the packet and the padded length of the packet.
- * These may be set by the caller before calling any of the
- * silc_packet_* routines. If not provided the library will calculate
- * the values.
+ * 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
+ *
+ * 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.
*
- * int users;
+ * unsigned int users;
*
* Reference counter for this context. The context is freed only
* after the reference counter hits zero. The counter is added
*
* Packet sequence number.
*
+ * SilcBuffer buffer
+ *
+ * The actual packet data.
+ *
***/
typedef struct {
- SilcBuffer buffer;
-
SilcUInt16 truelen;
SilcPacketFlags flags;
SilcPacketType type;
- SilcUInt8 padlen;
unsigned char *src_id;
+ unsigned char *dst_id;
SilcUInt8 src_id_len;
SilcUInt8 src_id_type;
-
- unsigned char *dst_id;
SilcUInt8 dst_id_len;
SilcUInt8 dst_id_type;
- int users;
- bool long_pad; /* Set to TRUE to use maximum padding
- in packet (up to 256 bytes). */
+ SilcUInt8 padlen;
+ unsigned int long_pad : 1; /* Set when maximum padding in packet */
+ unsigned int users : 23; /* Reference counter */
SilcUInt32 sequence;
+ SilcBuffer buffer;
} SilcPacketContext;
/****s* silccore/SilcPacketAPI/SilcPacketParserContext
* `assembled_packet' pointer sent by the caller. The `assembled_packet'
* is a reference to the socket connection's outgoing buffer. The
* returned packet can be encrypted, and then sent to network by calling
- * silc_packet_send function.
+ * silc_packet_send function. The `assembled_packet' may be freely
+ * modified (like encrypted etc.) but it must not be freed, since it is
+ * reference from `sock' outgoing buffer, and it is const.
*
***/
bool silc_packet_assemble(SilcPacketContext *packet, SilcRng rng,
* This returns the prepared data area into the `packet' pointer provided
* caller, which can be used then to add data to it, and later encrypt
* it. The `packet' includes reference to the socket connection's
- * outgoing buffer.
+ * outgoing buffer. The `packet' may be freely modified (like
+ * encrypted etc.) but it must not be freed, since it is reference from
+ * `sock' outgoing buffer, and it is const.
*
***/
bool silc_packet_send_prepare(SilcSocketConnection sock,