31 #if HAVE_UNALIGNED_64_ACCESS
32 #define ALIGN_FACTOR 4
34 #define ALIGN_FACTOR 8
37 #define LOG(kind, ...) GNUNET_log_from (kind, "util-mst", __VA_ARGS__)
125 unsigned long offset;
132 "MST receives %u bytes with %u (%u/%u) bytes already in private buffer\n",
134 (
unsigned int) (mst->
pos - mst->
off),
135 (
unsigned int) mst->
pos,
136 (
unsigned int) mst->
off);
138 ibuf = (
char *) mst->
hdr;
176 want = ntohs (hdr->
size);
178 "We want to read message of size %u\n",
201 ibuf = (
char *) mst->
hdr;
205 if (mst->
pos - mst->
off < want)
217 if (mst->
pos - mst->
off < want)
242 "Failure processing message of type %u and size %u\n",
258 "Server-mst has %u bytes left in inbound buffer\n",
259 (
unsigned int)
size);
262 offset = (
unsigned long)
buf;
268 want = ntohs (hdr->
size);
292 "Failure processing message of type %u and size %u\n",
308 if ((
size > 0) && (! purge))
314 ibuf = (
char *) mst->
hdr;
329 "Server-mst leaves %u (%u/%u) bytes in private buffer\n",
330 (
unsigned int) (mst->
pos - mst->
off),
331 (
unsigned int) mst->
pos,
332 (
unsigned int) mst->
off);
368 if ((EAGAIN == errno) ||
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_log(kind,...)
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_MIN_MESSAGE_SIZE
Smallest supported message.
#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.
#define GNUNET_log_strerror(level, cmd)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...
@ GNUNET_ERROR_TYPE_WARNING
@ 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.
ssize_t GNUNET_NETWORK_socket_recv(const struct GNUNET_NETWORK_Handle *desc, void *buffer, size_t length)
Read data from a connected socket (always non-blocking).
int GNUNET_MST_next(struct GNUNET_MessageStreamTokenizer *mst, int one_shot)
Obtain the next message from the mst, assuming that there are more unprocessed messages in the intern...
int GNUNET_MST_read(struct GNUNET_MessageStreamTokenizer *mst, struct GNUNET_NETWORK_Handle *sock, int purge, int one_shot)
Add incoming data to the receive buffer and call the callback for all complete messages.
int(* GNUNET_MessageTokenizerCallback)(void *cls, const struct GNUNET_MessageHeader *message)
Functions with this signature are called whenever a complete message is received by the tokenizer.
void GNUNET_MST_destroy(struct GNUNET_MessageStreamTokenizer *mst)
Destroys a tokenizer.
struct GNUNET_MessageStreamTokenizer * GNUNET_MST_create(GNUNET_MessageTokenizerCallback cb, void *cb_cls)
Create a message stream tokenizer.
int GNUNET_MST_from_buffer(struct GNUNET_MessageStreamTokenizer *mst, 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.
static unsigned int size
Size of the "table".
static struct GNUNET_TIME_Relative delta
Handle to a message stream tokenizer.
size_t curr_buf
Size of the buffer (starting at hdr).
size_t pos
How many bytes in buffer are valid right now?
void * cb_cls
Closure for cb.
struct GNUNET_MessageHeader * hdr
Beginning of the buffer.
size_t off
How many bytes in buffer have we already processed?
GNUNET_MessageTokenizerCallback cb
Function to call on completed messages.