+/****f* silccore/SilcPacketAPI/silc_packet_stream_link
+ *
+ * SYNOPSIS
+ *
+ * SilcBool silc_packet_stream_link(SilcPacketStream stream,
+ * SilcPacketCallbacks *callbacks,
+ * void *callback_context,
+ * int priority, ...);
+ *
+ * DESCRIPTION
+ *
+ * Links the packet processing callbacks indicated by `callbacks' into
+ * the packet stream indicated by `stream' with priority `priority' for
+ * the packet types given in the variable argument list. This function
+ * can be used to link to the packet stream for specific packet types
+ * and receive them in the specified callbacks. This way, a third party,
+ * for example some library may attach itself into the packet stream
+ * and receive and process certain packets. The variable argument
+ * list is ended with -1. To link to receive all packets use
+ * SILC_PACKET_ANY.
+ *
+ * The default packet processing callbacks given as argument to the
+ * silc_packet_engine_start has the priority 0. Any priority higher
+ * than 0 will then take precedence over the default callbacks. Any
+ * priority lower than 0 (negative value) will be processed after the
+ * default callbacks.
+ *
+ * Note that setting only the 'packet_receive' callback in the `callbacks'
+ * is required.
+ *
+ * EXAMPLE
+ *
+ * // Link to this packet stream, with high priority, for
+ * // SILC_PACKET_CONNECTION_AUTH and SILC_PACKET_CONNECTION_AUTH_REQUEST
+ * // packets. We don't care about other packets.
+ * silc_packet_stream_link(stream, our_callbacks, our_context,
+ * 1000000, SILC_PACKET_CONNECTION_AUTH,
+ * SILC_PACKET_CONNECTION_AUTH_REQUEST, -1);
+ *
+ ***/
+SilcBool silc_packet_stream_link(SilcPacketStream stream,
+ const SilcPacketCallbacks *callbacks,
+ void *callback_context,
+ int priority, ...);
+
+/****f* silccore/SilcPacketAPI/silc_packet_stream_unlink
+ *
+ * SYNOPSIS
+ *
+ * void silc_packet_stream_unlink(SilcPacketStream stream,
+ * SilcPacketCallbacks *callbacks,
+ * void *callback_context);
+ *
+ * DESCRIPTION
+ *
+ * Unlinks the `callbacks' with `callback_context' from the packet stream
+ * indicated by `stream'. This function must be called for the callbacks
+ * that was linked to `stream' when they are not needed anymore.
+ *
+ ***/
+void silc_packet_stream_unlink(SilcPacketStream stream,
+ const SilcPacketCallbacks *callbacks,
+ void *callback_context);
+
+/****f* silccore/SilcPacketAPI/SilcPacketWrapCoder
+ *
+ * SYNOPSIS
+ *
+ * typedef SilcBool (*SilcPacketWrapCoder)(SilcStream stream,
+ * SilcStreamStatus status,
+ * SilcBuffer buffer,
+ * void *context);
+ *
+ * DESCRIPTION
+ *
+ * The encoder/decoder callback for silc_packet_stream_wrap. If the
+ * `status' is SILC_STREAM_CAN_WRITE then additional data can be added
+ * to `buffer'. It is added before the data that is written with
+ * silc_stream_write. The silc_buffer_enlarge should be called to verify
+ * there is enough room in `buffer' before adding data to it. The `buffer'
+ * must not be freed.
+ *
+ * If the `status' is SILC_STREAM_CAN_READ then data from the `buffer'
+ * may be read before it is passed to readed when silc_stream_read is
+ * called. The `buffer' may be advanced also to hide data in it.
+ *
+ * This function returns FALSE in case of error.
+ *
+ ***/
+typedef SilcBool (*SilcPacketWrapCoder)(SilcStream stream,
+ SilcStreamStatus status,
+ SilcBuffer buffer,
+ void *context);
+
+/****f* silccore/SilcPacketAPI/silc_packet_stream_wrap
+ *
+ * SYNOPSIS
+ *
+ * SilcStream silc_packet_stream_wrap(SilcPacketStream stream,
+ * SilcPacketType type,
+ * SilcPacketFlags flags,
+ * SilcBool blocking_mode,
+ * SilcPacketWrapCoder coder,
+ * void *context);
+ *
+ * DESCRIPTION
+ *
+ * Wraps the packet stream indicated by `stream' into a SilcStream for
+ * the packet type indicated by `type' with packet flags indicated by
+ * `flags'. The returned SilcStream can be used to read and write the
+ * specified SILC packets with the specified packet flags, by calling
+ * silc_stream_read and silc_stream_write, respectively. The returned
+ * stream can be destroyed by calling silc_stream_destroy. It does not
+ * destroy the wrapped packet stream.
+ *
+ * If the `blocking_mode' mode is TRUE then the silc_stream_read and
+ * silc_stream_write may block the calling process or thread until SILC
+ * packet is read or written. If it is FALSE the stream is in non-blocking
+ * mode and the calls never block. The returned stream is thread-safe and
+ * packets may be read and written in multi-threaded environment.
+ *
+ * In non-blocking mode the silc_stream_set_notifier must be called before
+ * the returned stream can be used to read packets. The stream status
+ * SILC_STREAM_CAN_READ will be returned to the notifier callback to
+ * indicate that a packet is ready for reading. Calling silc_stream_read
+ * once returns one complete SILC packet data payload (which is of type of
+ * `type').
+ *
+ * The `coder' is optional encoder/decoder callback which the packet engine
+ * will call if it is non-NULL. It can be used to encode additional data
+ * into each packet when silc_stream_write is called or decode data before
+ * it is passed to reader when silc_stream_read is called. The `context'
+ * is passed to `coder'.
+ *
+ * The returned SilcStream can be used as any normal stream and all
+ * SilcStream API functions may be used with the stream. This returns
+ * NULL on error.
+ *
+ ***/
+SilcStream silc_packet_stream_wrap(SilcPacketStream stream,
+ SilcPacketType type,
+ SilcPacketFlags flags,
+ SilcBool blocking_mode,
+ SilcPacketWrapCoder coder,
+ void *context);
+
+/****f* silccore/SilcPacketAPI/silc_packet_stream_is_udp
+ *
+ * SYNOPSIS
+ *
+ * SilcBool silc_packet_stream_is_udp(SilcPacketStream stream);
+ *
+ * DESCRIPTION
+ *
+ * Returns TRUE if the packet stream indicated by `stream' is using
+ * UDP transport.
+ *
+ ***/
+SilcBool silc_packet_stream_is_udp(SilcPacketStream stream);
+
+/****f* silccore/SilcPacketAPI/silc_packet_get_sender
+ *
+ * SYNOPSIS
+ *
+ * SilcBool silc_packet_get_sender(SilcPacket packet,
+ * const char **sender_ip,
+ * SilcUInt16 *sender_port);
+ *
+ * DESCRIPTION
+ *
+ * Returns the packet sender's IP address and port from UDP packet
+ * indicated by `packet'. This can be called only from the packet
+ * callback to retrieve the information of the packet's sender. Returns
+ * FALSE if the information is not available.
+ *
+ ***/
+SilcBool silc_packet_get_sender(SilcPacket packet,
+ const char **sender_ip,
+ SilcUInt16 *sender_port);
+
+/****f* silccore/SilcPacketAPI/silc_packet_stream_ref