*/
struct GNUNET_SERVER_MessageStreamTokenizer *
GNUNET_SERVER_mst_create (size_t maxbuf,
- void *client_identity,
GNUNET_SERVER_MessageTokenizerCallback cb,
void *cb_cls);
*/
int
GNUNET_SERVER_mst_receive (struct GNUNET_SERVER_MessageStreamTokenizer *mst,
+ void *client_identity,
const char *buf,
size_t size,
int purge,
}
*/
if (cs->msgtok==NULL)
- cs->msgtok = GNUNET_SERVER_mst_create (GNUNET_SERVER_MAX_MESSAGE_SIZE, cs, &messageTokenizerCallback, cs);
+ cs->msgtok = GNUNET_SERVER_mst_create (GNUNET_SERVER_MAX_MESSAGE_SIZE, &messageTokenizerCallback, cs);
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"HTTP Daemon has new an incoming `%s' request from peer `%s'\n",method, GNUNET_i2s(&cs->partner));
}
if (cs->pending_inbound_msg->pos >= sizeof (struct GNUNET_MessageHeader))
{
cur_msg = (struct GNUNET_MessageHeader *) cs->pending_inbound_msg->buf;
- res = GNUNET_SERVER_mst_receive(cs->msgtok,cs->pending_inbound_msg->buf,cs->pending_inbound_msg->pos, GNUNET_YES, GNUNET_NO);
+ res = GNUNET_SERVER_mst_receive(cs->msgtok, cs, cs->pending_inbound_msg->buf,cs->pending_inbound_msg->pos, GNUNET_YES, GNUNET_NO);
if ((res != GNUNET_SYSERR) && (res != GNUNET_NO))
send_error_to_client = GNUNET_NO;
}
#if DEBUG_SERVER
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Server processes additional messages instantly.\n");
#endif
- ret = GNUNET_SERVER_mst_receive (client->mst, NULL, 0, GNUNET_NO, GNUNET_YES);
+ ret = GNUNET_SERVER_mst_receive (client->mst, client, NULL, 0, GNUNET_NO, GNUNET_YES);
}
#if DEBUG_SERVER
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
#endif
GNUNET_SERVER_client_keep (client);
client->last_activity = GNUNET_TIME_absolute_get ();
- ret = GNUNET_SERVER_mst_receive (client->mst, buf, available, GNUNET_NO, GNUNET_YES);
+ ret = GNUNET_SERVER_mst_receive (client->mst, client, buf, available, GNUNET_NO, GNUNET_YES);
process_mst (client, ret);
}
client = GNUNET_malloc (sizeof (struct GNUNET_SERVER_Client));
client->connection = connection;
client->mst = GNUNET_SERVER_mst_create (GNUNET_SERVER_MAX_MESSAGE_SIZE,
- client,
&client_message_tokenizer_callback,
server);
client->reference_count = 1;
*/
void *cb_cls;
- /**
- * Client to pass to cb.
- */
- void *client_identity;
-
/**
* Size of the buffer (starting at 'hdr').
*/
*
* @param maxbuf maximum message size to support (typically
* GNUNET_SERVER_MAX_MESSAGE_SIZE)
- * @param client_identity ID of client for which this is a buffer,
- * can be NULL (will be passed back to 'cb')
* @param cb function to call on completed messages
* @param cb_cls closure for cb
* @return handle to tokenizer
*/
struct GNUNET_SERVER_MessageStreamTokenizer *
GNUNET_SERVER_mst_create (size_t maxbuf,
- void *client_identity,
GNUNET_SERVER_MessageTokenizerCallback cb,
void *cb_cls)
{
ret = GNUNET_malloc (maxbuf + sizeof (struct GNUNET_SERVER_MessageStreamTokenizer));
ret->maxbuf = maxbuf;
- ret->client_identity = client_identity;
ret->cb = cb;
ret->cb_cls = cb_cls;
return ret;
* callback for all complete messages.
*
* @param mst tokenizer to use
+ * @param client_identity ID of client for which this is a buffer
* @param buf input data to add
* @param size number of bytes in buf
* @param purge should any excess bytes in the buffer be discarded
*/
int
GNUNET_SERVER_mst_receive (struct GNUNET_SERVER_MessageStreamTokenizer *mst,
+ void *client,
const char *buf,
size_t size,
int purge,
}
if (one_shot == GNUNET_YES)
one_shot = GNUNET_SYSERR;
- mst->cb (mst->cb_cls, mst->client_identity, hdr);
+ mst->cb (mst->cb_cls, client, hdr);
mst->off += want;
if (mst->off == mst->pos)
{
}
if (one_shot == GNUNET_YES)
one_shot = GNUNET_SYSERR;
- mst->cb (mst->cb_cls, mst->client_identity, hdr);
+ mst->cb (mst->cb_cls, client, hdr);
buf += want;
size -= want;
}