aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-01-24 16:47:51 +0000
committerChristian Grothoff <christian@grothoff.org>2010-01-24 16:47:51 +0000
commit145d221194b71a52403a8323839f7b4039764ece (patch)
tree5383522d05700fdaaf3e977575350053aa866af7 /src/core
parent6b26c6b0babd2b0964875cad68c866639ea94936 (diff)
downloadgnunet-145d221194b71a52403a8323839f7b4039764ece.tar.gz
gnunet-145d221194b71a52403a8323839f7b4039764ece.zip
adding support for outbound message monitoring
Diffstat (limited to 'src/core')
-rw-r--r--src/core/gnunet-service-core.c62
1 files changed, 44 insertions, 18 deletions
diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c
index cb74fc8c2..a0e1fb1c7 100644
--- a/src/core/gnunet-service-core.c
+++ b/src/core/gnunet-service-core.c
@@ -23,11 +23,6 @@
23 * @brief high-level P2P messaging 23 * @brief high-level P2P messaging
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 * 25 *
26 * TODO:
27 * - not all GNUNET_CORE_OPTION_SEND_* flags are fully supported yet
28 * (i.e. no SEND_XXX_OUTBOUND).
29 * - 'REQUEST_DISCONNECT' is not implemented (transport API is lacking!)
30 *
31 * Considerations for later: 26 * Considerations for later:
32 * - check that hostkey used by transport (for HELLOs) is the 27 * - check that hostkey used by transport (for HELLOs) is the
33 * same as the hostkey that we are using! 28 * same as the hostkey that we are using!
@@ -54,6 +49,13 @@
54#define MAX_WINDOW_TIME (5 * 60 * 1000) 49#define MAX_WINDOW_TIME (5 * 60 * 1000)
55 50
56/** 51/**
52 * How many messages do we queue up at most for optional
53 * notifications to a client? (this can cause notifications
54 * about outgoing messages to be dropped).
55 */
56#define MAX_NOTIFY_QUEUE 16
57
58/**
57 * Minimum of bytes per minute (out) to assign to any connected peer. 59 * Minimum of bytes per minute (out) to assign to any connected peer.
58 * Should be rather low; values larger than DEFAULT_BPM_IN_OUT make no 60 * Should be rather low; values larger than DEFAULT_BPM_IN_OUT make no
59 * sense. 61 * sense.
@@ -1350,11 +1352,13 @@ batch_message (struct Neighbour *n,
1350 struct GNUNET_TIME_Relative *retry_time, 1352 struct GNUNET_TIME_Relative *retry_time,
1351 unsigned int *priority) 1353 unsigned int *priority)
1352{ 1354{
1355 char ntmb[GNUNET_SERVER_MAX_MESSAGE_SIZE];
1356 struct NotifyTrafficMessage *ntm = (struct NotifyTrafficMessage*) ntmb;
1353 struct MessageEntry *pos; 1357 struct MessageEntry *pos;
1354 struct MessageEntry *prev; 1358 struct MessageEntry *prev;
1355 struct MessageEntry *next; 1359 struct MessageEntry *next;
1356 size_t ret; 1360 size_t ret;
1357 1361
1358 ret = 0; 1362 ret = 0;
1359 *priority = 0; 1363 *priority = 0;
1360 *deadline = GNUNET_TIME_UNIT_FOREVER_ABS; 1364 *deadline = GNUNET_TIME_UNIT_FOREVER_ABS;
@@ -1366,6 +1370,11 @@ batch_message (struct Neighbour *n,
1366 retry_time->value); 1370 retry_time->value);
1367 return 0; 1371 return 0;
1368 } 1372 }
1373 ntm->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_NOTIFY_OUTBOUND);
1374 ntm->distance = htonl (n->last_distance);
1375 ntm->latency = GNUNET_TIME_relative_hton (n->last_latency);
1376 ntm->peer = n->peer;
1377
1369 pos = n->messages; 1378 pos = n->messages;
1370 prev = NULL; 1379 prev = NULL;
1371 while ((pos != NULL) && (size >= sizeof (struct GNUNET_MessageHeader))) 1380 while ((pos != NULL) && (size >= sizeof (struct GNUNET_MessageHeader)))
@@ -1374,6 +1383,33 @@ batch_message (struct Neighbour *n,
1374 if (GNUNET_YES == pos->do_transmit) 1383 if (GNUNET_YES == pos->do_transmit)
1375 { 1384 {
1376 GNUNET_assert (pos->size <= size); 1385 GNUNET_assert (pos->size <= size);
1386 /* do notifications */
1387 /* FIXME: track if we have *any* client that wants
1388 full notifications and only do this if that is
1389 actually true */
1390 if (pos->size < GNUNET_SERVER_MAX_MESSAGE_SIZE - sizeof (struct NotifyTrafficMessage))
1391 {
1392 memcpy (&ntm[1], &pos[1], pos->size);
1393 ntm->header.size = htons (sizeof (struct NotifyTrafficMessage) +
1394 sizeof (struct GNUNET_MessageHeader));
1395 send_to_all_clients (&ntm->header,
1396 GNUNET_YES,
1397 GNUNET_CORE_OPTION_SEND_HDR_OUTBOUND);
1398 }
1399 else
1400 {
1401 /* message too large for 'full' notifications, we do at
1402 least the 'hdr' type */
1403 memcpy (&ntm[1],
1404 &pos[1],
1405 sizeof (struct GNUNET_MessageHeader));
1406 }
1407 ntm->header.size = htons (sizeof (struct NotifyTrafficMessage) +
1408 pos->size);
1409 send_to_all_clients (&ntm->header,
1410 GNUNET_YES,
1411 GNUNET_CORE_OPTION_SEND_FULL_OUTBOUND);
1412 /* copy for encrypted transmission */
1377 memcpy (&buf[ret], &pos[1], pos->size); 1413 memcpy (&buf[ret], &pos[1], pos->size);
1378 ret += pos->size; 1414 ret += pos->size;
1379 size -= pos->size; 1415 size -= pos->size;
@@ -3096,17 +3132,6 @@ run (void *cls,
3096 "CORE", 3132 "CORE",
3097 "TOTAL_QUOTA_OUT", 3133 "TOTAL_QUOTA_OUT",
3098 &bandwidth_target_out)) || 3134 &bandwidth_target_out)) ||
3099#if 0
3100 (GNUNET_OK !=
3101 GNUNET_CONFIGURATION_get_value_number (c,
3102 "CORE",
3103 "YY",
3104 &qout)) ||
3105 (GNUNET_OK !=
3106 GNUNET_CONFIGURATION_get_value_number (c,
3107 "CORE",
3108 "ZZ_LIMIT", &tneigh)) ||
3109#endif
3110 (GNUNET_OK != 3135 (GNUNET_OK !=
3111 GNUNET_CONFIGURATION_get_value_filename (c, 3136 GNUNET_CONFIGURATION_get_value_filename (c,
3112 "GNUNETD", 3137 "GNUNETD",
@@ -3132,7 +3157,8 @@ run (void *cls,
3132 sizeof (my_public_key), &my_identity.hashPubKey); 3157 sizeof (my_public_key), &my_identity.hashPubKey);
3133 /* setup notification */ 3158 /* setup notification */
3134 server = serv; 3159 server = serv;
3135 notifier = GNUNET_SERVER_notification_context_create (server, 0); 3160 notifier = GNUNET_SERVER_notification_context_create (server,
3161 MAX_NOTIFY_QUEUE);
3136 GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL); 3162 GNUNET_SERVER_disconnect_notify (server, &handle_client_disconnect, NULL);
3137 /* setup transport connection */ 3163 /* setup transport connection */
3138 transport = GNUNET_TRANSPORT_connect (sched, 3164 transport = GNUNET_TRANSPORT_connect (sched,