31 #if HAVE_UNALIGNED_64_ACCESS
32 #define ALIGN_FACTOR 4
34 #define ALIGN_FACTOR 8
114 void *client_identity,
116 int purge,
int one_shot)
123 unsigned long offset;
129 "Server-mst receives %u bytes with %u bytes already in private buffer\n",
130 (
unsigned int)
size, (
unsigned int) (mst->
pos - mst->
off));
132 ibuf = (
char *) mst->
hdr;
142 memmove (ibuf, &ibuf[mst->
off], mst->
pos);
165 want = ntohs (hdr->
size);
176 memmove (ibuf, &ibuf[mst->
off], mst->
pos);
184 ibuf = (
char *) mst->
hdr;
188 if (mst->
pos - mst->
off < want)
197 if (mst->
pos - mst->
off < want)
229 "Server-mst has %u bytes left in inbound buffer\n",
230 (
unsigned int)
size);
233 offset = (
unsigned long)
buf;
239 want = ntohs (hdr->
size);
270 if ((
size > 0) && (! purge))
275 ibuf = (
char *) mst->
hdr;
288 "Server-mst leaves %u bytes in private buffer\n",
289 (
unsigned int) (mst->
pos - mst->
off));
static size_t do_align(size_t start_position, size_t end_position)
Given the start and end position of a block of data, return the end position of that data after align...
static int ret
Return value of the commandline.
#define GNUNET_MIN_MESSAGE_SIZE
Smallest supported message.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_break_op(cond)
Use this for assertion violations caused by other peers (i.e.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_realloc(ptr, size)
Wrapper around realloc.
#define GNUNET_free(ptr)
Wrapper around free.
static unsigned int size
Size of the "table".
int(* GNUNET_SERVER_MessageTokenizerCallback)(void *cls, void *client, const struct GNUNET_MessageHeader *message)
Functions with this signature are called whenever a complete message is received by the tokenizer.
static struct GNUNET_TIME_Relative delta
Handle to a message stream tokenizer.
size_t off
How many bytes in buffer have we already processed?
size_t curr_buf
Size of the buffer (starting at hdr).
size_t pos
How many bytes in buffer are valid right now?
struct GNUNET_MessageHeader * hdr
Beginning of the buffer.
GNUNET_SERVER_MessageTokenizerCallback cb
Function to call on completed messages.
void * cb_cls
Closure for cb.
int GNUNET_SERVER_mst_receive(struct GNUNET_SERVER_MessageStreamTokenizer *mst, void *client_identity, const char *buf, size_t size, int purge, int one_shot)
Add incoming data to the receive buffer and call the callback for all complete messages.
struct GNUNET_SERVER_MessageStreamTokenizer * GNUNET_SERVER_mst_create(GNUNET_SERVER_MessageTokenizerCallback cb, void *cb_cls)
Create a message stream tokenizer.
void GNUNET_SERVER_mst_destroy(struct GNUNET_SERVER_MessageStreamTokenizer *mst)
Destroys a tokenizer.