diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-01-22 21:25:54 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-01-22 21:25:54 +0000 |
commit | 750da2796162b92c533f9666104c47407ed09e46 (patch) | |
tree | b1fe3ec2ca36854a15fd8e97760d05e9a54836b9 /src/ats/ats_api_scheduling.c | |
parent | 9c95f4ea09fa61fc193fc45873f76bf6fe6d93f3 (diff) | |
download | gnunet-750da2796162b92c533f9666104c47407ed09e46.tar.gz gnunet-750da2796162b92c533f9666104c47407ed09e46.zip |
simplifying IPC for address in use and address update
Diffstat (limited to 'src/ats/ats_api_scheduling.c')
-rw-r--r-- | src/ats/ats_api_scheduling.c | 41 |
1 files changed, 3 insertions, 38 deletions
diff --git a/src/ats/ats_api_scheduling.c b/src/ats/ats_api_scheduling.c index 1b729f75e..8fced8996 100644 --- a/src/ats/ats_api_scheduling.c +++ b/src/ats/ats_api_scheduling.c | |||
@@ -1319,8 +1319,6 @@ GNUNET_ATS_address_update (struct GNUNET_ATS_AddressRecord *ar, | |||
1319 | struct GNUNET_MQ_Envelope *ev; | 1319 | struct GNUNET_MQ_Envelope *ev; |
1320 | struct AddressUpdateMessage *m; | 1320 | struct AddressUpdateMessage *m; |
1321 | struct GNUNET_ATS_Information *am; | 1321 | struct GNUNET_ATS_Information *am; |
1322 | char *pm; | ||
1323 | size_t namelen; | ||
1324 | size_t msize; | 1322 | size_t msize; |
1325 | 1323 | ||
1326 | GNUNET_array_grow (ar->ats, | 1324 | GNUNET_array_grow (ar->ats, |
@@ -1333,18 +1331,11 @@ GNUNET_ATS_address_update (struct GNUNET_ATS_AddressRecord *ar, | |||
1333 | 1331 | ||
1334 | if (NULL == sh->mq) | 1332 | if (NULL == sh->mq) |
1335 | return; /* disconnected, skip for now */ | 1333 | return; /* disconnected, skip for now */ |
1336 | namelen = (NULL == ar->address->transport_name) | 1334 | msize = ar->ats_count * sizeof (struct GNUNET_ATS_Information); |
1337 | ? 0 | ||
1338 | : strlen (ar->address->transport_name) + 1; | ||
1339 | msize = ar->address->address_length + | ||
1340 | ar->ats_count * sizeof (struct GNUNET_ATS_Information) + namelen; | ||
1341 | 1335 | ||
1342 | ev = GNUNET_MQ_msg_extra (m, msize, GNUNET_MESSAGE_TYPE_ATS_ADDRESS_UPDATE); | 1336 | ev = GNUNET_MQ_msg_extra (m, msize, GNUNET_MESSAGE_TYPE_ATS_ADDRESS_UPDATE); |
1343 | m->ats_count = htonl (ar->ats_count); | 1337 | m->ats_count = htonl (ar->ats_count); |
1344 | m->peer = ar->address->peer; | 1338 | m->peer = ar->address->peer; |
1345 | m->address_length = htons (ar->address->address_length); | ||
1346 | m->address_local_info = htonl ((uint32_t) ar->address->local_info); | ||
1347 | m->plugin_name_length = htons (namelen); | ||
1348 | m->session_id = htonl (ar->slot); | 1339 | m->session_id = htonl (ar->slot); |
1349 | 1340 | ||
1350 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1341 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1357,14 +1348,6 @@ GNUNET_ATS_address_update (struct GNUNET_ATS_AddressRecord *ar, | |||
1357 | memcpy (am, | 1348 | memcpy (am, |
1358 | ar->ats, | 1349 | ar->ats, |
1359 | ar->ats_count * sizeof (struct GNUNET_ATS_Information)); | 1350 | ar->ats_count * sizeof (struct GNUNET_ATS_Information)); |
1360 | pm = (char *) &am[ar->ats_count]; | ||
1361 | memcpy (pm, | ||
1362 | ar->address->address, | ||
1363 | ar->address->address_length); | ||
1364 | if (NULL != ar->address->transport_name) | ||
1365 | memcpy (&pm[ar->address->address_length], | ||
1366 | ar->address->transport_name, | ||
1367 | namelen); | ||
1368 | GNUNET_MQ_send (sh->mq, ev); | 1351 | GNUNET_MQ_send (sh->mq, ev); |
1369 | } | 1352 | } |
1370 | 1353 | ||
@@ -1383,36 +1366,18 @@ GNUNET_ATS_address_set_in_use (struct GNUNET_ATS_AddressRecord *ar, | |||
1383 | struct GNUNET_ATS_SchedulingHandle *sh = ar->sh; | 1366 | struct GNUNET_ATS_SchedulingHandle *sh = ar->sh; |
1384 | struct GNUNET_MQ_Envelope *ev; | 1367 | struct GNUNET_MQ_Envelope *ev; |
1385 | struct AddressUseMessage *m; | 1368 | struct AddressUseMessage *m; |
1386 | char *pm; | ||
1387 | size_t namelen; | ||
1388 | size_t msize; | ||
1389 | 1369 | ||
1390 | ar->in_use = in_use; | 1370 | ar->in_use = in_use; |
1391 | namelen = (NULL == ar->address->transport_name) | 1371 | ev = GNUNET_MQ_msg (m, GNUNET_MESSAGE_TYPE_ATS_ADDRESS_IN_USE); |
1392 | ? 0 | ||
1393 | : strlen (ar->address->transport_name) + 1; | ||
1394 | msize = ar->address->address_length + namelen; | ||
1395 | |||
1396 | ev = GNUNET_MQ_msg_extra (m, msize, GNUNET_MESSAGE_TYPE_ATS_ADDRESS_IN_USE); | ||
1397 | m->peer = ar->address->peer; | 1372 | m->peer = ar->address->peer; |
1398 | m->in_use = htons (in_use); | 1373 | m->in_use = htonl ((uint32_t) in_use); |
1399 | m->address_length = htons (ar->address->address_length); | ||
1400 | m->address_local_info = htonl ((uint32_t) ar->address->local_info); | ||
1401 | m->plugin_name_length = htons (namelen); | ||
1402 | |||
1403 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1374 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1404 | "Setting address used to %s for peer `%s', plugin `%s', session %p\n", | 1375 | "Setting address used to %s for peer `%s', plugin `%s', session %p\n", |
1405 | (GNUNET_YES == in_use) ? "YES" : "NO", | 1376 | (GNUNET_YES == in_use) ? "YES" : "NO", |
1406 | GNUNET_i2s (&ar->address->peer), | 1377 | GNUNET_i2s (&ar->address->peer), |
1407 | ar->address->transport_name, | 1378 | ar->address->transport_name, |
1408 | ar->session); | 1379 | ar->session); |
1409 | |||
1410 | m->session_id = htonl (ar->slot); | 1380 | m->session_id = htonl (ar->slot); |
1411 | pm = (char *) &m[1]; | ||
1412 | /* FIXME: no need to send the address data */ | ||
1413 | memcpy (pm, ar->address->address, ar->address->address_length); | ||
1414 | memcpy (&pm[ar->address->address_length], | ||
1415 | ar->address->transport_name, namelen); | ||
1416 | GNUNET_MQ_send (sh->mq, ev); | 1381 | GNUNET_MQ_send (sh->mq, ev); |
1417 | } | 1382 | } |
1418 | 1383 | ||