Function 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' which contains the data that is being written
to the stream. There is at least 16 bytes of free space in head
space of the buffer in case new headers need to be added.
The silc_buffer_enlarge should be called to verify that there is
enough room before adding data to it. The `buffer' must not be freed.
If the return value is FALSE the encoding failed and the packet is
not sent at all and the stream will receive error. Return TRUE if
the encoding succeeded.
If the `status' is SILC_STREAM_CAN_READ then data from the `buffer'
may be read before it is passed to reader when silc_stream_read is
called. The `buffer' may be advanced also to hide data in it. If
return value is FALSE the decoding failed (or the packet is ignored)
and the packet will not be processed by the wrapped packet stream.
If there are other packet streams wanting the same packet, they will
get it, and if not the packet will drop. Return TRUE if decoding
succeeded.
|