if (GNUNET_YES == top->test_core)
{
p->cth = GNUNET_CORE_notify_transmit_ready (
- p->me->ch, GNUNET_NO, 0, GNUNET_TIME_UNIT_MINUTES, &p->dest->id,
+ p->me->ch, GNUNET_NO,
+ GNUNET_CORE_PRIO_BEST_EFFORT,
+ GNUNET_TIME_UNIT_MINUTES, &p->dest->id,
TEST_MESSAGE_SIZE, &send_ping_ready_cb, p);
}
else
{
GNUNET_assert (NULL == p->cth);
- p->cth = GNUNET_CORE_notify_transmit_ready (p->me->ch, GNUNET_NO, 0,
- GNUNET_TIME_UNIT_MINUTES, &p->dest->id, TEST_MESSAGE_SIZE,
- &comm_send_pong_ready, p);
+ p->cth
+ = GNUNET_CORE_notify_transmit_ready (p->me->ch, GNUNET_NO,
+ GNUNET_CORE_PRIO_BEST_EFFORT,
+ GNUNET_TIME_UNIT_MINUTES,
+ &p->dest->id, TEST_MESSAGE_SIZE,
+ &comm_send_pong_ready, p);
}
else
{
/**
* How important is this message?
*/
- uint32_t priority;
+ enum GNUNET_CORE_Priority priority;
/**
* Size of this request.
smr = (struct SendMessageRequest *) &cm[1];
smr->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_SEND_REQUEST);
smr->header.size = htons (sizeof (struct SendMessageRequest));
- smr->priority = htonl (th->priority);
+ smr->priority = htonl ((uint32_t) th->priority);
smr->deadline = GNUNET_TIME_absolute_hton (th->timeout);
smr->peer = pr->peer;
smr->reserved = htonl (0);
GNUNET_i2s (&pr->peer), (unsigned int) th->msize);
sm = (struct SendMessage *) buf;
sm->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_SEND);
- sm->priority = htonl (th->priority);
+ sm->priority = htonl ((uint32_t) th->priority);
sm->deadline = GNUNET_TIME_absolute_hton (th->timeout);
sm->peer = pr->peer;
sm->cork = htonl ((uint32_t) th->cork);
/**
* Disconnect from the core service. This function can only
- * be called *after* all pending 'GNUNET_CORE_notify_transmit_ready'
+ * be called *after* all pending #GNUNET_CORE_notify_transmit_ready()
* requests have been explicitly canceled.
*
* @param handle connection to core to disconnect
*/
struct GNUNET_CORE_TransmitHandle *
GNUNET_CORE_notify_transmit_ready (struct GNUNET_CORE_Handle *handle, int cork,
- uint32_t priority,
+ enum GNUNET_CORE_Priority priority,
struct GNUNET_TIME_Relative maxdelay,
const struct GNUNET_PeerIdentity *target,
size_t notify_size,
struct PeerRecord *pr;
struct GNUNET_CORE_TransmitHandle *th;
- GNUNET_assert (NULL != handle);
- GNUNET_assert (NULL != target);
-
if (notify_size > GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE)
{
GNUNET_break (0);
GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == pr->ntr_task);
pr->ntr_task =
GNUNET_SCHEDULER_add_now (&run_request_next_transmission, pr);
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Transmission request added to queue\n");
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Transmission request added to queue\n");
return th;
}
#define GNUNET_SERVICE_CORE_H
#include "gnunet_statistics_service.h"
+#include "gnunet_core_service.h"
#include "core.h"
/**
/**
* How important is this request.
*/
- uint32_t priority;
+ enum GNUNET_CORE_Priority priority;
/**
* Has this request been solicited yet?
}
car = GNUNET_CONTAINER_multipeermap_get (c->requests, &req->peer);
- if (car == NULL)
+ if (NULL == car)
{
/* create new entry */
car = GNUNET_new (struct GSC_ClientActiveRequest);
}
car->target = req->peer;
car->deadline = GNUNET_TIME_absolute_ntoh (req->deadline);
- car->priority = ntohl (req->priority);
+ car->priority = (enum GNUNET_CORE_Priority) ntohl (req->priority);
car->msize = ntohs (req->size);
car->smr_id = req->smr_id;
car->was_solicited = GNUNET_NO;
* or other CLIENT (for loopback).
*
* @param cls closure
- * @param client reservation request ('struct GSC_ClientActiveRequest')
+ * @param client reservation request (`struct GSC_ClientActiveRequest`)
* @param message the actual message
*/
static int
*
* @param cls NULL
* @param key identity of peer for which this is an active request
- * @param value the 'struct GSC_ClientActiveRequest' to free
+ * @param value the `struct GSC_ClientActiveRequest` to free
* @return #GNUNET_YES (continue iteration)
*/
static int
"Asking core (1) for transmission to peer `%4s'\n",
GNUNET_i2s (&p2.id));
if (NULL ==
- GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_YES, 0,
+ GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_YES,
+ GNUNET_CORE_PRIO_BEST_EFFORT,
GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_SECONDS, 145),
&p2.id,
{
if (p1.ch != NULL)
GNUNET_break (NULL !=
- GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_NO, 0,
+ GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_NO,
+ GNUNET_CORE_PRIO_BEST_EFFORT,
FAST_TIMEOUT, &p2.id,
get_size (tr_n),
&transmit_ready, &p1));
GNUNET_SCHEDULER_add_delayed (TIMEOUT, &terminate_task_error, NULL);
start_time = GNUNET_TIME_absolute_get ();
GNUNET_break (NULL !=
- GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_NO, 0,
+ GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_NO,
+ GNUNET_CORE_PRIO_BEST_EFFORT,
TIMEOUT, &p2.id,
get_size (0),
&transmit_ready, &p1));
{
if (n == tr_n)
GNUNET_break (NULL !=
- GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_NO, 0,
+ GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_NO,
+ GNUNET_CORE_PRIO_BEST_EFFORT,
FAST_TIMEOUT, &p2.id,
get_size (tr_n),
&transmit_ready, &p1));
if ((p1.ch != NULL) && (p1.connect_status == 1))
GNUNET_break (NULL !=
(p1.nth =
- GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_NO, 0,
+ GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_NO,
+ GNUNET_CORE_PRIO_BEST_EFFORT,
FAST_TIMEOUT, &p2.id,
MESSAGESIZE,
&transmit_ready, &p1)));
GNUNET_break (NULL !=
(p1.nth =
- GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_NO, 0,
+ GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_NO,
+ GNUNET_CORE_PRIO_BEST_EFFORT,
TIMEOUT, &p2.id,
MESSAGESIZE,
&transmit_ready, &p1)));
if (running == GNUNET_YES)
GNUNET_break (NULL !=
- GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_NO, 0,
+ GNUNET_CORE_notify_transmit_ready (p1.ch, GNUNET_NO,
+ GNUNET_CORE_PRIO_BEST_EFFORT,
FAST_TIMEOUT, &p2.id,
MESSAGESIZE,
&transmit_ready, &p1));
GNUNET_CONTAINER_DLL_remove (peer->head, peer->tail, pending);
GNUNET_free (pending);
}
- if (pending == NULL)
+ if (NULL == pending)
{
/* no messages pending */
return 0;
}
- if (buf == NULL)
+ if (NULL == buf)
{
peer->th =
GNUNET_CORE_notify_transmit_ready (core_api, GNUNET_NO,
- pending->importance,
+ GNUNET_CORE_PRIO_BEST_EFFORT,
GNUNET_TIME_absolute_get_remaining
(pending->timeout), &peer->id,
ntohs (pending->msg->size),
{
peer->th =
GNUNET_CORE_notify_transmit_ready (core_api, GNUNET_NO,
- pending->importance,
+ GNUNET_CORE_PRIO_BEST_EFFORT,
GNUNET_TIME_absolute_get_remaining
(pending->timeout), &peer->id, msize,
&core_transmit_notify, peer);
ntohs (pending->msg->size), GNUNET_NO);
peer->th =
GNUNET_CORE_notify_transmit_ready (core_api, GNUNET_NO,
- pending->importance,
+ GNUNET_CORE_PRIO_BEST_EFFORT,
GNUNET_TIME_absolute_get_remaining
(pending->timeout), &peer->id,
ntohs (pending->msg->size),
}
-/* end of gnunet-service-dht_neighbours.c */
\ No newline at end of file
+/* end of gnunet-service-dht_neighbours.c */
dn->cth =
GNUNET_CORE_notify_transmit_ready (core_api,
GNUNET_YES /* cork */,
- 0 /* priority */,
+ GNUNET_CORE_PRIO_BEST_EFFORT,
GNUNET_TIME_UNIT_FOREVER_REL,
&dn->peer,
msize,
if (NULL == target->cth)
target->cth = GNUNET_CORE_notify_transmit_ready (core_api,
GNUNET_YES /* cork */,
- 0 /* priority */,
+ GNUNET_CORE_PRIO_BEST_EFFORT,
GNUNET_TIME_UNIT_FOREVER_REL,
&target->peer,
msize,
if (NULL != e_ctx->n->cth)
return;
- e_ctx->n->cth = GNUNET_CORE_notify_transmit_ready (ch, GNUNET_NO, 0, FAST_TIMEOUT,
+ e_ctx->n->cth = GNUNET_CORE_notify_transmit_ready (ch, GNUNET_NO,
+ GNUNET_CORE_PRIO_BEST_EFFORT,
+ FAST_TIMEOUT,
&e_ctx->n->id, e_ctx->size,
transmit_read_wrapper, e_ctx);
if (NULL == e_ctx->n->cth)
size_t ri_size = sizeof (struct GNUNET_CRYPTO_EddsaPublicKey) * my_issuer_count;
size_t total_size = msg_size + ri_size;
struct GNUNET_CRYPTO_EddsaPublicKey *issuers;
-
+
n->cth = NULL;
if (NULL == buf)
{
/**
* Set to 1 if we're currently in the process of calling
- * 'GNUNET_CORE_notify_transmit_ready' (so while cth is
+ * #GNUNET_CORE_notify_transmit_ready() (so while cth is
* NULL, we should not call notify_transmit_ready for this
* handle right now).
*/
GNUNET_assert (NULL == cp->cth);
cp->cth_in_progress++;
cp->cth =
- GNUNET_CORE_notify_transmit_ready (GSF_core, GNUNET_YES, pth->priority,
+ GNUNET_CORE_notify_transmit_ready (GSF_core, GNUNET_YES,
+ GNUNET_CORE_PRIO_BACKGROUND,
GNUNET_TIME_absolute_get_remaining
(pth->timeout), &target, pth->size,
&peer_transmit_ready_cb, cp);
/* reservation success, try transmission now! */
cp->cth_in_progress++;
cp->cth =
- GNUNET_CORE_notify_transmit_ready (GSF_core, GNUNET_YES, pth->priority,
+ GNUNET_CORE_notify_transmit_ready (GSF_core, GNUNET_YES,
+ GNUNET_CORE_PRIO_BACKGROUND,
GNUNET_TIME_absolute_get_remaining
(pth->timeout), peer, pth->size,
&peer_transmit_ready_cb, cp);
"Asked core to transmit advertisement message with a size of %u bytes to peer `%s'\n",
size, GNUNET_i2s (peer));
if (NULL ==
- GNUNET_CORE_notify_transmit_ready (core, GNUNET_YES, 0,
+ GNUNET_CORE_notify_transmit_ready (core, GNUNET_YES,
+ GNUNET_CORE_PRIO_BEST_EFFORT,
GNUNET_ADV_TIMEOUT, peer, size,
&adv_transmit_ready, NULL))
{
*/
#define GNUNET_CORE_VERSION 0x00000001
+/**
+ * Traffic priorities.
+ */
+enum GNUNET_CORE_Priority
+{
+
+ /**
+ * Highest priority, control traffic (i.e. NSE, Core/Mesh KX).
+ */
+ GNUNET_CORE_PRIO_CRITICAL_CONTROL = 0,
+
+ /**
+ * Urgent traffic (local peer, i.e. conversation).
+ */
+ GNUNET_CORE_PRIO_URGENT = 1,
+
+ /**
+ * Normal traffic (i.e. mesh/dv relay, DHT)
+ */
+ GNUNET_CORE_PRIO_BEST_EFFORT = 2,
+
+ /**
+ * Background traffic (i.e. fs)
+ */
+ GNUNET_CORE_PRIO_BACKGROUND = 3
+
+};
+
/**
* Opaque handle to the service.
* @param cls closure
* @param peer peer identity this notification is about
*/
-typedef void (*GNUNET_CORE_ConnectEventHandler) (void *cls,
- const struct GNUNET_PeerIdentity *peer);
+typedef void
+(*GNUNET_CORE_ConnectEventHandler) (void *cls,
+ const struct GNUNET_PeerIdentity *peer);
/**
* @param cls closure
* @param peer peer identity this notification is about
*/
-typedef void (*GNUNET_CORE_DisconnectEventHandler) (void *cls,
- const struct GNUNET_PeerIdentity *peer);
+typedef void
+(*GNUNET_CORE_DisconnectEventHandler) (void *cls,
+ const struct GNUNET_PeerIdentity *peer);
/**
* @return #GNUNET_OK to keep the connection open,
* #GNUNET_SYSERR to close connection to the peer (signal serious error)
*/
-typedef int (*GNUNET_CORE_MessageCallback) (void *cls,
- const struct GNUNET_PeerIdentity *
- other,
- const struct GNUNET_MessageHeader *
- message);
+typedef int
+(*GNUNET_CORE_MessageCallback) (void *cls,
+ const struct GNUNET_PeerIdentity *other,
+ const struct GNUNET_MessageHeader *message);
/**
struct GNUNET_CORE_MessageHandler
{
/**
- * Function to call for messages of "type".
+ * Function to call for messages of @e type.
*/
GNUNET_CORE_MessageCallback callback;
* @param cls closure
* @param my_identity ID of this peer, NULL if we failed
*/
-typedef void (*GNUNET_CORE_StartupCallback) (void *cls,
- const struct GNUNET_PeerIdentity *my_identity);
+typedef void
+(*GNUNET_CORE_StartupCallback) (void *cls,
+ const struct GNUNET_PeerIdentity *my_identity);
/**
* if NULL is returned, "notify" will NOT be called.
*/
struct GNUNET_CORE_TransmitHandle *
-GNUNET_CORE_notify_transmit_ready (struct GNUNET_CORE_Handle *handle, int cork,
- uint32_t priority,
+GNUNET_CORE_notify_transmit_ready (struct GNUNET_CORE_Handle *handle,
+ int cork,
+ enum GNUNET_CORE_Priority priority,
struct GNUNET_TIME_Relative maxdelay,
const struct GNUNET_PeerIdentity *target,
size_t notify_size,
peer->core_transmit =
GNUNET_CORE_notify_transmit_ready (core_handle,
GNUNET_NO,
- 0,
+ GNUNET_CORE_PRIO_CRITICAL_CONTROL,
GNUNET_TIME_UNIT_FOREVER_REL,
dst_id,
queue->size,
{
peer->core_transmit =
GNUNET_CORE_notify_transmit_ready (core_handle,
- GNUNET_NO, 0,
+ GNUNET_NO,
+ GNUNET_CORE_PRIO_CRITICAL_CONTROL,
GNUNET_TIME_UNIT_FOREVER_REL,
dst_id,
queue->size,
peer->core_transmit =
GNUNET_CORE_notify_transmit_ready (core_handle,
GNUNET_NO,
- 0,
+ GNUNET_CORE_PRIO_CRITICAL_CONTROL,
GNUNET_TIME_UNIT_FOREVER_REL,
GNUNET_PEER_resolve2 (peer->id),
size,
peer->core_transmit =
GNUNET_CORE_notify_transmit_ready (core_handle,
GNUNET_NO,
- 0,
+ GNUNET_CORE_PRIO_CRITICAL_CONTROL,
GNUNET_TIME_UNIT_FOREVER_REL,
GNUNET_PEER_resolve2 (peer->id),
size,
/**
* Message priority to use.
*/
-#define NSE_PRIORITY 5
+#define NSE_PRIORITY GNUNET_CORE_PRIO_CRITICAL_CONTROL
#if FREEBSD
#define log2(a) (log(a)/log(2))
GNUNET_assert (NULL == peer_entry->th);
peer_entry->th =
- GNUNET_CORE_notify_transmit_ready (core_api, GNUNET_NO, NSE_PRIORITY,
+ GNUNET_CORE_notify_transmit_ready (core_api, GNUNET_NO,
+ NSE_PRIORITY,
GNUNET_TIME_UNIT_FOREVER_REL,
&peer_entry->id,
sizeof (struct
{
/* now! */
pl->hello_req =
- GNUNET_CORE_notify_transmit_ready (handle, GNUNET_YES, 0,
+ GNUNET_CORE_notify_transmit_ready (handle, GNUNET_YES,
+ GNUNET_CORE_PRIO_BEST_EFFORT,
GNUNET_CONSTANTS_SERVICE_TIMEOUT,
&pl->pid, next_want,
&hello_advertising_ready, pl);