/**
- * Data structure for each client connected to the core service.
+ * Data structure for each client connected to the CORE service.
*/
struct GSC_Client
{
/**
* Array of the types of messages this peer cares
- * about (with "tcnt" entries). Allocated as part
+ * about (with @e tcnt entries). Allocated as part
* of this client struct, do not free!
*/
const uint16_t *types;
/**
* Map of peer identities to active transmission requests of this
- * client to the peer (of type 'struct GSC_ClientActiveRequest').
+ * client to the peer (of type `struct GSC_ClientActiveRequest`).
*/
struct GNUNET_CONTAINER_MultiPeerMap *requests;
/**
* Number of types of incoming messages this client
- * specifically cares about. Size of the "types" array.
+ * specifically cares about. Size of the @e types array.
*/
unsigned int tcnt;
*
* @param type message type
* @param c client to test
- * @return GNUNET_YES if 'c' is interested, GNUNET_NO if not.
+ * @return #GNUNET_YES if @a c is interested, #GNUNET_NO if not.
*/
static int
type_match (uint16_t type, struct GSC_Client *c)
struct GSC_Client *c;
int tm;
- for (c = client_head; c != NULL; c = c->next)
+ for (c = client_head; NULL != c; c = c->next)
{
tm = type_match (type, c);
if (! ( (0 != (c->options & options)) ||
*
* @param cls unused
* @param client new client that sent INIT
- * @param message the 'struct InitMessage' (presumably)
+ * @param message the `struct InitMessage` (presumably)
*/
static void
-handle_client_init (void *cls, struct GNUNET_SERVER_Client *client,
+handle_client_init (void *cls,
+ struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
{
const struct InitMessage *im;
*
* @param cls unused
* @param client new client that sent CORE_SEND_REQUEST
- * @param message the 'struct SendMessageRequest' (presumably)
+ * @param message the `struct SendMessageRequest` (presumably)
*/
static void
-handle_client_send_request (void *cls, struct GNUNET_SERVER_Client *client,
+handle_client_send_request (void *cls,
+ struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
{
const struct SendMessageRequest *req;
}
car = GNUNET_CONTAINER_multipeermap_get (c->requests, &req->peer);
- if (car == NULL)
+ if (NULL == car)
{
/* create new entry */
- car = GNUNET_malloc (sizeof (struct GSC_ClientActiveRequest));
+ car = GNUNET_new (struct GSC_ClientActiveRequest);
GNUNET_assert (GNUNET_OK ==
GNUNET_CONTAINER_multipeermap_put (c->requests,
&req->peer,
}
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;
/**
- * Closure for the 'client_tokenizer_callback'.
+ * Closure for the #client_tokenizer_callback().
*/
struct TokenizerContext
{
*/
struct GSC_ClientActiveRequest *car;
+ /**
+ * How important is this message.
+ */
+ enum GNUNET_CORE_Priority priority;
+
/**
* Is corking allowed (set only once we have the real message).
*/
*
* @param cls unused
* @param client the client issuing the request
- * @param message the "struct SendMessage"
+ * @param message the `struct SendMessage`
*/
static void
-handle_client_send (void *cls, struct GNUNET_SERVER_Client *client,
+handle_client_send (void *cls,
+ struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
{
const struct SendMessage *sm;
msize -= sizeof (struct SendMessage);
GNUNET_break (0 == ntohl (sm->reserved));
c = find_client (client);
- if (c == NULL)
+ if (NULL == c)
{
/* client did not send INIT first! */
GNUNET_break (0);
&sm->peer,
tc.car));
tc.cork = ntohl (sm->cork);
+ tc.priority = (enum GNUNET_CORE_Priority) ntohl (sm->priority);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Client asked for transmission of %u bytes to `%s' %s\n", msize,
+ "Client asked for transmission of %u bytes to `%s' %s\n",
+ msize,
GNUNET_i2s (&sm->peer), tc.cork ? "now" : "");
- GNUNET_SERVER_mst_receive (client_mst, &tc, (const char *) &sm[1], msize,
+ GNUNET_SERVER_mst_receive (client_mst, &tc,
+ (const char *) &sm[1], msize,
GNUNET_YES, GNUNET_NO);
if (0 !=
memcmp (&tc.car->target, &GSC_my_identity,
* 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
else
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Delivering message of type %u to %s\n", ntohs (message->type),
+ "Delivering message of type %u to %s\n",
+ ntohs (message->type),
GNUNET_i2s (&car->target));
GSC_CLIENTS_deliver_message (&car->target, message,
ntohs (message->size),
GSC_CLIENTS_deliver_message (&car->target, message,
sizeof (struct GNUNET_MessageHeader),
GNUNET_CORE_OPTION_SEND_HDR_OUTBOUND);
- GSC_SESSIONS_transmit (car, message, tc->cork);
+ GSC_SESSIONS_transmit (car,
+ message,
+ tc->cork,
+ tc->priority);
}
return GNUNET_OK;
}
*
* @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
* @param client identification of the client
*/
static void
-handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client)
+handle_client_disconnect (void *cls,
+ struct GNUNET_SERVER_Client *client)
{
struct GSC_Client *c;
- if (client == NULL)
+ if (NULL == client)
return;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Client %p has disconnected from core service.\n", client);
*
* @param client client to notify
* @param neighbour identity of the neighbour that changed status
- * @param tmap_old previous type map for the neighbour, NULL for disconnect
+ * @param tmap_old previous type map for the neighbour, NULL for connect
* @param tmap_new updated type map for the neighbour, NULL for disconnect
*/
void
GSC_CLIENTS_notify_client_about_neighbour (struct GSC_Client *client,
- const struct GNUNET_PeerIdentity
- *neighbour,
+ const struct GNUNET_PeerIdentity *neighbour,
const struct GSC_TypeMap *tmap_old,
const struct GSC_TypeMap *tmap_new)
{
cnm->header.size = htons (size);
cnm->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_NOTIFY_CONNECT);
cnm->reserved = htonl (0);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending `%s' message to client.\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Sending `%s' message to client.\n",
"NOTIFY_CONNECT");
cnm->peer = *neighbour;
send_to_client (client, &cnm->header, GNUNET_NO);
* or types processed by the respective peer.
*
* @param neighbour identity of the neighbour that changed status
- * @param tmap_old previous type map for the neighbour, NULL for disconnect
+ * @param tmap_old previous type map for the neighbour, NULL for connect
* @param tmap_new updated type map for the neighbour, NULL for disconnect
*/
void
-GSC_CLIENTS_notify_clients_about_neighbour (const struct GNUNET_PeerIdentity
- *neighbour,
+GSC_CLIENTS_notify_clients_about_neighbour (const struct GNUNET_PeerIdentity *neighbour,
const struct GSC_TypeMap *tmap_old,
const struct GSC_TypeMap *tmap_new)
{
struct GSC_Client *c;
- for (c = client_head; c != NULL; c = c->next)
+ for (c = client_head; NULL != c; c = c->next)
GSC_CLIENTS_notify_client_about_neighbour (c, neighbour,
tmap_old, tmap_new);
}
static const struct GNUNET_SERVER_MessageHandler handlers[] = {
{&handle_client_init, NULL,
GNUNET_MESSAGE_TYPE_CORE_INIT, 0},
- {&GSC_SESSIONS_handle_client_iterate_peers, NULL,
- GNUNET_MESSAGE_TYPE_CORE_ITERATE_PEERS,
+ {&GSC_KX_handle_client_monitor_peers, NULL,
+ GNUNET_MESSAGE_TYPE_CORE_MONITOR_PEERS,
sizeof (struct GNUNET_MessageHeader)},
{&handle_client_send_request, NULL,
GNUNET_MESSAGE_TYPE_CORE_SEND_REQUEST,
client_mst = GNUNET_SERVER_mst_create (&client_tokenizer_callback, NULL);
notifier =
GNUNET_SERVER_notification_context_create (server, MAX_NOTIFY_QUEUE);
- GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL);
+ GNUNET_SERVER_disconnect_notify (server,
+ &handle_client_disconnect, NULL);
GNUNET_SERVER_add_handlers (server, handlers);
}