Library for tokenizing a message stream. More...
Typedefs | |
| typedef 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. | |
Functions | |
| struct GNUNET_MessageStreamTokenizer * | GNUNET_MST_create (GNUNET_MessageTokenizerCallback cb, void *cb_cls) |
| Create a message stream tokenizer. | |
| 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. | |
| 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. | |
| 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 internal buffer of the mst. | |
| void | GNUNET_MST_destroy (struct GNUNET_MessageStreamTokenizer *mst) |
| Destroys a tokenizer. | |
Library for tokenizing a message stream.
| typedef 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.
Do not call #GNUNET_mst_destroy from within the scope of this callback.
| cls | closure |
| message | the actual message |
Definition at line 77 of file gnunet_mst_lib.h.
| struct GNUNET_MessageStreamTokenizer * GNUNET_MST_create | ( | GNUNET_MessageTokenizerCallback | cb, |
| void * | cb_cls | ||
| ) |
Create a message stream tokenizer.
| cb | function to call on completed messages |
| cb_cls | closure for cb |
Definition at line 86 of file mst.c.
References GNUNET_MessageStreamTokenizer::cb, GNUNET_MessageStreamTokenizer::cb_cls, GNUNET_malloc, GNUNET_MIN_MESSAGE_SIZE, GNUNET_new, and ret.
Referenced by GCT_create_tunnel(), get_app(), GNUNET_CLIENT_connect(), GNUNET_HELPER_start(), handle_client_send(), handle_transport_notify_connect(), load(), main(), main(), run(), and start_client().
| 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.
| mst | tokenizer to use |
| buf | input data to add |
| size | number of bytes in buf |
| purge | should any excess bytes in the buffer be discarded (i.e. for packet-based services like UDP) |
| one_shot | only call callback once, keep rest of message in buffer |
Definition at line 101 of file mst.c.
References ALIGN_FACTOR, GNUNET_MessageStreamTokenizer::cb, GNUNET_MessageStreamTokenizer::cb_cls, GNUNET_MessageStreamTokenizer::curr_buf, delta, do_align(), GNUNET_assert, GNUNET_break_op, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_log, GNUNET_memcpy, GNUNET_MIN, GNUNET_NO, GNUNET_OK, GNUNET_realloc, GNUNET_SYSERR, GNUNET_YES, GNUNET_MessageStreamTokenizer::hdr, LOG, GNUNET_MessageStreamTokenizer::off, GNUNET_MessageStreamTokenizer::pos, ret, GNUNET_MessageHeader::size, size, and GNUNET_MessageHeader::type.
Referenced by GCT_handle_encrypted(), GNUNET_HELPER_wait(), GNUNET_MST_next(), GNUNET_MST_read(), gnunet_read(), handle_client_send(), handle_encrypted_message(), helper_read(), load(), main(), main(), and read_task().
| 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.
| mst | tokenizer to use |
| buf | input data to add |
| size | number of bytes in buf |
| purge | should any excess bytes in the buffer be discarded (i.e. for packet-based services like UDP) |
| one_shot | only call callback once, keep rest of message in buffer |
Definition at line 338 of file mst.c.
References GNUNET_MessageStreamTokenizer::curr_buf, GNUNET_ERROR_TYPE_INFO, GNUNET_log_strerror, GNUNET_MST_from_buffer(), GNUNET_NETWORK_socket_recv(), GNUNET_OK, GNUNET_SYSERR, GNUNET_MessageStreamTokenizer::hdr, GNUNET_MessageStreamTokenizer::pos, and ret.
Referenced by receive_ready(), and service_client_recv().
| 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 internal buffer of the mst.
| mst | tokenizer to use |
| one_shot | only call callback once, keep rest of message in buffer |
Definition at line 387 of file mst.c.
References GNUNET_MST_from_buffer(), and GNUNET_NO.
Referenced by resume_client_receive().
| void GNUNET_MST_destroy | ( | struct GNUNET_MessageStreamTokenizer * | mst | ) |
Destroys a tokenizer.
| mst | tokenizer to destroy |
Definition at line 404 of file mst.c.
References GNUNET_free, and GNUNET_MessageStreamTokenizer::hdr.
Referenced by connection_client_destroy_impl(), destroy_tunnel(), do_shutdown_later(), finish_client_drop(), GNUNET_HELPER_destroy(), handle_client_send(), handle_transport_notify_disconnect(), load(), main(), and main().