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. More... | |
Functions | |
struct GNUNET_MessageStreamTokenizer * | GNUNET_MST_create (GNUNET_MessageTokenizerCallback cb, void *cb_cls) |
Create a message stream tokenizer. More... | |
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. More... | |
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. More... | |
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 internal buffer of the mst. More... | |
void | GNUNET_MST_destroy (struct GNUNET_MessageStreamTokenizer *mst) |
Destroys a tokenizer. More... | |
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 client_receive(), GCT_create_tunnel(), get_app(), GNUNET_CLIENT_connect(), GNUNET_HELPER_start(), handle_client_send(), handle_transport_notify_connect(), load(), main(), run(), server_access_cb(), start_client(), udp_broadcast_receive(), and udp_plugin_create_session().
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 86 of file mst.c.
Referenced by client_receive(), GCT_handle_encrypted(), GNUNET_HELPER_wait(), gnunet_read(), handle_client_send(), handle_encrypted(), helper_read(), load(), main(), process_udp_message(), read_task(), server_access_cb(), and udp_broadcast_receive().
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.
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 86 of file mst.c.
Referenced by receive_ready(), and service_client_recv().
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 internal buffer of the mst.
mst | tokenizer to use |
one_shot | only call callback once, keep rest of message in buffer |
Definition at line 86 of file mst.c.
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 client_delete_session(), connection_client_destroy_impl(), destroy_tunnel(), do_shutdown(), finish_client_drop(), free_session(), GNUNET_HELPER_destroy(), handle_client_send(), handle_transport_notify_disconnect(), load(), main(), server_delete_session(), server_disconnect_cb(), shutdown_task(), and udp_broadcast_receive().