2 This file is part of GNUnet.
3 Copyright (C) 2012-2016 GNUnet e.V.
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 SPDX-License-Identifier: AGPL3.0-or-later
22 * @author Florian Dold
23 * @author Christian Grothoff
26 * General-purpose message queue
28 * @defgroup mq MQ library
29 * General-purpose message queue
31 * @see [Documentation](https://gnunet.org/message-queue-api)
35 #ifndef GNUNET_MQ_LIB_H
36 #define GNUNET_MQ_LIB_H
38 #include "gnunet_scheduler_lib.h"
41 * Allocate an envelope, with extra space allocated after the space needed
42 * by the message struct.
43 * The allocated message will already have the type and size field set.
45 * @param mvar variable to store the allocated message in;
46 * must have a header field;
48 * @param esize extra space to allocate after the message
49 * @param type type of the message
50 * @return the MQ message
52 #define GNUNET_MQ_msg_extra(mvar, esize, type) GNUNET_MQ_msg_(((struct GNUNET_MessageHeader**) &(mvar)), (esize) + sizeof *(mvar), (type))
55 * Allocate a GNUNET_MQ_Envelope.
56 * The contained message will already have the type and size field set.
58 * @param mvar variable to store the allocated message in;
59 * must have a header field;
61 * @param type type of the message
62 * @return the allocated envelope
64 #define GNUNET_MQ_msg(mvar, type) GNUNET_MQ_msg_extra(mvar, 0, type)
68 * Allocate a GNUNET_MQ_Envelope, where the message only consists of a header.
69 * The allocated message will already have the type and size field set.
71 * @param type type of the message
73 #define GNUNET_MQ_msg_header(type) GNUNET_MQ_msg_ (NULL, sizeof (struct GNUNET_MessageHeader), type)
77 * Allocate a GNUNET_MQ_Envelope, where the message only consists of a header and extra space.
78 * The allocated message will already have the type and size field set.
80 * @param mh pointer that will changed to point at to the allocated message header
81 * @param esize extra space to allocate after the message header
82 * @param type type of the message
84 #define GNUNET_MQ_msg_header_extra(mh, esize, type) GNUNET_MQ_msg_ (&mh, (esize) + sizeof (struct GNUNET_MessageHeader), type)
88 * Allocate a GNUNET_MQ_Envelope, and append a payload message after the given
91 * @param mvar pointer to a message struct, will be changed to point at the newly allocated message,
92 * whose size is 'sizeof(*mvar) + ntohs (mh->size)'
93 * @param type message type of the allocated message, has no effect on the nested message
94 * @param mh message to nest
95 * @return a newly allocated 'struct GNUNET_MQ_Envelope *'
97 #define GNUNET_MQ_msg_nested_mh(mvar, type, mh) \
98 ({struct GNUNET_MQ_Envelope *_ev;\
99 _ev = GNUNET_MQ_msg_nested_mh_((struct GNUNET_MessageHeader**) &(mvar),\
103 (void)(mvar)->header; /* type check */\
108 * Return a pointer to the message at the end of the given message.
110 * @param var pointer to a message struct, the type of the expression determines the base size,
111 * the space after the base size is the nested message
112 * @return a 'struct GNUNET_MessageHeader *' that points at the nested message of the given message,
113 * or NULL if the given message in @a var does not have any space after the message struct
115 #define GNUNET_MQ_extract_nested_mh(var) GNUNET_MQ_extract_nested_mh_ ((struct GNUNET_MessageHeader *) (var), sizeof (*(var)))
119 * Implementation of the #GNUNET_MQ_extract_nexted_mh macro.
121 * @param mh message header to extract nested message header from
122 * @param base_size size of the message before the nested message's header appears
123 * @return pointer to the nested message, does not copy the message
124 * OR NULL in case of a malformed message.
126 const struct GNUNET_MessageHeader *
127 GNUNET_MQ_extract_nested_mh_ (const struct GNUNET_MessageHeader *mh,
132 * Opaque handle to an envelope.
134 struct GNUNET_MQ_Envelope;
138 * Obtain message contained in envelope.
140 * @param env the envelope
141 * @return message contained in the envelope
143 const struct GNUNET_MessageHeader *
144 GNUNET_MQ_env_get_msg (const struct GNUNET_MQ_Envelope *env);
148 * Return next envelope in queue.
150 * @param env a queued envelope
151 * @return next one, or NULL
153 const struct GNUNET_MQ_Envelope *
154 GNUNET_MQ_env_next (const struct GNUNET_MQ_Envelope *env);
158 * Implementation of the #GNUNET_MQ_msg_nested_mh macro.
160 * @param mhp pointer to the message header pointer that will be changed to allocate at
161 * the newly allocated space for the message.
162 * @param base_size size of the data before the nested message
163 * @param type type of the message in the envelope
164 * @param nested_mh the message to append to the message after base_size
166 struct GNUNET_MQ_Envelope *
167 GNUNET_MQ_msg_nested_mh_ (struct GNUNET_MessageHeader **mhp,
170 const struct GNUNET_MessageHeader *nested_mh);
174 * Opaque handle to a message queue.
176 struct GNUNET_MQ_Handle;
180 * Error codes for the queue.
185 * Failed to read message from the network.
186 * FIXME: Likely not properly distinguished
187 * from TIMEOUT case in the code!
189 GNUNET_MQ_ERROR_READ = 1,
194 GNUNET_MQ_ERROR_WRITE = 2,
199 GNUNET_MQ_ERROR_TIMEOUT = 4,
202 * We received a message that was malformed and thus
203 * could not be passed to its handler.
205 GNUNET_MQ_ERROR_MALFORMED = 8,
208 * We received a message for which we have no matching
211 GNUNET_MQ_ERROR_NO_MATCH = 16
216 * Called when a message has been received.
219 * @param msg the received message
222 (*GNUNET_MQ_MessageCallback) (void *cls,
223 const struct GNUNET_MessageHeader *msg);
227 * Called when a message needs to be validated.
230 * @param msg the received message
231 * @return #GNUNET_OK if the message is well-formed,
232 * #GNUNET_SYSERR if not
235 (*GNUNET_MQ_MessageValidationCallback) (void *cls,
236 const struct GNUNET_MessageHeader *msg);
240 * Signature of functions implementing the
241 * sending functionality of a message queue.
243 * @param mq the message queue
244 * @param msg the message to send
245 * @param impl_state state of the implementation
248 (*GNUNET_MQ_SendImpl) (struct GNUNET_MQ_Handle *mq,
249 const struct GNUNET_MessageHeader *msg,
254 * Signature of functions implementing the
255 * destruction of a message queue.
256 * Implementations must not free @a mq, but should
257 * take care of @a impl_state.
259 * @param mq the message queue to destroy
260 * @param impl_state state of the implementation
263 (*GNUNET_MQ_DestroyImpl) (struct GNUNET_MQ_Handle *mq,
268 * Implementation function that cancels the currently sent message.
270 * @param mq message queue
271 * @param impl_state state specific to the implementation
274 (*GNUNET_MQ_CancelImpl) (struct GNUNET_MQ_Handle *mq,
279 * Generic error handler, called with the appropriate
280 * error code and the same closure specified at the creation of
282 * Not every message queue implementation supports an error handler.
285 * @param error error code
288 (*GNUNET_MQ_ErrorHandler) (void *cls,
289 enum GNUNET_MQ_Error error);
293 * Insert @a env into the envelope DLL starting at @a env_head
294 * Note that @a env must not be in any MQ while this function
295 * is used with DLLs defined outside of the MQ module. This
296 * is just in case some application needs to also manage a
297 * FIFO of envelopes independent of MQ itself and wants to
298 * re-use the pointers internal to @a env. Use with caution.
300 * @param[in|out] env_head of envelope DLL
301 * @param[in|out] env_tail tail of envelope DLL
302 * @param[in|out] env element to insert at the tail
305 GNUNET_MQ_dll_insert_tail (struct GNUNET_MQ_Envelope **env_head,
306 struct GNUNET_MQ_Envelope **env_tail,
307 struct GNUNET_MQ_Envelope *env);
311 * Remove @a env from the envelope DLL starting at @a env_head.
312 * Note that @a env must not be in any MQ while this function
313 * is used with DLLs defined outside of the MQ module. This
314 * is just in case some application needs to also manage a
315 * FIFO of envelopes independent of MQ itself and wants to
316 * re-use the pointers internal to @a env. Use with caution.
318 * @param[in|out] env_head of envelope DLL
319 * @param[in|out] env_tail tail of envelope DLL
320 * @param[in|out] env element to remove from the DLL
323 GNUNET_MQ_dll_remove (struct GNUNET_MQ_Envelope **env_head,
324 struct GNUNET_MQ_Envelope **env_tail,
325 struct GNUNET_MQ_Envelope *env);
329 * Copy an array of handlers.
331 * Useful if the array has been delared in local memory and needs to be
332 * persisted for future use.
334 * @param handlers Array of handlers to be copied.
335 * @return A newly allocated array of handlers.
336 * Needs to be freed with #GNUNET_free.
338 struct GNUNET_MQ_MessageHandler *
339 GNUNET_MQ_copy_handlers (const struct GNUNET_MQ_MessageHandler *handlers);
343 * Copy an array of handlers, appending AGPL handler.
345 * Useful if the array has been delared in local memory and needs to be
346 * persisted for future use.
348 * @param handlers Array of handlers to be copied. Can be NULL (nothing done).
349 * @param agpl_handler function to call for AGPL handling
350 * @param agpl_cls closure for @a agpl_handler
351 * @return A newly allocated array of handlers.
352 * Needs to be freed with #GNUNET_free.
354 struct GNUNET_MQ_MessageHandler *
355 GNUNET_MQ_copy_handlers2 (const struct GNUNET_MQ_MessageHandler *handlers,
356 GNUNET_MQ_MessageCallback agpl_handler,
361 * Count the handlers in a handler array.
363 * @param handlers Array of handlers to be counted.
364 * @return The number of handlers in the array.
367 GNUNET_MQ_count_handlers (const struct GNUNET_MQ_MessageHandler *handlers);
371 * Message handler for a specific message type.
373 struct GNUNET_MQ_MessageHandler
376 * Callback to validate a message of the specified @e type.
377 * The closure given to @e mv will be this struct (not @e ctx).
378 * Using NULL means only size-validation using
379 * @e expected_size. In this case, @e expected_size must
382 GNUNET_MQ_MessageValidationCallback mv;
385 * Callback, called every time a new message of
386 * the specified @e type has been receied.
387 * The closure given to @e mv will be this struct (not @e ctx).
389 GNUNET_MQ_MessageCallback cb;
392 * Closure for @e mv and @e cb.
397 * Type of the message this handler covers, in host byte order.
402 * Expected size of messages of this type. Minimum size of the
403 * message if @e mv is non-NULL. Messages of the given type will be
404 * discarded (and the connection closed with an error reported to
405 * the application) if they do not have the right size.
407 uint16_t expected_size;
412 * End-marker for the handlers array
414 #define GNUNET_MQ_handler_end() { NULL, NULL, NULL, 0, 0 }
418 * Defines a static function @a name which takes as a single argument
419 * a message handler for fixed-sized messages of type @a code and with
420 * a message type argument of @a str. Given such an argument, the
421 * function @name will return a `struct GNUNET_MQ_MessageHandler`
422 * for the given message type.
424 * The macro is to be used as follows:
426 * struct GNUNET_MessageTest { ... }; // must be fixed size
428 * handle_test_message (void *cls,
429 * const struct GNUNET_MessageTest *msg)
432 * struct GNUNET_MQ_MessageHandler handlers[] = {
433 * GNUNET_MQ_hd_fixed_size(test_message,
434 * GNUNET_MESSAGE_TYPE_TEST,
435 * struct GNUNET_MessageTest,
437 * GNUNET_MQ_handler_end()
440 * @param name unique basename for the functions
441 * @param code message type constant
442 * @param str type of the message (a struct)
443 * @param ctx context for the callbacks
445 #define GNUNET_MQ_hd_fixed_size(name,code,str,ctx) \
447 void (*_cb)(void *cls, const str *msg) = &handle_##name; \
448 ((struct GNUNET_MQ_MessageHandler) { \
449 NULL, (GNUNET_MQ_MessageCallback) _cb, \
450 (ctx), (code), sizeof (str) }); \
455 * Defines a static function @a name which takes two arguments and a
456 * context-pointer for validating and handling variable-sized messages
457 * of type @a code and with a message type argument of @a str. Given
458 * such arguments, the function @name will return a `struct
459 * GNUNET_MQ_MessageHandler` for the given message type.
461 * The macro is to be used as follows:
463 * struct GNUNET_MessageTest { ... }; // can be variable size
465 * check_test (void *cls,
466 * const struct GNUNET_MessageTest *msg)
468 * const char *ctx = cls;
469 * GNUNET_assert (0 == strcmp ("context", ctx));
473 * handle_test (void *cls,
474 * const struct GNUNET_MessageTest *msg)
476 * const char *ctx = cls;
477 * GNUNET_assert (0 == strcmp ("context", ctx));
481 * struct GNUNET_MQ_MessageHandler handlers[] = {
482 * GNUNET_MQ_hd_var_size(test_message,
483 * GNUNET_MESSAGE_TYPE_TEST,
484 * struct GNUNET_MessageTest,
486 * GNUNET_MQ_handler_end()
489 * @param name unique basename for the functions
490 * @param code message type constant
491 * @param str type of the message (a struct)
492 * @param ctx context for the callbacks
494 #define GNUNET_MQ_hd_var_size(name,code,str,ctx) \
496 int (*_mv)(void *cls, const str *msg) = &check_##name; \
497 void (*_cb)(void *cls, const str *msg) = &handle_##name; \
498 ((struct GNUNET_MQ_MessageHandler) \
499 { (GNUNET_MQ_MessageValidationCallback) _mv, \
500 (GNUNET_MQ_MessageCallback) _cb, \
501 (ctx), (code), sizeof (str) }); \
506 * Insert code for a "check_" function that verifies that
507 * a given variable-length message received over the network
508 * is followed by a 0-terminated string. If the message @a m
509 * is not followed by a 0-terminated string, an error is logged
510 * and the function is returned with #GNUNET_NO.
512 * @param an IPC message with proper type to determine
513 * the size, starting with a `struct GNUNET_MessageHeader`
515 #define GNUNET_MQ_check_zero_termination(m) \
517 const char *str = (const char *) &m[1]; \
518 const struct GNUNET_MessageHeader *hdr = \
519 (const struct GNUNET_MessageHeader *) m; \
520 uint16_t slen = ntohs (hdr->size) - sizeof (*m); \
521 if ( (0 == slen) || \
522 (memchr (str, 0, slen) != &str[slen - 1]) ) \
531 * Create a new envelope.
533 * @param mhp message header to store the allocated message header in, can be NULL
534 * @param size size of the message to allocate
535 * @param type type of the message, will be set in the allocated message
536 * @return the allocated MQ message
538 struct GNUNET_MQ_Envelope *
539 GNUNET_MQ_msg_ (struct GNUNET_MessageHeader **mhp,
545 * Create a new envelope by copying an existing message.
547 * @param hdr header of the message to copy
548 * @return envelope containing @a hdr
550 struct GNUNET_MQ_Envelope *
551 GNUNET_MQ_msg_copy (const struct GNUNET_MessageHeader *hdr);
555 * Discard the message queue message, free all
556 * allocated resources. Must be called in the event
557 * that a message is created but should not actually be sent.
559 * @param mqm the message to discard
562 GNUNET_MQ_discard (struct GNUNET_MQ_Envelope *mqm);
566 * Function to obtain the current envelope
567 * from within #GNUNET_MQ_SendImpl implementations.
569 * @param mq message queue to interrogate
570 * @return the current envelope
572 struct GNUNET_MQ_Envelope *
573 GNUNET_MQ_get_current_envelope (struct GNUNET_MQ_Handle *mq);
577 * Function to copy an envelope. The envelope must not yet
578 * be in any queue or have any options or callbacks set.
580 * @param env envelope to copy
581 * @return copy of @a env
583 struct GNUNET_MQ_Envelope *
584 GNUNET_MQ_env_copy (struct GNUNET_MQ_Envelope *env);
588 * Function to obtain the last envelope in the queue.
590 * @param mq message queue to interrogate
591 * @return the last envelope in the queue
593 struct GNUNET_MQ_Envelope *
594 GNUNET_MQ_get_last_envelope (struct GNUNET_MQ_Handle *mq);
598 * Set application-specific options for this envelope.
599 * Overrides the options set for the queue with
600 * #GNUNET_MQ_set_options() for this message only.
602 * @param env message to set options for
603 * @param flags flags to use (meaning is queue-specific)
604 * @param extra additional buffer for further data (also queue-specific)
607 GNUNET_MQ_env_set_options (struct GNUNET_MQ_Envelope *env,
613 * Get application-specific options for this envelope.
615 * @param env message to set options for
616 * @param[out] flags set to flags to use (meaning is queue-specific)
617 * @return extra additional buffer for further data (also queue-specific)
620 GNUNET_MQ_env_get_options (struct GNUNET_MQ_Envelope *env,
625 * Remove the first envelope that has not yet been sent from the message
626 * queue and return it.
628 * @param mq queue to remove envelope from
629 * @return NULL if queue is empty (or has no envelope that is not under transmission)
631 struct GNUNET_MQ_Envelope *
632 GNUNET_MQ_unsent_head (struct GNUNET_MQ_Handle *mq);
636 * Set application-specific options for this queue.
638 * @param mq message queue to set options for
639 * @param flags flags to use (meaning is queue-specific)
640 * @param extra additional buffer for further data (also queue-specific)
643 GNUNET_MQ_set_options (struct GNUNET_MQ_Handle *mq,
649 * Obtain the current length of the message queue.
651 * @param mq queue to inspect
652 * @return number of queued, non-transmitted messages
655 GNUNET_MQ_get_length (struct GNUNET_MQ_Handle *mq);
659 * Send a message with the given message queue.
660 * May only be called once per message.
662 * @param mq message queue
663 * @param ev the envelope with the message to send.
666 GNUNET_MQ_send (struct GNUNET_MQ_Handle *mq,
667 struct GNUNET_MQ_Envelope *ev);
671 * Send a copy of a message with the given message queue.
672 * Can be called repeatedly on the same envelope.
674 * @param mq message queue
675 * @param ev the envelope with the message to send.
678 GNUNET_MQ_send_copy (struct GNUNET_MQ_Handle *mq,
679 const struct GNUNET_MQ_Envelope *ev);
683 * Cancel sending the message. Message must have been sent with
684 * #GNUNET_MQ_send before. May not be called after the notify sent
685 * callback has been called
687 * @param ev queued envelope to cancel
690 GNUNET_MQ_send_cancel (struct GNUNET_MQ_Envelope *ev);
694 * Associate the assoc_data in @a mq with a unique request id.
696 * @param mq message queue, id will be unique for the queue
697 * @param assoc_data to associate
700 GNUNET_MQ_assoc_add (struct GNUNET_MQ_Handle *mq,
705 * Get the data associated with a @a request_id in a queue
707 * @param mq the message queue with the association
708 * @param request_id the request id we are interested in
709 * @return the associated data
712 GNUNET_MQ_assoc_get (struct GNUNET_MQ_Handle *mq,
713 uint32_t request_id);
717 * Remove the association for a @a request_id
719 * @param mq the message queue with the association
720 * @param request_id the request id we want to remove
721 * @return the associated data
724 GNUNET_MQ_assoc_remove (struct GNUNET_MQ_Handle *mq,
725 uint32_t request_id);
729 * Create a message queue for the specified handlers.
731 * @param send function the implements sending messages
732 * @param destroy function that implements destroying the queue
733 * @param cancel function that implements canceling a message
734 * @param impl_state for the queue, passed to @a send, @a destroy and @a cancel
735 * @param handlers array of message handlers
736 * @param error_handler handler for read and write errors
737 * @param cls closure for message handlers and error handler
738 * @return a new message queue
740 struct GNUNET_MQ_Handle *
741 GNUNET_MQ_queue_for_callbacks (GNUNET_MQ_SendImpl send,
742 GNUNET_MQ_DestroyImpl destroy,
743 GNUNET_MQ_CancelImpl cancel,
745 const struct GNUNET_MQ_MessageHandler *handlers,
746 GNUNET_MQ_ErrorHandler error_handler,
751 * Change the closure argument in all of the `handlers` of the
754 * @param mq to modify
755 * @param handlers_cls new closure to use
758 GNUNET_MQ_set_handlers_closure (struct GNUNET_MQ_Handle *mq,
763 * Call a callback once the envelope has been sent, that is,
764 * sending it can not be canceled anymore.
765 * There can be only one notify sent callback per envelope.
767 * @param ev message to call the notify callback for
768 * @param cb the notify callback
769 * @param cb_cls closure for the callback
772 GNUNET_MQ_notify_sent (struct GNUNET_MQ_Envelope *ev,
773 GNUNET_SCHEDULER_TaskCallback cb,
778 * Destroy the message queue.
780 * @param mq message queue to destroy
783 GNUNET_MQ_destroy (struct GNUNET_MQ_Handle *mq);
787 * Handle we return for callbacks registered to be
788 * notified when #GNUNET_MQ_destroy() is called on a queue.
790 struct GNUNET_MQ_DestroyNotificationHandle;
794 * Register function to be called whenever @a mq is being
797 * @param mq message queue to watch
798 * @param cb function to call on @a mq destruction
799 * @param cb_cls closure for @a cb
800 * @return handle for #GNUNET_MQ_destroy_notify_cancel().
802 struct GNUNET_MQ_DestroyNotificationHandle *
803 GNUNET_MQ_destroy_notify (struct GNUNET_MQ_Handle *mq,
804 GNUNET_SCHEDULER_TaskCallback cb,
808 * Cancel registration from #GNUNET_MQ_destroy_notify().
810 * @param dnh handle for registration to cancel
813 GNUNET_MQ_destroy_notify_cancel (struct GNUNET_MQ_DestroyNotificationHandle *dnh);
817 * Call the message message handler that was registered
818 * for the type of the given message in the given message queue.
820 * This function is indended to be used for the implementation
823 * @param mq message queue with the handlers
824 * @param mh message to dispatch
827 GNUNET_MQ_inject_message (struct GNUNET_MQ_Handle *mq,
828 const struct GNUNET_MessageHeader *mh);
832 * Call the error handler of a message queue with the given
833 * error code. If there is no error handler, log a warning.
835 * This function is intended to be used for the implementation
838 * @param mq message queue
839 * @param error the error type
842 GNUNET_MQ_inject_error (struct GNUNET_MQ_Handle *mq,
843 enum GNUNET_MQ_Error error);
847 * Call the send implementation for the next queued message, if any.
848 * Calls the send notification for the current message unless
849 * #GNUNET_MQ_impl_send_in_flight was called for this envelope.
851 * Only useful for implementing message queues, results in undefined
852 * behavior if not used carefully.
854 * @param mq message queue to send the next message with
857 GNUNET_MQ_impl_send_continue (struct GNUNET_MQ_Handle *mq);
861 * Call the send notification for the current message, but do not
862 * try to send the next message until #gnunet_mq_impl_send_continue
865 * Only useful for implementing message queues, results in undefined
866 * behavior if not used carefully.
868 * @param mq message queue to send the next message with
871 GNUNET_MQ_impl_send_in_flight (struct GNUNET_MQ_Handle *mq);
875 * Get the implementation state associated with the
878 * While the GNUNET_MQ_Impl* callbacks receive the
879 * implementation state, continuations that are scheduled
880 * by the implementation function often only have one closure
881 * argument, with this function it is possible to get at the
882 * implementation state when only passing the `struct GNUNET_MQ_Handle`
885 * @param mq message queue with the current message
886 * @return message to send, never NULL
889 GNUNET_MQ_impl_state (struct GNUNET_MQ_Handle *mq);
893 * Get the message that should currently be sent.
894 * Fails if there is no current message.
895 * Only useful for implementing message queues,
896 * results in undefined behavior if not used carefully.
898 * @param mq message queue with the current message
899 * @return message to send, never NULL
901 const struct GNUNET_MessageHeader *
902 GNUNET_MQ_impl_current (struct GNUNET_MQ_Handle *mq);
907 * Enum defining all known preference categories.
909 enum GNUNET_MQ_PreferenceKind
913 * No preference was expressed.
915 GNUNET_MQ_PREFERENCE_NONE = 0,
918 * The preferred transmission for this envelope focuses on
919 * maximizing bandwidth.
921 GNUNET_MQ_PREFERENCE_BANDWIDTH = 1,
924 * The preferred transmission for this envelope foces on
925 * minimizing latency.
927 GNUNET_MQ_PREFERENCE_LATENCY = 2,
930 * The preferred transmission for this envelope foces on
933 GNUNET_MQ_PREFERENCE_RELIABILITY = 3
936 * Number of preference values allowed.
938 #define GNUNET_MQ_PREFERENCE_COUNT 4
944 * Convert an `enum GNUNET_MQ_PreferenceType` to a string
946 * @param type the preference type
947 * @return a string or NULL if invalid
950 GNUNET_MQ_preference_to_string (enum GNUNET_MQ_PreferenceKind type);
957 /** @} */ /* end of group mq */