aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/gnunet-service-core_kx.c24
-rw-r--r--src/util/resolver_api.c73
2 files changed, 60 insertions, 37 deletions
diff --git a/src/core/gnunet-service-core_kx.c b/src/core/gnunet-service-core_kx.c
index f6b64f367..e5e8d54aa 100644
--- a/src/core/gnunet-service-core_kx.c
+++ b/src/core/gnunet-service-core_kx.c
@@ -1274,7 +1274,7 @@ GSC_KX_encrypt_and_transmit (struct GSC_KeyExchangeInfo *kx,
1274 1274
1275 1275
1276/** 1276/**
1277 * Closure for 'deliver_message' 1277 * Closure for #deliver_message()
1278 */ 1278 */
1279struct DeliverMessageContext 1279struct DeliverMessageContext
1280{ 1280{
@@ -1320,7 +1320,7 @@ GSC_KX_handle_encrypted_message (struct GSC_KeyExchangeInfo *kx,
1320 return; 1320 return;
1321 } 1321 }
1322 m = (const struct EncryptedMessage *) msg; 1322 m = (const struct EncryptedMessage *) msg;
1323 if (kx->status != KX_STATE_UP) 1323 if (KX_STATE_UP != kx->status)
1324 { 1324 {
1325 GNUNET_STATISTICS_update (GSC_stats, 1325 GNUNET_STATISTICS_update (GSC_stats,
1326 gettext_noop 1326 gettext_noop
@@ -1365,8 +1365,10 @@ GSC_KX_handle_encrypted_message (struct GSC_KeyExchangeInfo *kx,
1365 do_decrypt (kx, &iv, &m->sequence_number, &buf[ENCRYPTED_HEADER_SIZE], 1365 do_decrypt (kx, &iv, &m->sequence_number, &buf[ENCRYPTED_HEADER_SIZE],
1366 size - ENCRYPTED_HEADER_SIZE)) 1366 size - ENCRYPTED_HEADER_SIZE))
1367 return; 1367 return;
1368 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Decrypted %u bytes from %s\n", 1368 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1369 size - ENCRYPTED_HEADER_SIZE, GNUNET_i2s (&kx->peer)); 1369 "Decrypted %u bytes from %s\n",
1370 size - ENCRYPTED_HEADER_SIZE,
1371 GNUNET_i2s (&kx->peer));
1370 pt = (struct EncryptedMessage *) buf; 1372 pt = (struct EncryptedMessage *) buf;
1371 1373
1372 /* validate sequence number */ 1374 /* validate sequence number */
@@ -1427,7 +1429,8 @@ GSC_KX_handle_encrypted_message (struct GSC_KeyExchangeInfo *kx,
1427 { 1429 {
1428 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1430 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1429 "Message received far too old (%s). Content ignored.\n", 1431 "Message received far too old (%s). Content ignored.\n",
1430 GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (t), GNUNET_YES)); 1432 GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (t),
1433 GNUNET_YES));
1431 GNUNET_STATISTICS_update (GSC_stats, 1434 GNUNET_STATISTICS_update (GSC_stats,
1432 gettext_noop 1435 gettext_noop
1433 ("# bytes dropped (ancient message)"), size, 1436 ("# bytes dropped (ancient message)"), size,
@@ -1439,14 +1442,16 @@ GSC_KX_handle_encrypted_message (struct GSC_KeyExchangeInfo *kx,
1439 update_timeout (kx); 1442 update_timeout (kx);
1440 GNUNET_STATISTICS_update (GSC_stats, 1443 GNUNET_STATISTICS_update (GSC_stats,
1441 gettext_noop ("# bytes of payload decrypted"), 1444 gettext_noop ("# bytes of payload decrypted"),
1442 size - sizeof (struct EncryptedMessage), GNUNET_NO); 1445 size - sizeof (struct EncryptedMessage),
1446 GNUNET_NO);
1443 dmc.kx = kx; 1447 dmc.kx = kx;
1444 dmc.peer = &kx->peer; 1448 dmc.peer = &kx->peer;
1445 if (GNUNET_OK != 1449 if (GNUNET_OK !=
1446 GNUNET_SERVER_mst_receive (mst, &dmc, 1450 GNUNET_SERVER_mst_receive (mst, &dmc,
1447 &buf[sizeof (struct EncryptedMessage)], 1451 &buf[sizeof (struct EncryptedMessage)],
1448 size - sizeof (struct EncryptedMessage), 1452 size - sizeof (struct EncryptedMessage),
1449 GNUNET_YES, GNUNET_NO)) 1453 GNUNET_YES,
1454 GNUNET_NO))
1450 GNUNET_break_op (0); 1455 GNUNET_break_op (0);
1451} 1456}
1452 1457
@@ -1461,7 +1466,9 @@ GSC_KX_handle_encrypted_message (struct GSC_KeyExchangeInfo *kx,
1461 * @param m the message 1466 * @param m the message
1462 */ 1467 */
1463static int 1468static int
1464deliver_message (void *cls, void *client, const struct GNUNET_MessageHeader *m) 1469deliver_message (void *cls,
1470 void *client,
1471 const struct GNUNET_MessageHeader *m)
1465{ 1472{
1466 struct DeliverMessageContext *dmc = client; 1473 struct DeliverMessageContext *dmc = client;
1467 1474
@@ -1568,7 +1575,6 @@ do_rekey (void *cls,
1568int 1575int
1569GSC_KX_init (struct GNUNET_CRYPTO_EddsaPrivateKey *pk) 1576GSC_KX_init (struct GNUNET_CRYPTO_EddsaPrivateKey *pk)
1570{ 1577{
1571 GNUNET_assert (NULL != pk);
1572 my_private_key = pk; 1578 my_private_key = pk;
1573 GNUNET_CRYPTO_eddsa_key_get_public (my_private_key, 1579 GNUNET_CRYPTO_eddsa_key_get_public (my_private_key,
1574 &GSC_my_identity.public_key); 1580 &GSC_my_identity.public_key);
diff --git a/src/util/resolver_api.c b/src/util/resolver_api.c
index 46ac52586..d097cd6a5 100644
--- a/src/util/resolver_api.c
+++ b/src/util/resolver_api.c
@@ -139,9 +139,9 @@ struct GNUNET_RESOLVER_RequestHandle
139 139
140 /** 140 /**
141 * Has this request been transmitted to the service? 141 * Has this request been transmitted to the service?
142 * GNUNET_YES if transmitted 142 * #GNUNET_YES if transmitted
143 * GNUNET_YES if not transmitted 143 * #GNUNET_YES if not transmitted
144 * GNUNET_SYSERR when request was canceled 144 * #GNUNET_SYSERR when request was canceled
145 */ 145 */
146 int was_transmitted; 146 int was_transmitted;
147 147
@@ -156,7 +156,7 @@ struct GNUNET_RESOLVER_RequestHandle
156 int direction; 156 int direction;
157 157
158 /** 158 /**
159 * GNUNET_YES if a response was received 159 * #GNUNET_YES if a response was received
160 */ 160 */
161 int received_response; 161 int received_response;
162 162
@@ -245,7 +245,8 @@ GNUNET_RESOLVER_disconnect ()
245 GNUNET_assert (NULL == req_tail); 245 GNUNET_assert (NULL == req_tail);
246 if (NULL != client) 246 if (NULL != client)
247 { 247 {
248 LOG (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from DNS service\n"); 248 LOG (GNUNET_ERROR_TYPE_DEBUG,
249 "Disconnecting from DNS service\n");
249 GNUNET_CLIENT_disconnect (client); 250 GNUNET_CLIENT_disconnect (client);
250 client = NULL; 251 client = NULL;
251 } 252 }
@@ -284,7 +285,8 @@ no_resolve (int af,
284 if (NULL == 285 if (NULL ==
285 inet_ntop (AF_INET, ip, buf, sizeof (buf))) 286 inet_ntop (AF_INET, ip, buf, sizeof (buf)))
286 { 287 {
287 LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, "inet_ntop"); 288 LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING,
289 "inet_ntop");
288 return NULL; 290 return NULL;
289 } 291 }
290 break; 292 break;
@@ -294,7 +296,8 @@ no_resolve (int af,
294 if (NULL == 296 if (NULL ==
295 inet_ntop (AF_INET6, ip, buf, sizeof (buf))) 297 inet_ntop (AF_INET6, ip, buf, sizeof (buf)))
296 { 298 {
297 LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, "inet_ntop"); 299 LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING,
300 "inet_ntop");
298 return NULL; 301 return NULL;
299 } 302 }
300 break; 303 break;
@@ -323,14 +326,16 @@ process_requests ();
323/** 326/**
324 * Process response with a hostname for a DNS lookup. 327 * Process response with a hostname for a DNS lookup.
325 * 328 *
326 * @param cls our "struct GNUNET_RESOLVER_RequestHandle" context 329 * @param cls our `struct GNUNET_RESOLVER_RequestHandle` context
327 * @param msg message with the hostname, NULL on error 330 * @param msg message with the hostname, NULL on error
328 */ 331 */
329static void 332static void
330handle_response (void *cls, const struct GNUNET_MessageHeader *msg) 333handle_response (void *cls,
334 const struct GNUNET_MessageHeader *msg)
331{ 335{
332 struct GNUNET_RESOLVER_RequestHandle *rh = cls; 336 struct GNUNET_RESOLVER_RequestHandle *rh = cls;
333 uint16_t size; 337 uint16_t size;
338 char *nret;
334 339
335 LOG (GNUNET_ERROR_TYPE_DEBUG, 340 LOG (GNUNET_ERROR_TYPE_DEBUG,
336 "Receiving response from DNS service\n"); 341 "Receiving response from DNS service\n");
@@ -354,7 +359,9 @@ handle_response (void *cls, const struct GNUNET_MessageHeader *msg)
354 /* no reverse lookup was successful, return ip as string */ 359 /* no reverse lookup was successful, return ip as string */
355 if (rh->received_response == GNUNET_NO) 360 if (rh->received_response == GNUNET_NO)
356 { 361 {
357 rh->name_callback (rh->cls, no_resolve (rh->af, &rh[1], rh->data_len)); 362 nret = no_resolve (rh->af, &rh[1], rh->data_len);
363 rh->name_callback (rh->cls, nret);
364 GNUNET_free (nret);
358 rh->name_callback (rh->cls, NULL); 365 rh->name_callback (rh->cls, NULL);
359 } 366 }
360 /* at least one reverse lookup was successful */ 367 /* at least one reverse lookup was successful */
@@ -384,7 +391,7 @@ handle_response (void *cls, const struct GNUNET_MessageHeader *msg)
384 if (size == sizeof (struct GNUNET_MessageHeader)) 391 if (size == sizeof (struct GNUNET_MessageHeader))
385 { 392 {
386 /* check if request was canceled */ 393 /* check if request was canceled */
387 if (rh->was_transmitted != GNUNET_SYSERR) 394 if (GNUNET_SYSERR != rh->was_transmitted)
388 { 395 {
389 if (NULL != rh->name_callback) 396 if (NULL != rh->name_callback)
390 rh->name_callback (rh->cls, NULL); 397 rh->name_callback (rh->cls, NULL);
@@ -414,8 +421,11 @@ handle_response (void *cls, const struct GNUNET_MessageHeader *msg)
414 reconnect (); 421 reconnect ();
415 return; 422 return;
416 } 423 }
417 LOG (GNUNET_ERROR_TYPE_DEBUG, "Resolver returns `%s' for IP `%s'.\n", 424 LOG (GNUNET_ERROR_TYPE_DEBUG,
418 hostname, GNUNET_a2s ((const void *) &rh[1], rh->data_len)); 425 "Resolver returns `%s' for IP `%s'.\n",
426 hostname,
427 GNUNET_a2s ((const void *) &rh[1],
428 rh->data_len));
419 if (rh->was_transmitted != GNUNET_SYSERR) 429 if (rh->was_transmitted != GNUNET_SYSERR)
420 rh->name_callback (rh->cls, hostname); 430 rh->name_callback (rh->cls, hostname);
421 rh->received_response = GNUNET_YES; 431 rh->received_response = GNUNET_YES;
@@ -480,11 +490,12 @@ handle_response (void *cls, const struct GNUNET_MessageHeader *msg)
480 * given a valid numeric string. Perform the callbacks for the 490 * given a valid numeric string. Perform the callbacks for the
481 * numeric addresses. 491 * numeric addresses.
482 * 492 *
483 * @param cls struct GNUNET_RESOLVER_RequestHandle for the request 493 * @param cls `struct GNUNET_RESOLVER_RequestHandle` for the request
484 * @param tc unused scheduler context 494 * @param tc unused scheduler context
485 */ 495 */
486static void 496static void
487numeric_resolution (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 497numeric_resolution (void *cls,
498 const struct GNUNET_SCHEDULER_TaskContext *tc)
488{ 499{
489 struct GNUNET_RESOLVER_RequestHandle *rh = cls; 500 struct GNUNET_RESOLVER_RequestHandle *rh = cls;
490 struct sockaddr_in v4; 501 struct sockaddr_in v4;
@@ -535,11 +546,12 @@ numeric_resolution (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
535 * given a variant of "loopback". Perform the callbacks for the 546 * given a variant of "loopback". Perform the callbacks for the
536 * respective loopback numeric addresses. 547 * respective loopback numeric addresses.
537 * 548 *
538 * @param cls struct GNUNET_RESOLVER_RequestHandle for the request 549 * @param cls `struct GNUNET_RESOLVER_RequestHandle` for the request
539 * @param tc unused scheduler context 550 * @param tc unused scheduler context
540 */ 551 */
541static void 552static void
542loopback_resolution (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 553loopback_resolution (void *cls,
554 const struct GNUNET_SCHEDULER_TaskContext *tc)
543{ 555{
544 struct GNUNET_RESOLVER_RequestHandle *rh = cls; 556 struct GNUNET_RESOLVER_RequestHandle *rh = cls;
545 struct sockaddr_in v4; 557 struct sockaddr_in v4;
@@ -650,7 +662,8 @@ process_requests ()
650 * @param tc scheduler context 662 * @param tc scheduler context
651 */ 663 */
652static void 664static void
653reconnect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 665reconnect_task (void *cls,
666 const struct GNUNET_SCHEDULER_TaskContext *tc)
654{ 667{
655 r_task = GNUNET_SCHEDULER_NO_TASK; 668 r_task = GNUNET_SCHEDULER_NO_TASK;
656 if (NULL == req_head) 669 if (NULL == req_head)
@@ -718,7 +731,7 @@ reconnect ()
718 * @param hostname the hostname to resolve 731 * @param hostname the hostname to resolve
719 * @param af AF_INET or AF_INET6; use AF_UNSPEC for "any" 732 * @param af AF_INET or AF_INET6; use AF_UNSPEC for "any"
720 * @param callback function to call with addresses 733 * @param callback function to call with addresses
721 * @param callback_cls closure for callback 734 * @param callback_cls closure for @a callback
722 * @param timeout how long to try resolving 735 * @param timeout how long to try resolving
723 * @return handle that can be used to cancel the request, NULL on error 736 * @return handle that can be used to cancel the request, NULL on error
724 */ 737 */
@@ -782,18 +795,21 @@ GNUNET_RESOLVER_ip_get (const char *hostname, int af,
782 * We've been asked to convert an address to a string without 795 * We've been asked to convert an address to a string without
783 * a reverse lookup. Do it. 796 * a reverse lookup. Do it.
784 * 797 *
785 * @param cls struct GNUNET_RESOLVER_RequestHandle for the request 798 * @param cls `struct GNUNET_RESOLVER_RequestHandle` for the request
786 * @param tc unused scheduler context 799 * @param tc unused scheduler context
787 */ 800 */
788static void 801static void
789numeric_reverse (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 802numeric_reverse (void *cls,
803 const struct GNUNET_SCHEDULER_TaskContext *tc)
790{ 804{
791 struct GNUNET_RESOLVER_RequestHandle *rh = cls; 805 struct GNUNET_RESOLVER_RequestHandle *rh = cls;
792 char *result; 806 char *result;
793 807
794 result = no_resolve (rh->af, &rh[1], rh->data_len); 808 result = no_resolve (rh->af, &rh[1], rh->data_len);
795 LOG (GNUNET_ERROR_TYPE_DEBUG, "Resolver returns `%s'.\n", result); 809 LOG (GNUNET_ERROR_TYPE_DEBUG,
796 if (result != NULL) 810 "Resolver returns `%s'.\n",
811 result);
812 if (NULL != result)
797 { 813 {
798 rh->name_callback (rh->cls, result); 814 rh->name_callback (rh->cls, result);
799 GNUNET_free (result); 815 GNUNET_free (result);
@@ -807,16 +823,17 @@ numeric_reverse (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
807 * Get an IP address as a string. 823 * Get an IP address as a string.
808 * 824 *
809 * @param sa host address 825 * @param sa host address
810 * @param salen length of host address 826 * @param salen length of host address in @a sa
811 * @param do_resolve use GNUNET_NO to return numeric hostname 827 * @param do_resolve use #GNUNET_NO to return numeric hostname
812 * @param timeout how long to try resolving 828 * @param timeout how long to try resolving
813 * @param callback function to call with hostnames 829 * @param callback function to call with hostnames
814 * last callback is NULL when finished 830 * last callback is NULL when finished
815 * @param cls closure for callback 831 * @param cls closure for @a callback
816 * @return handle that can be used to cancel the request 832 * @return handle that can be used to cancel the request
817 */ 833 */
818struct GNUNET_RESOLVER_RequestHandle * 834struct GNUNET_RESOLVER_RequestHandle *
819GNUNET_RESOLVER_hostname_get (const struct sockaddr *sa, socklen_t salen, 835GNUNET_RESOLVER_hostname_get (const struct sockaddr *sa,
836 socklen_t salen,
820 int do_resolve, 837 int do_resolve,
821 struct GNUNET_TIME_Relative timeout, 838 struct GNUNET_TIME_Relative timeout,
822 GNUNET_RESOLVER_HostnameCallback callback, 839 GNUNET_RESOLVER_HostnameCallback callback,
@@ -901,7 +918,7 @@ GNUNET_RESOLVER_local_fqdn_get ()
901 * 918 *
902 * @param af AF_INET or AF_INET6; use AF_UNSPEC for "any" 919 * @param af AF_INET or AF_INET6; use AF_UNSPEC for "any"
903 * @param callback function to call with addresses 920 * @param callback function to call with addresses
904 * @param cls closure for callback 921 * @param cls closure for @a callback
905 * @param timeout how long to try resolving 922 * @param timeout how long to try resolving
906 * @return handle that can be used to cancel the request, NULL on error 923 * @return handle that can be used to cancel the request, NULL on error
907 */ 924 */