Library to help fragment messages. More...
Typedefs | |
typedef void(* | GNUNET_FRAGMENT_MessageProcessor) (void *cls, const struct GNUNET_MessageHeader *msg) |
Function that is called with messages created by the fragmentation module. More... | |
typedef void(* | GNUNET_DEFRAGMENT_AckProcessor) (void *cls, uint32_t id, const struct GNUNET_MessageHeader *msg) |
Function that is called with acknowledgement messages created by the fragmentation module. More... | |
Functions | |
struct GNUNET_FRAGMENT_Context * | GNUNET_FRAGMENT_context_create (struct GNUNET_STATISTICS_Handle *stats, uint16_t mtu, struct GNUNET_BANDWIDTH_Tracker *tracker, struct GNUNET_TIME_Relative msg_delay, struct GNUNET_TIME_Relative ack_delay, const struct GNUNET_MessageHeader *msg, GNUNET_FRAGMENT_MessageProcessor proc, void *proc_cls) |
Create a fragmentation context for the given message. More... | |
void | GNUNET_FRAGMENT_context_transmission_done (struct GNUNET_FRAGMENT_Context *fc) |
Continuation to call from the 'proc' function after the fragment has been transmitted (and hence the next fragment can now be given to proc). More... | |
int | GNUNET_FRAGMENT_process_ack (struct GNUNET_FRAGMENT_Context *fc, const struct GNUNET_MessageHeader *msg) |
Process an acknowledgement message we got from the other side (to control re-transmits). More... | |
void | GNUNET_FRAGMENT_context_destroy (struct GNUNET_FRAGMENT_Context *fc, struct GNUNET_TIME_Relative *msg_delay, struct GNUNET_TIME_Relative *ack_delay) |
Destroy the given fragmentation context (stop calling 'proc', free resources). More... | |
const char * | GNUNET_FRAGMENT_print_ack (const struct GNUNET_MessageHeader *ack) |
Convert an ACK message to a printable format suitable for logging. More... | |
struct GNUNET_DEFRAGMENT_Context * | GNUNET_DEFRAGMENT_context_create (struct GNUNET_STATISTICS_Handle *stats, uint16_t mtu, unsigned int num_msgs, void *cls, GNUNET_FRAGMENT_MessageProcessor proc, GNUNET_DEFRAGMENT_AckProcessor ackp) |
Create a defragmentation context. More... | |
void | GNUNET_DEFRAGMENT_context_destroy (struct GNUNET_DEFRAGMENT_Context *dc) |
Destroy the given defragmentation context. More... | |
int | GNUNET_DEFRAGMENT_process_fragment (struct GNUNET_DEFRAGMENT_Context *dc, const struct GNUNET_MessageHeader *msg) |
We have received a fragment. More... | |
Library to help fragment messages.
typedef void(* GNUNET_FRAGMENT_MessageProcessor) (void *cls, const struct GNUNET_MessageHeader *msg) |
Function that is called with messages created by the fragmentation module.
In the case of the 'proc' callback of the GNUNET_FRAGMENT_context_create() function, this function must eventually call GNUNET_FRAGMENT_context_transmission_done().
cls | closure |
msg | the message that was created |
Definition at line 68 of file gnunet_fragmentation_lib.h.
typedef void(* GNUNET_DEFRAGMENT_AckProcessor) (void *cls, uint32_t id, const struct GNUNET_MessageHeader *msg) |
Function that is called with acknowledgement messages created by the fragmentation module.
Acknowledgements are cumulative, so it is OK to only transmit the 'latest' ack message for the same message ID.
cls | closure |
id | unique message ID (modulo collisions) |
msg | the message that was created |
Definition at line 173 of file gnunet_fragmentation_lib.h.
struct GNUNET_FRAGMENT_Context* GNUNET_FRAGMENT_context_create | ( | struct GNUNET_STATISTICS_Handle * | stats, |
uint16_t | mtu, | ||
struct GNUNET_BANDWIDTH_Tracker * | tracker, | ||
struct GNUNET_TIME_Relative | msg_delay, | ||
struct GNUNET_TIME_Relative | ack_delay, | ||
const struct GNUNET_MessageHeader * | msg, | ||
GNUNET_FRAGMENT_MessageProcessor | proc, | ||
void * | proc_cls | ||
) |
Create a fragmentation context for the given message.
Fragments the message into fragments of size mtu or less. Calls proc on each un-acknowledged fragment, using both the expected msg_delay between messages and acknowledgements and the given tracker to guide the frequency of calls to proc.
stats | statistics context |
mtu | the maximum message size for each fragment |
tracker | bandwidth tracker to use for flow control (can be NULL) |
msg_delay | initial delay to insert between fragment transmissions based on previous messages |
ack_delay | expected delay between fragment transmission and ACK based on previous messages |
msg | the message to fragment |
proc | function to call for each fragment to transmit |
proc_cls | closure for proc |
Fragments the message into fragments of size mtu or less. Calls proc on each un-acknowledged fragment, using both the expected msg_delay between messages and acknowledgements and the given tracker to guide the frequency of calls to proc.
stats | statistics context |
mtu | the maximum message size for each fragment |
tracker | bandwidth tracker to use for flow control (can be NULL) |
msg_delay | initial delay to insert between fragment transmissions based on previous messages |
ack_delay | expected delay between fragment transmission and ACK based on previous messages |
msg | the message to fragment |
proc | function to call for each fragment to transmit |
proc_cls | closure for proc |
Definition at line 310 of file fragmentation.c.
References _, GNUNET_FRAGMENT_Context::ack_delay, GNUNET_FRAGMENT_Context::acks, GNUNET_FRAGMENT_Context::acks_mask, GNUNET_FRAGMENT_Context::fragment_id, GNUNET_assert, GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u32(), GNUNET_malloc, GNUNET_memcpy, GNUNET_NO, GNUNET_SCHEDULER_add_now(), GNUNET_STATISTICS_update(), msg, GNUNET_FRAGMENT_Context::msg, GNUNET_FRAGMENT_Context::msg_delay, GNUNET_FRAGMENT_Context::mtu, GNUNET_FRAGMENT_Context::proc, GNUNET_FRAGMENT_Context::proc_cls, GNUNET_MessageHeader::size, size, stats, GNUNET_FRAGMENT_Context::stats, GNUNET_FRAGMENT_Context::task, GNUNET_FRAGMENT_Context::tracker, and transmit_next().
Referenced by handle_helper_message(), send_with_fragmentation(), and udp_plugin_send().
void GNUNET_FRAGMENT_context_transmission_done | ( | struct GNUNET_FRAGMENT_Context * | fc | ) |
Continuation to call from the 'proc' function after the fragment has been transmitted (and hence the next fragment can now be given to proc).
fc | fragmentation context |
Definition at line 369 of file fragmentation.c.
References GNUNET_FRAGMENT_Context::delay_until, GNUNET_assert, GNUNET_NO, GNUNET_SCHEDULER_add_at(), GNUNET_YES, GNUNET_FRAGMENT_Context::proc_busy, GNUNET_FRAGMENT_Context::task, and transmit_next().
Referenced by fragment_transmission_done(), qc_fragment_sent(), and transmit_fragment().
int GNUNET_FRAGMENT_process_ack | ( | struct GNUNET_FRAGMENT_Context * | fc, |
const struct GNUNET_MessageHeader * | msg | ||
) |
Process an acknowledgement message we got from the other side (to control re-transmits).
fc | fragmentation context |
msg | acknowledgement message we received |
Definition at line 393 of file fragmentation.c.
References _, GNUNET_FRAGMENT_Context::ack_delay, GNUNET_FRAGMENT_Context::acks, GNUNET_FRAGMENT_Context::acks_mask, FragmentAcknowledgement::bits, GNUNET_FRAGMENT_Context::fragment_id, FragmentAcknowledgement::fragment_id, GNUNET_assert, GNUNET_break_op, GNUNET_NO, GNUNET_ntohll(), GNUNET_OK, GNUNET_SCHEDULER_add_now(), GNUNET_SCHEDULER_cancel(), GNUNET_STATISTICS_update(), GNUNET_SYSERR, GNUNET_TIME_absolute_get_duration(), GNUNET_TIME_relative_min(), GNUNET_TIME_relative_saturating_multiply(), GNUNET_TIME_UNIT_SECONDS, GNUNET_YES, GNUNET_FRAGMENT_Context::last_round, msg, GNUNET_FRAGMENT_Context::msg_delay, GNUNET_FRAGMENT_Context::num_transmissions, GNUNET_FRAGMENT_Context::proc_busy, GNUNET_TIME_Relative::rel_value_us, GNUNET_MessageHeader::size, GNUNET_FRAGMENT_Context::stats, GNUNET_FRAGMENT_Context::task, transmit_next(), and GNUNET_FRAGMENT_Context::wack.
Referenced by process_data(), and read_process_ack().
void GNUNET_FRAGMENT_context_destroy | ( | struct GNUNET_FRAGMENT_Context * | fc, |
struct GNUNET_TIME_Relative * | msg_delay, | ||
struct GNUNET_TIME_Relative * | ack_delay | ||
) |
Destroy the given fragmentation context (stop calling 'proc', free resources).
fc | fragmentation context |
msg_delay | where to store average delay between individual message transmissions the last message (OUT only) |
ack_delay | where to store average delay between transmission and ACK for the last message, set to FOREVER if the message was not fully transmitted (OUT only) |
Definition at line 512 of file fragmentation.c.
References GNUNET_FRAGMENT_Context::ack_delay, GNUNET_free, GNUNET_SCHEDULER_cancel(), GNUNET_TIME_relative_saturating_multiply(), GNUNET_FRAGMENT_Context::msg_delay, GNUNET_FRAGMENT_Context::num_rounds, and GNUNET_FRAGMENT_Context::task.
Referenced by fragmented_message_done(), free_fragment_message(), and free_session().
const char* GNUNET_FRAGMENT_print_ack | ( | const struct GNUNET_MessageHeader * | ack | ) |
Convert an ACK message to a printable format suitable for logging.
ack | message to print |
Definition at line 147 of file fragmentation.c.
References FragmentAcknowledgement::bits, buf, FragmentAcknowledgement::fragment_id, GNUNET_ntohll(), GNUNET_snprintf(), and GNUNET_MessageHeader::size.
Referenced by read_process_ack().
struct GNUNET_DEFRAGMENT_Context* GNUNET_DEFRAGMENT_context_create | ( | struct GNUNET_STATISTICS_Handle * | stats, |
uint16_t | mtu, | ||
unsigned int | num_msgs, | ||
void * | cls, | ||
GNUNET_FRAGMENT_MessageProcessor | proc, | ||
GNUNET_DEFRAGMENT_AckProcessor | ackp | ||
) |
Create a defragmentation context.
stats | statistics context |
mtu | the maximum message size for each fragment |
num_msgs | how many fragmented messages to we defragment at most at the same time? |
cls | closure for proc and ackp |
proc | function to call with defragmented messages |
ackp | function to call with acknowledgements (to send back to the other side) |
Definition at line 208 of file defragmentation.c.
References GNUNET_DEFRAGMENT_Context::ackp, GNUNET_DEFRAGMENT_Context::cls, dc, GNUNET_new, GNUNET_TIME_UNIT_SECONDS, GNUNET_DEFRAGMENT_Context::mtu, GNUNET_DEFRAGMENT_Context::num_msgs, GNUNET_DEFRAGMENT_Context::proc, and stats.
Referenced by create_macendpoint(), and read_process_fragment().
void GNUNET_DEFRAGMENT_context_destroy | ( | struct GNUNET_DEFRAGMENT_Context * | dc | ) |
Destroy the given defragmentation context.
dc | defragmentation context |
Definition at line 234 of file defragmentation.c.
References dc, GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_SCHEDULER_cancel(), and mc.
Referenced by ack_proc(), free_macendpoint(), heap_cleanup_iterator(), read_process_fragment(), and udp_disconnect_session().
int GNUNET_DEFRAGMENT_process_fragment | ( | struct GNUNET_DEFRAGMENT_Context * | dc, |
const struct GNUNET_MessageHeader * | msg | ||
) |
We have received a fragment.
Process it.
dc | the context |
msg | the message that was received |
Definition at line 416 of file defragmentation.c.
Referenced by process_data(), and read_process_fragment().