diff options
-rw-r--r-- | src/core/gnunet-service-core_kx.c | 105 | ||||
-rw-r--r-- | src/core/gnunet-service-core_neighbours.c | 8 | ||||
-rw-r--r-- | src/include/gnunet_bandwidth_lib.h | 20 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_neighbours.c | 5 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_validation.c | 5 | ||||
-rw-r--r-- | src/util/bandwidth.c | 21 |
6 files changed, 116 insertions, 48 deletions
diff --git a/src/core/gnunet-service-core_kx.c b/src/core/gnunet-service-core_kx.c index 6608725a5..4983dab0e 100644 --- a/src/core/gnunet-service-core_kx.c +++ b/src/core/gnunet-service-core_kx.c | |||
@@ -716,7 +716,8 @@ GSC_KX_start (const struct GNUNET_PeerIdentity *pid) | |||
716 | "Initiating key exchange with `%s'\n", | 716 | "Initiating key exchange with `%s'\n", |
717 | GNUNET_i2s (pid)); | 717 | GNUNET_i2s (pid)); |
718 | GNUNET_STATISTICS_update (GSC_stats, | 718 | GNUNET_STATISTICS_update (GSC_stats, |
719 | gettext_noop ("# key exchanges initiated"), 1, | 719 | gettext_noop ("# key exchanges initiated"), |
720 | 1, | ||
720 | GNUNET_NO); | 721 | GNUNET_NO); |
721 | kx = GNUNET_new (struct GSC_KeyExchangeInfo); | 722 | kx = GNUNET_new (struct GSC_KeyExchangeInfo); |
722 | kx->peer = *pid; | 723 | kx->peer = *pid; |
@@ -745,7 +746,8 @@ GSC_KX_start (const struct GNUNET_PeerIdentity *pid) | |||
745 | /* peer with "higher" identity starts a delayed KX, if the "lower" peer | 746 | /* peer with "higher" identity starts a delayed KX, if the "lower" peer |
746 | * does not start a KX since he sees no reasons to do so */ | 747 | * does not start a KX since he sees no reasons to do so */ |
747 | kx->retry_set_key_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | 748 | kx->retry_set_key_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, |
748 | &set_key_retry_task, kx); | 749 | &set_key_retry_task, |
750 | kx); | ||
749 | } | 751 | } |
750 | return kx; | 752 | return kx; |
751 | } | 753 | } |
@@ -795,7 +797,7 @@ send_ping (struct GSC_KeyExchangeInfo *kx) | |||
795 | GNUNET_NO); | 797 | GNUNET_NO); |
796 | GSC_NEIGHBOURS_transmit (&kx->peer, | 798 | GSC_NEIGHBOURS_transmit (&kx->peer, |
797 | &kx->ping.header, | 799 | &kx->ping.header, |
798 | MIN_PING_FREQUENCY); | 800 | kx->set_key_retry_frequency); |
799 | } | 801 | } |
800 | 802 | ||
801 | 803 | ||
@@ -1024,7 +1026,8 @@ GSC_KX_handle_ping (struct GSC_KeyExchangeInfo *kx, | |||
1024 | return; | 1026 | return; |
1025 | } | 1027 | } |
1026 | GNUNET_STATISTICS_update (GSC_stats, | 1028 | GNUNET_STATISTICS_update (GSC_stats, |
1027 | gettext_noop ("# PING messages received"), 1, | 1029 | gettext_noop ("# PING messages received"), |
1030 | 1, | ||
1028 | GNUNET_NO); | 1031 | GNUNET_NO); |
1029 | if ( (kx->status != GNUNET_CORE_KX_STATE_KEY_RECEIVED) && | 1032 | if ( (kx->status != GNUNET_CORE_KX_STATE_KEY_RECEIVED) && |
1030 | (kx->status != GNUNET_CORE_KX_STATE_UP) && | 1033 | (kx->status != GNUNET_CORE_KX_STATE_UP) && |
@@ -1032,7 +1035,8 @@ GSC_KX_handle_ping (struct GSC_KeyExchangeInfo *kx, | |||
1032 | { | 1035 | { |
1033 | /* ignore */ | 1036 | /* ignore */ |
1034 | GNUNET_STATISTICS_update (GSC_stats, | 1037 | GNUNET_STATISTICS_update (GSC_stats, |
1035 | gettext_noop ("# PING messages dropped (out of order)"), 1, | 1038 | gettext_noop ("# PING messages dropped (out of order)"), |
1039 | 1, | ||
1036 | GNUNET_NO); | 1040 | GNUNET_NO); |
1037 | return; | 1041 | return; |
1038 | } | 1042 | } |
@@ -1166,12 +1170,14 @@ update_timeout (struct GSC_KeyExchangeInfo *kx) | |||
1166 | are bigger than the threshold (5s) */ | 1170 | are bigger than the threshold (5s) */ |
1167 | monitor_notify_all (kx); | 1171 | monitor_notify_all (kx); |
1168 | } | 1172 | } |
1169 | if (kx->keep_alive_task != NULL) | 1173 | if (NULL != kx->keep_alive_task) |
1170 | GNUNET_SCHEDULER_cancel (kx->keep_alive_task); | 1174 | GNUNET_SCHEDULER_cancel (kx->keep_alive_task); |
1171 | kx->keep_alive_task = | 1175 | kx->keep_alive_task = |
1172 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide | 1176 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide |
1173 | (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, | 1177 | (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, |
1174 | 2), &send_keep_alive, kx); | 1178 | 2), |
1179 | &send_keep_alive, | ||
1180 | kx); | ||
1175 | } | 1181 | } |
1176 | 1182 | ||
1177 | 1183 | ||
@@ -1197,7 +1203,8 @@ GSC_KX_handle_pong (struct GSC_KeyExchangeInfo *kx, | |||
1197 | return; | 1203 | return; |
1198 | } | 1204 | } |
1199 | GNUNET_STATISTICS_update (GSC_stats, | 1205 | GNUNET_STATISTICS_update (GSC_stats, |
1200 | gettext_noop ("# PONG messages received"), 1, | 1206 | gettext_noop ("# PONG messages received"), |
1207 | 1, | ||
1201 | GNUNET_NO); | 1208 | GNUNET_NO); |
1202 | switch (kx->status) | 1209 | switch (kx->status) |
1203 | { | 1210 | { |
@@ -1227,10 +1234,16 @@ GSC_KX_handle_pong (struct GSC_KeyExchangeInfo *kx, | |||
1227 | GNUNET_i2s (&kx->peer)); | 1234 | GNUNET_i2s (&kx->peer)); |
1228 | /* mark as garbage, just to be sure */ | 1235 | /* mark as garbage, just to be sure */ |
1229 | memset (&t, 255, sizeof (t)); | 1236 | memset (&t, 255, sizeof (t)); |
1230 | derive_pong_iv (&iv, &kx->decrypt_key, m->iv_seed, kx->ping_challenge, | 1237 | derive_pong_iv (&iv, |
1238 | &kx->decrypt_key, | ||
1239 | m->iv_seed, | ||
1240 | kx->ping_challenge, | ||
1231 | &GSC_my_identity); | 1241 | &GSC_my_identity); |
1232 | if (GNUNET_OK != | 1242 | if (GNUNET_OK != |
1233 | do_decrypt (kx, &iv, &m->challenge, &t.challenge, | 1243 | do_decrypt (kx, |
1244 | &iv, | ||
1245 | &m->challenge, | ||
1246 | &t.challenge, | ||
1234 | sizeof (struct PongMessage) - ((void *) &m->challenge - | 1247 | sizeof (struct PongMessage) - ((void *) &m->challenge - |
1235 | (void *) m))) | 1248 | (void *) m))) |
1236 | { | 1249 | { |
@@ -1238,19 +1251,23 @@ GSC_KX_handle_pong (struct GSC_KeyExchangeInfo *kx, | |||
1238 | return; | 1251 | return; |
1239 | } | 1252 | } |
1240 | GNUNET_STATISTICS_update (GSC_stats, | 1253 | GNUNET_STATISTICS_update (GSC_stats, |
1241 | gettext_noop ("# PONG messages decrypted"), 1, | 1254 | gettext_noop ("# PONG messages decrypted"), |
1255 | 1, | ||
1242 | GNUNET_NO); | 1256 | GNUNET_NO); |
1243 | if ((0 != memcmp (&t.target, &kx->peer, sizeof (struct GNUNET_PeerIdentity))) | 1257 | if ((0 != memcmp (&t.target, |
1244 | || (kx->ping_challenge != t.challenge)) | 1258 | &kx->peer, |
1259 | sizeof (struct GNUNET_PeerIdentity))) || | ||
1260 | (kx->ping_challenge != t.challenge)) | ||
1245 | { | 1261 | { |
1246 | /* PONG malformed */ | 1262 | /* PONG malformed */ |
1247 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1263 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1248 | "Received malformed `%s' wanted sender `%s' with challenge %u\n", | 1264 | "Received malformed PONG wanted sender `%s' with challenge %u\n", |
1249 | "PONG", GNUNET_i2s (&kx->peer), | 1265 | GNUNET_i2s (&kx->peer), |
1250 | (unsigned int) kx->ping_challenge); | 1266 | (unsigned int) kx->ping_challenge); |
1251 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1267 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1252 | "Received malformed `%s' received from `%s' with challenge %u\n", | 1268 | "Received malformed PONG received from `%s' with challenge %u\n", |
1253 | "PONG", GNUNET_i2s (&t.target), (unsigned int) t.challenge); | 1269 | GNUNET_i2s (&t.target), |
1270 | (unsigned int) t.challenge); | ||
1254 | return; | 1271 | return; |
1255 | } | 1272 | } |
1256 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1273 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1272,8 +1289,8 @@ GSC_KX_handle_pong (struct GSC_KeyExchangeInfo *kx, | |||
1272 | return; | 1289 | return; |
1273 | case GNUNET_CORE_KX_STATE_KEY_RECEIVED: | 1290 | case GNUNET_CORE_KX_STATE_KEY_RECEIVED: |
1274 | GNUNET_STATISTICS_update (GSC_stats, | 1291 | GNUNET_STATISTICS_update (GSC_stats, |
1275 | gettext_noop | 1292 | gettext_noop ("# session keys confirmed via PONG"), |
1276 | ("# session keys confirmed via PONG"), 1, | 1293 | 1, |
1277 | GNUNET_NO); | 1294 | GNUNET_NO); |
1278 | kx->status = GNUNET_CORE_KX_STATE_UP; | 1295 | kx->status = GNUNET_CORE_KX_STATE_UP; |
1279 | monitor_notify_all (kx); | 1296 | monitor_notify_all (kx); |
@@ -1283,15 +1300,15 @@ GSC_KX_handle_pong (struct GSC_KeyExchangeInfo *kx, | |||
1283 | break; | 1300 | break; |
1284 | case GNUNET_CORE_KX_STATE_UP: | 1301 | case GNUNET_CORE_KX_STATE_UP: |
1285 | GNUNET_STATISTICS_update (GSC_stats, | 1302 | GNUNET_STATISTICS_update (GSC_stats, |
1286 | gettext_noop | 1303 | gettext_noop ("# timeouts prevented via PONG"), |
1287 | ("# timeouts prevented via PONG"), 1, | 1304 | 1, |
1288 | GNUNET_NO); | 1305 | GNUNET_NO); |
1289 | update_timeout (kx); | 1306 | update_timeout (kx); |
1290 | break; | 1307 | break; |
1291 | case GNUNET_CORE_KX_STATE_REKEY_SENT: | 1308 | case GNUNET_CORE_KX_STATE_REKEY_SENT: |
1292 | GNUNET_STATISTICS_update (GSC_stats, | 1309 | GNUNET_STATISTICS_update (GSC_stats, |
1293 | gettext_noop | 1310 | gettext_noop ("# rekey operations confirmed via PONG"), |
1294 | ("# rekey operations confirmed via PONG"), 1, | 1311 | 1, |
1295 | GNUNET_NO); | 1312 | GNUNET_NO); |
1296 | kx->status = GNUNET_CORE_KX_STATE_UP; | 1313 | kx->status = GNUNET_CORE_KX_STATE_UP; |
1297 | monitor_notify_all (kx); | 1314 | monitor_notify_all (kx); |
@@ -1331,7 +1348,8 @@ send_key (struct GSC_KeyExchangeInfo *kx) | |||
1331 | send_ping (kx); | 1348 | send_ping (kx); |
1332 | kx->retry_set_key_task = | 1349 | kx->retry_set_key_task = |
1333 | GNUNET_SCHEDULER_add_delayed (kx->set_key_retry_frequency, | 1350 | GNUNET_SCHEDULER_add_delayed (kx->set_key_retry_frequency, |
1334 | &set_key_retry_task, kx); | 1351 | &set_key_retry_task, |
1352 | kx); | ||
1335 | } | 1353 | } |
1336 | 1354 | ||
1337 | 1355 | ||
@@ -1434,9 +1452,9 @@ GSC_KX_handle_encrypted_message (struct GSC_KeyExchangeInfo *kx, | |||
1434 | if (GNUNET_CORE_KX_STATE_UP != kx->status) | 1452 | if (GNUNET_CORE_KX_STATE_UP != kx->status) |
1435 | { | 1453 | { |
1436 | GNUNET_STATISTICS_update (GSC_stats, | 1454 | GNUNET_STATISTICS_update (GSC_stats, |
1437 | gettext_noop | 1455 | gettext_noop ("# DATA message dropped (out of order)"), |
1438 | ("# DATA message dropped (out of order)"), | 1456 | 1, |
1439 | 1, GNUNET_NO); | 1457 | GNUNET_NO); |
1440 | return; | 1458 | return; |
1441 | } | 1459 | } |
1442 | if (0 == GNUNET_TIME_absolute_get_remaining (kx->foreign_key_expires).rel_value_us) | 1460 | if (0 == GNUNET_TIME_absolute_get_remaining (kx->foreign_key_expires).rel_value_us) |
@@ -1460,10 +1478,16 @@ GSC_KX_handle_encrypted_message (struct GSC_KeyExchangeInfo *kx, | |||
1460 | } | 1478 | } |
1461 | 1479 | ||
1462 | /* validate hash */ | 1480 | /* validate hash */ |
1463 | derive_auth_key (&auth_key, &kx->decrypt_key, m->iv_seed); | 1481 | derive_auth_key (&auth_key, |
1464 | GNUNET_CRYPTO_hmac (&auth_key, &m->sequence_number, | 1482 | &kx->decrypt_key, |
1465 | size - ENCRYPTED_HEADER_SIZE, &ph); | 1483 | m->iv_seed); |
1466 | if (0 != memcmp (&ph, &m->hmac, sizeof (struct GNUNET_HashCode))) | 1484 | GNUNET_CRYPTO_hmac (&auth_key, |
1485 | &m->sequence_number, | ||
1486 | size - ENCRYPTED_HEADER_SIZE, | ||
1487 | &ph); | ||
1488 | if (0 != memcmp (&ph, | ||
1489 | &m->hmac, | ||
1490 | sizeof (struct GNUNET_HashCode))) | ||
1467 | { | 1491 | { |
1468 | /* checksum failed */ | 1492 | /* checksum failed */ |
1469 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1493 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1471,10 +1495,16 @@ GSC_KX_handle_encrypted_message (struct GSC_KeyExchangeInfo *kx, | |||
1471 | GNUNET_i2s (&kx->peer)); | 1495 | GNUNET_i2s (&kx->peer)); |
1472 | return; | 1496 | return; |
1473 | } | 1497 | } |
1474 | derive_iv (&iv, &kx->decrypt_key, m->iv_seed, &GSC_my_identity); | 1498 | derive_iv (&iv, |
1499 | &kx->decrypt_key, | ||
1500 | m->iv_seed, | ||
1501 | &GSC_my_identity); | ||
1475 | /* decrypt */ | 1502 | /* decrypt */ |
1476 | if (GNUNET_OK != | 1503 | if (GNUNET_OK != |
1477 | do_decrypt (kx, &iv, &m->sequence_number, &buf[ENCRYPTED_HEADER_SIZE], | 1504 | do_decrypt (kx, |
1505 | &iv, | ||
1506 | &m->sequence_number, | ||
1507 | &buf[ENCRYPTED_HEADER_SIZE], | ||
1478 | size - ENCRYPTED_HEADER_SIZE)) | 1508 | size - ENCRYPTED_HEADER_SIZE)) |
1479 | return; | 1509 | return; |
1480 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1510 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1492,7 +1522,8 @@ GSC_KX_handle_encrypted_message (struct GSC_KeyExchangeInfo *kx, | |||
1492 | /* duplicate, ignore */ | 1522 | /* duplicate, ignore */ |
1493 | GNUNET_STATISTICS_update (GSC_stats, | 1523 | GNUNET_STATISTICS_update (GSC_stats, |
1494 | gettext_noop ("# bytes dropped (duplicates)"), | 1524 | gettext_noop ("# bytes dropped (duplicates)"), |
1495 | size, GNUNET_NO); | 1525 | size, |
1526 | GNUNET_NO); | ||
1496 | return; | 1527 | return; |
1497 | } | 1528 | } |
1498 | if ((kx->last_sequence_number_received > snum) && | 1529 | if ((kx->last_sequence_number_received > snum) && |
@@ -1587,9 +1618,9 @@ deliver_message (void *cls, | |||
1587 | if (GNUNET_CORE_KX_STATE_UP != dmc->kx->status) | 1618 | if (GNUNET_CORE_KX_STATE_UP != dmc->kx->status) |
1588 | { | 1619 | { |
1589 | GNUNET_STATISTICS_update (GSC_stats, | 1620 | GNUNET_STATISTICS_update (GSC_stats, |
1590 | gettext_noop | 1621 | gettext_noop ("# PAYLOAD dropped (out of order)"), |
1591 | ("# PAYLOAD dropped (out of order)"), | 1622 | 1, |
1592 | 1, GNUNET_NO); | 1623 | GNUNET_NO); |
1593 | return GNUNET_OK; | 1624 | return GNUNET_OK; |
1594 | } | 1625 | } |
1595 | switch (ntohs (m->type)) | 1626 | switch (ntohs (m->type)) |
diff --git a/src/core/gnunet-service-core_neighbours.c b/src/core/gnunet-service-core_neighbours.c index 9fd9207e4..e3f4425e9 100644 --- a/src/core/gnunet-service-core_neighbours.c +++ b/src/core/gnunet-service-core_neighbours.c | |||
@@ -457,8 +457,12 @@ GSC_NEIGHBOURS_transmit (const struct GNUNET_PeerIdentity *target, | |||
457 | me = GNUNET_malloc (sizeof (struct NeighbourMessageEntry) + msize); | 457 | me = GNUNET_malloc (sizeof (struct NeighbourMessageEntry) + msize); |
458 | me->deadline = GNUNET_TIME_relative_to_absolute (timeout); | 458 | me->deadline = GNUNET_TIME_relative_to_absolute (timeout); |
459 | me->size = msize; | 459 | me->size = msize; |
460 | memcpy (&me[1], msg, msize); | 460 | memcpy (&me[1], |
461 | GNUNET_CONTAINER_DLL_insert_tail (n->message_head, n->message_tail, me); | 461 | msg, |
462 | msize); | ||
463 | GNUNET_CONTAINER_DLL_insert_tail (n->message_head, | ||
464 | n->message_tail, | ||
465 | me); | ||
462 | process_queue (n); | 466 | process_queue (n); |
463 | } | 467 | } |
464 | 468 | ||
diff --git a/src/include/gnunet_bandwidth_lib.h b/src/include/gnunet_bandwidth_lib.h index 82d8a1862..1190210ba 100644 --- a/src/include/gnunet_bandwidth_lib.h +++ b/src/include/gnunet_bandwidth_lib.h | |||
@@ -195,17 +195,29 @@ GNUNET_BANDWIDTH_value_min (struct GNUNET_BANDWIDTH_Value32NBO b1, | |||
195 | 195 | ||
196 | 196 | ||
197 | /** | 197 | /** |
198 | * Compute the MAX of two bandwidth values. | ||
199 | * | ||
200 | * @param b1 first value | ||
201 | * @param b2 second value | ||
202 | * @return the min of b1 and b2 | ||
203 | */ | ||
204 | struct GNUNET_BANDWIDTH_Value32NBO | ||
205 | GNUNET_BANDWIDTH_value_max (struct GNUNET_BANDWIDTH_Value32NBO b1, | ||
206 | struct GNUNET_BANDWIDTH_Value32NBO b2); | ||
207 | |||
208 | |||
209 | /** | ||
198 | * Initialize bandwidth tracker. Note that in addition to the | 210 | * Initialize bandwidth tracker. Note that in addition to the |
199 | * 'max_carry_s' limit, we also always allow at least | 211 | * 'max_carry_s' limit, we also always allow at least |
200 | * GNUNET_SERVER_MAX_MESSAGE_SIZE to accumulate. So if the | 212 | * #GNUNET_SERVER_MAX_MESSAGE_SIZE to accumulate. So if the |
201 | * bytes-per-second limit is so small that within 'max_carry_s' not | 213 | * bytes-per-second limit is so small that within 'max_carry_s' not |
202 | * even GNUNET_SERVER_MAX_MESSAGE_SIZE is allowed to accumulate, it is | 214 | * even #GNUNET_SERVER_MAX_MESSAGE_SIZE is allowed to accumulate, it is |
203 | * ignored and replaced by GNUNET_SERVER_MAX_MESSAGE_SIZE (which is in | 215 | * ignored and replaced by #GNUNET_SERVER_MAX_MESSAGE_SIZE (which is in |
204 | * bytes). | 216 | * bytes). |
205 | * | 217 | * |
206 | * @param av tracker to initialize | 218 | * @param av tracker to initialize |
207 | * @param update_cb callback to notify a client about the tracker being updated | 219 | * @param update_cb callback to notify a client about the tracker being updated |
208 | * @param update_cb_cls cls for the callback | 220 | * @param update_cb_cls cls for the @a update_cb callback |
209 | * @param bytes_per_second_limit initial limit to assume | 221 | * @param bytes_per_second_limit initial limit to assume |
210 | * @param max_carry_s maximum number of seconds unused bandwidth | 222 | * @param max_carry_s maximum number of seconds unused bandwidth |
211 | * may accumulate before it expires | 223 | * may accumulate before it expires |
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index 87dd9c213..a2aaa19ec 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c | |||
@@ -2140,6 +2140,7 @@ setup_neighbour (const struct GNUNET_PeerIdentity *peer) | |||
2140 | n->id = *peer; | 2140 | n->id = *peer; |
2141 | n->ack_state = ACK_UNDEFINED; | 2141 | n->ack_state = ACK_UNDEFINED; |
2142 | n->last_util_transmission = GNUNET_TIME_absolute_get(); | 2142 | n->last_util_transmission = GNUNET_TIME_absolute_get(); |
2143 | n->neighbour_receive_quota = GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT; | ||
2143 | GNUNET_BANDWIDTH_tracker_init (&n->in_tracker, | 2144 | GNUNET_BANDWIDTH_tracker_init (&n->in_tracker, |
2144 | &inbound_bw_tracker_update, | 2145 | &inbound_bw_tracker_update, |
2145 | n, | 2146 | n, |
@@ -3661,7 +3662,9 @@ GST_neighbours_handle_quota_message (const struct GNUNET_PeerIdentity *peer, | |||
3661 | /* gone already */ | 3662 | /* gone already */ |
3662 | return; | 3663 | return; |
3663 | } | 3664 | } |
3664 | n->neighbour_receive_quota = GNUNET_BANDWIDTH_value_init (ntohl (sqm->quota)); | 3665 | n->neighbour_receive_quota |
3666 | = GNUNET_BANDWIDTH_value_max (GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT, | ||
3667 | GNUNET_BANDWIDTH_value_init (ntohl (sqm->quota))); | ||
3665 | 3668 | ||
3666 | bandwidth_min = GNUNET_BANDWIDTH_value_min (n->primary_address.bandwidth_out, | 3669 | bandwidth_min = GNUNET_BANDWIDTH_value_min (n->primary_address.bandwidth_out, |
3667 | n->neighbour_receive_quota); | 3670 | n->neighbour_receive_quota); |
diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c index ee8cd9308..ccd077aab 100644 --- a/src/transport/gnunet-service-transport_validation.c +++ b/src/transport/gnunet-service-transport_validation.c | |||
@@ -1524,10 +1524,10 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender, | |||
1524 | /* build HELLO to store in PEERINFO */ | 1524 | /* build HELLO to store in PEERINFO */ |
1525 | ve->copied = GNUNET_NO; | 1525 | ve->copied = GNUNET_NO; |
1526 | hello = GNUNET_HELLO_create (&ve->address->peer.public_key, | 1526 | hello = GNUNET_HELLO_create (&ve->address->peer.public_key, |
1527 | &add_valid_peer_address, | 1527 | &add_valid_peer_address, |
1528 | ve, | 1528 | ve, |
1529 | GNUNET_NO); | 1529 | GNUNET_NO); |
1530 | GNUNET_PEERINFO_add_peer (GST_peerinfo, | 1530 | GNUNET_PEERINFO_add_peer (GST_peerinfo, |
1531 | hello, | 1531 | hello, |
1532 | NULL, | 1532 | NULL, |
1533 | NULL); | 1533 | NULL); |
@@ -1549,7 +1549,6 @@ GST_validation_handle_hello (const struct GNUNET_MessageHeader *hello) | |||
1549 | const struct GNUNET_HELLO_Message *hm = | 1549 | const struct GNUNET_HELLO_Message *hm = |
1550 | (const struct GNUNET_HELLO_Message *) hello; | 1550 | (const struct GNUNET_HELLO_Message *) hello; |
1551 | struct GNUNET_PeerIdentity pid; | 1551 | struct GNUNET_PeerIdentity pid; |
1552 | struct GNUNET_HELLO_Message *h; | ||
1553 | int friend; | 1552 | int friend; |
1554 | 1553 | ||
1555 | friend = GNUNET_HELLO_is_friend_only (hm); | 1554 | friend = GNUNET_HELLO_is_friend_only (hm); |
diff --git a/src/util/bandwidth.c b/src/util/bandwidth.c index 1ed87ff9b..3b9b64239 100644 --- a/src/util/bandwidth.c +++ b/src/util/bandwidth.c | |||
@@ -61,7 +61,26 @@ GNUNET_BANDWIDTH_value_min (struct GNUNET_BANDWIDTH_Value32NBO b1, | |||
61 | { | 61 | { |
62 | return | 62 | return |
63 | GNUNET_BANDWIDTH_value_init (GNUNET_MIN | 63 | GNUNET_BANDWIDTH_value_init (GNUNET_MIN |
64 | (ntohl (b1.value__), ntohl (b2.value__))); | 64 | (ntohl (b1.value__), |
65 | ntohl (b2.value__))); | ||
66 | } | ||
67 | |||
68 | |||
69 | /** | ||
70 | * Compute the MAX of two bandwidth values. | ||
71 | * | ||
72 | * @param b1 first value | ||
73 | * @param b2 second value | ||
74 | * @return the min of b1 and b2 | ||
75 | */ | ||
76 | struct GNUNET_BANDWIDTH_Value32NBO | ||
77 | GNUNET_BANDWIDTH_value_max (struct GNUNET_BANDWIDTH_Value32NBO b1, | ||
78 | struct GNUNET_BANDWIDTH_Value32NBO b2) | ||
79 | { | ||
80 | return | ||
81 | GNUNET_BANDWIDTH_value_init (GNUNET_MAX | ||
82 | (ntohl (b1.value__), | ||
83 | ntohl (b2.value__))); | ||
65 | } | 84 | } |
66 | 85 | ||
67 | 86 | ||