Function SilcPacketReceiveCb
SYNOPSIS
typedef SilcBool (*SilcPacketReceiveCb)(SilcPacketEngine engine,
SilcPacketStream stream,
SilcPacket packet,
void *callback_context,
void *stream_context);
DESCRIPTION
The packet receive callback is called by the packet engine when a new
SILC Packet has arrived. The application must free the returned
SilcPacket with silc_packet_free if it takes the packet in for
processing. This callback is set in the SilcPacketCallbacks structure.
The `callback_context' is the context set as argument in the
silc_packet_engine_start function. The `stream_context' is stream
specific context that was set by calling silc_packet_set_context.
If the application takes the received packet `packet' into processing
TRUE must be returned. If FALSE is returned the packet engine will
pass the packet to other packet processor, if one has been linked
to the stream with silc_packet_stream_link function. If no extra
processor is linked the packet is dropped.
EXAMPLE
SilcBool
silc_foo_packet_receive_cb(SilcPacketEngine engine,
SilcPacketStream stream, SilcPacket packet,
void *callback_context, void *stream_context)
{
Application ctx = callback_context;
// If we're not up yet, let's not process the packet
if (ctx->initialized == FALSE)
return FALSE;
// Process the incoming packet...
...
// It's our packet now, no one else will get it
return TRUE;
}
|