inbuf = silc_dlist_get(ps->sc->inbufs);
if (!inbuf) {
/* Allocate new data input buffer */
- inbuf = silc_buffer_alloc(SILC_PACKET_DEFAULT_SIZE * 31);
+ inbuf = silc_buffer_alloc(SILC_PACKET_DEFAULT_SIZE * 61);
if (!inbuf) {
silc_mutex_unlock(ps->lock);
return FALSE;
ps->sc->schedule = schedule;
/* Allocate data input buffer */
- inbuf = silc_buffer_alloc(SILC_PACKET_DEFAULT_SIZE * 31);
+ inbuf = silc_buffer_alloc(SILC_PACKET_DEFAULT_SIZE * 61);
if (!inbuf) {
silc_free(ps->sc);
ps->sc = NULL;
SilcMutex wait_lock;
SilcCond wait_cond;
SilcList packet_queue;
+ unsigned char id[28];
+ unsigned int id_type : 2;
+ unsigned int id_len : 5;
unsigned int stopped : 1;
} *SilcPacketWait;
{
SilcPacketWait pw = callback_context;
+ /* If source ID is specified check for it */
+ if (pw->id_len) {
+ if (pw->id_type != packet->src_id_type ||
+ memcmp(pw->id, packet->src_id, pw->id_len))
+ return FALSE;
+ }
+
/* Signal the waiting thread for a new packet */
silc_mutex_lock(pw->wait_lock);
/* Initialize packet waiting */
-void *silc_packet_wait_init(SilcPacketStream stream, ...)
+void *silc_packet_wait_init(SilcPacketStream stream,
+ const SilcID *source_id, ...)
{
SilcPacketWait pw;
SilcBool ret;
}
/* Link to the packet stream for the requested packet types */
- va_start(ap, stream);
+ va_start(ap, source_id);
ret = silc_packet_stream_link_va(stream, &silc_packet_wait_cbs, pw,
10000000, ap);
va_end(ap);
/* Initialize packet queue */
silc_list_init(pw->packet_queue, struct SilcPacketStruct, next);
+ if (source_id) {
+ SilcUInt32 id_len;
+ silc_id_id2str(SILC_ID_GET_ID(*source_id), source_id->type, pw->id,
+ sizeof(pw->id), &id_len);
+ pw->id_type = source_id->type;
+ pw->id_len = id_len;
+ }
+
return (void *)pw;
}
if (pws->blocking) {
/* Blocking mode. Use packet waiter to do the thing. */
- pws->waiter = silc_packet_wait_init(pws->stream, pws->type, -1);
+ pws->waiter = silc_packet_wait_init(pws->stream, NULL, pws->type, -1);
if (!pws->waiter) {
silc_free(pws);
return NULL;
*
* SYNOPSIS
*
- * void *silc_packet_wait_init(SilcPacketStream stream, ...);
+ * void *silc_packet_wait_init(SilcPacketStream stream,
+ * const SilcID *source_id, ...);
*
* DESCRIPTION
*
* Initializes a packet waiter for the packet stream `stream' and
* for the variable argument list of packet types. The function
* silc_packet_wait can be used to block the thread until a packet
- * has been received. This function is used to initialize the waiting
- * and to give the list of packet types that caller wish to receive.
- * The variable argument list must end with -1. To receive all
- * packets use SILC_PACKET_ANY. Returns a context that must be given
- * to the silc_packet_wait function as argument. Returns NULL on
- * error. To uninitialize the waiting call silc_packet_wait_uninit.
+ * has been received.
+ *
+ * This function is used to initialize the waiting and to give the list
+ * of packet types that caller wish to receive. The variable argument
+ * list must end with -1. To receive all packets use SILC_PACKET_ANY.
+ * If the `source_id' is non-NULL then only packets of the specified
+ * type from the specified `source_id' are received. If it is NULL
+ * then the packet source is ignored.
+ *
+ * Returns a context that must be given to the silc_packet_wait function
+ * as argument. Returns NULL on error. To uninitialize the waiting
+ * call silc_packet_wait_uninit.
*
* NOTES
*
* void *waiter;
*
* // Will wait for private message packets
- * waiter = silc_packet_wait_init(stream,
+ * waiter = silc_packet_wait_init(stream, NULL,
* SILC_PACKET_PRIVATE_MESSAGE, -1);
*
- *
***/
-void *silc_packet_wait_init(SilcPacketStream stream, ...);
+void *silc_packet_wait_init(SilcPacketStream stream,
+ const SilcID *source_id, ...);
/****f* silccore/SilcPacketAPI/silc_packet_wait_uninit
*