+
+/****f* silccore/SilcPacketAPI/silc_packet_send
+ *
+ * SYNOPSIS
+ *
+ * int silc_packet_send(SilcSocketConnection sock, bool force_send);
+ *
+ * DESCRIPTION
+ *
+ * Actually sends the packet. This flushes the connections outgoing data
+ * buffer. If data is sent directly to the network this returns the bytes
+ * written, if error occured this returns -1 and if the data could not
+ * be written directly to the network at this time this returns -2, in
+ * which case the data should be queued by the caller and sent at some
+ * later time. If `force_send' is TRUE this attempts to write the data
+ * directly to the network, if FALSE, this returns -2.
+ *
+ ***/
+int silc_packet_send(SilcSocketConnection sock, bool force_send);
+
+/****f* silccore/SilcPacketAPI/silc_packet_encrypt
+ *
+ * SYNOPSIS
+ *
+ * void silc_packet_encrypt(SilcCipher cipher, SilcHmac hmac,
+ * SilcBuffer buffer, SilcUInt32 len);
+ *
+ * DESCRIPTION
+ *
+ * Encrypts a packet. This also creates HMAC of the packet before
+ * encryption and adds the HMAC at the end of the buffer. This assumes
+ * that there is enough free space at the end of the buffer to add the
+ * computed HMAC. This is the normal way of encrypting packets, if some
+ * other process of HMAC computing and encryption is needed this function
+ * cannot be used.
+ *
+ ***/
+void silc_packet_encrypt(SilcCipher cipher, SilcHmac hmac, SilcUInt32 sequence,
+ SilcBuffer buffer, SilcUInt32 len);
+
+/****f* silccore/SilcPacketAPI/silc_packet_assemble
+ *
+ * SYNOPSIS
+ *
+ * bool silc_packet_assemble(SilcPacketContext *packet, SilcRng rng,
+ * SilcCipher cipher, SilcHmac hmac,
+ * SilcSocketConnection sock,
+ * const unsigned char *data, SilcUInt32 data_len,
+ * const SilcBuffer assembled_packet);
+ *
+ * DESCRIPTION
+ *
+ * Assembles new packet to be ready for encrypting and sending out.
+ * The `packet' is filled by caller to include the packet header specific
+ * values. This prepares the socket connection's `sock' outoing buffer
+ * for sending data, and returns the assembled packet to the
+ * `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. 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,
+ SilcCipher cipher, SilcHmac hmac,
+ SilcSocketConnection sock,
+ const unsigned char *data, SilcUInt32 data_len,
+ const SilcBuffer assembled_packet);
+
+/****f* silccore/SilcPacketAPI/silc_packet_send_prepare
+ *
+ * SYNOPSIS
+ *
+ * bool silc_packet_send_prepare(SilcSocketConnection sock,
+ * SilcUInt32 header_len,
+ * SilcUInt32 pad_len,
+ * SilcUInt32 data_len,
+ * SilcHmac hmac,
+ * const SilcBuffer packet);
+ *
+ * DESCRIPTION
+ *
+ * This function can be used to prepare the outgoing data buffer in
+ * the socket connection specified by `sock' for packet sending.
+ * This is used internally by packet sending routines, but application
+ * may call this if it doesn't call silc_packet_assemble function.
+ * If that function is called then application must not call this since
+ * that function calls this internally.
+ *
+ * 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. 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,
+ SilcUInt32 header_len,
+ SilcUInt32 pad_len,
+ SilcUInt32 data_len,
+ SilcHmac hmac,
+ const SilcBuffer packet);
+
+/****f* silccore/SilcPacketAPI/silc_packet_receive
+ *
+ * SYNOPSIS
+ *
+ * int silc_packet_receive(SilcSocketConnection sock);
+ *
+ * DESCRIPTION
+ *
+ * Receives packet from network and reads the data into connection's
+ * incoming data buffer. If the data was read directly this returns the
+ * read bytes, if error occured this returns -1, if the data could not
+ * be read directly at this time this returns -2 in which case the data
+ * should be read again at some later time, or If EOF occured this returns
+ * 0.
+ *
+ ***/