32#if HAVE_UNALIGNED_64_ACCESS
38#define LOG(kind, ...) GNUNET_log_from (kind, "util-mst", __VA_ARGS__)
117 "MST receives %u bytes with %u (%u/%u) bytes already in private buffer\n",
119 (
unsigned int) (mst->
pos - mst->
off),
120 (
unsigned int) mst->
pos,
121 (
unsigned int) mst->
off);
123 ibuf = (
char *) mst->
hdr;
161 want = ntohs (hdr->
size);
163 "We want to read message of size %u\n",
186 ibuf = (
char *) mst->
hdr;
190 if (mst->
pos - mst->
off < want)
202 if (mst->
pos - mst->
off < want)
227 "Failure processing message of type %u and size %u\n",
242 unsigned long offset = (
unsigned long) buf;
246 "Server-mst has %u bytes left in inbound buffer\n",
247 (
unsigned int)
size);
254 want = ntohs (hdr->
size);
278 "Failure processing message of type %u and size %u\n",
294 if ((
size > 0) && (! purge))
300 ibuf = (
char *) mst->
hdr;
315 "Server-mst leaves %u (%u/%u) bytes in private buffer\n",
316 (
unsigned int) (mst->
pos - mst->
off),
317 (
unsigned int) mst->
pos,
318 (
unsigned int) mst->
off);
348 buf = (
char *) mst->
hdr;
354 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
Final status code.
#define GNUNET_MIN_MESSAGE_SIZE
Smallest supported message.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
#define GNUNET_log(kind,...)
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
GNUNET_GenericReturnValue
Named constants for return values.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
#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_MessageTokenizerCallback)(void *cls, const struct GNUNET_MessageHeader *message)
Functions with this signature are called whenever a complete message is received by the tokenizer.
enum GNUNET_GenericReturnValue 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...
enum GNUNET_GenericReturnValue 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.
struct GNUNET_MessageStreamTokenizer * GNUNET_MST_create(GNUNET_MessageTokenizerCallback cb, void *cb_cls)
Create a message stream tokenizer.
void GNUNET_MST_destroy(struct GNUNET_MessageStreamTokenizer *mst)
Destroys a tokenizer.
enum GNUNET_GenericReturnValue 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.
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.