aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-service-transport.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/gnunet-service-transport.c')
-rw-r--r--src/transport/gnunet-service-transport.c97
1 files changed, 62 insertions, 35 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index b21b0c384..505fed797 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -359,7 +359,9 @@ connect_bl_check_cont (void *cls,
359 /* Blacklist allows to speak to this peer, forward SYN to neighbours */ 359 /* Blacklist allows to speak to this peer, forward SYN to neighbours */
360 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 360 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
361 "Received SYN message from peer `%s' with `%s' %p\n", 361 "Received SYN message from peer `%s' with `%s' %p\n",
362 GNUNET_i2s (peer), GST_plugins_a2s (blctx->address), blctx->session); 362 GNUNET_i2s (peer),
363 GST_plugins_a2s (blctx->address),
364 blctx->session);
363 365
364 if (GNUNET_OK != 366 if (GNUNET_OK !=
365 GST_neighbours_handle_session_syn (blctx->msg, 367 GST_neighbours_handle_session_syn (blctx->msg,
@@ -416,16 +418,19 @@ GST_receive_callback (void *cls,
416 if (NULL == message) 418 if (NULL == message)
417 goto end; 419 goto end;
418 type = ntohs (message->type); 420 type = ntohs (message->type);
419 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 421 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
420 "Received Message with type %u from peer `%s'\n", type, 422 "Received Message with type %u from peer `%s'\n",
421 GNUNET_i2s (&address->peer)); 423 type,
424 GNUNET_i2s (&address->peer));
422 425
423 GNUNET_STATISTICS_update (GST_stats, gettext_noop 426 GNUNET_STATISTICS_update (GST_stats,
424 ("# bytes total received"), 427 gettext_noop ("# bytes total received"),
425 ntohs (message->size), 428 ntohs (message->size),
426 GNUNET_NO); 429 GNUNET_NO);
427 GST_neighbours_notify_data_recv (&address->peer, address, session, message); 430 GST_neighbours_notify_data_recv (&address->peer,
428 431 address,
432 session,
433 message);
429 switch (type) 434 switch (type)
430 { 435 {
431 case GNUNET_MESSAGE_TYPE_HELLO_LEGACY: 436 case GNUNET_MESSAGE_TYPE_HELLO_LEGACY:
@@ -434,8 +439,9 @@ GST_receive_callback (void *cls,
434 case GNUNET_MESSAGE_TYPE_HELLO: 439 case GNUNET_MESSAGE_TYPE_HELLO:
435 if (GNUNET_OK != GST_validation_handle_hello (message)) 440 if (GNUNET_OK != GST_validation_handle_hello (message))
436 { 441 {
437 GNUNET_break_op(0); 442 GNUNET_break_op (0);
438 cancel_pending_blacklist_checks (address, session); 443 cancel_pending_blacklist_checks (address,
444 session);
439 } 445 }
440 return ret; 446 return ret;
441 case GNUNET_MESSAGE_TYPE_TRANSPORT_PING: 447 case GNUNET_MESSAGE_TYPE_TRANSPORT_PING:
@@ -448,8 +454,10 @@ GST_receive_callback (void *cls,
448 address, 454 address,
449 session)) 455 session))
450 { 456 {
451 cancel_pending_blacklist_checks (address, session); 457 cancel_pending_blacklist_checks (address,
452 kill_session (plugin_name, session); 458 session);
459 kill_session (plugin_name,
460 session);
453 } 461 }
454 break; 462 break;
455 case GNUNET_MESSAGE_TYPE_TRANSPORT_PONG: 463 case GNUNET_MESSAGE_TYPE_TRANSPORT_PONG:
@@ -472,22 +480,29 @@ GST_receive_callback (void *cls,
472 memcpy (blctx->msg, message, ntohs(message->size)); 480 memcpy (blctx->msg, message, ntohs(message->size));
473 GNUNET_CONTAINER_DLL_insert (bc_head, bc_tail, blctx); 481 GNUNET_CONTAINER_DLL_insert (bc_head, bc_tail, blctx);
474 if (NULL != (blc = GST_blacklist_test_allowed (&address->peer, NULL, 482 if (NULL != (blc = GST_blacklist_test_allowed (&address->peer, NULL,
475 &connect_bl_check_cont, blctx))) 483 &connect_bl_check_cont,
484 blctx)))
476 { 485 {
477 blctx->blc = blc; 486 blctx->blc = blc;
478 } 487 }
479 break; 488 break;
480 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_SYN_ACK: 489 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_SYN_ACK:
481 if (GNUNET_OK != GST_neighbours_handle_session_syn_ack (message, 490 if (GNUNET_OK !=
482 &address->peer, address, session)) 491 GST_neighbours_handle_session_syn_ack (message,
492 &address->peer,
493 address,
494 session))
483 { 495 {
484 cancel_pending_blacklist_checks (address, session); 496 cancel_pending_blacklist_checks (address, session);
485 kill_session (plugin_name, session); 497 kill_session (plugin_name, session);
486 } 498 }
487 break; 499 break;
488 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_ACK: 500 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_ACK:
489 if (GNUNET_OK 501 if (GNUNET_OK !=
490 != GST_neighbours_handle_session_ack (message, &address->peer, address, session)) 502 GST_neighbours_handle_session_ack (message,
503 &address->peer,
504 address,
505 session))
491 { 506 {
492 GNUNET_break_op(0); 507 GNUNET_break_op(0);
493 cancel_pending_blacklist_checks (address, session); 508 cancel_pending_blacklist_checks (address, session);
@@ -505,16 +520,26 @@ GST_receive_callback (void *cls,
505 break; 520 break;
506 default: 521 default:
507 /* should be payload */ 522 /* should be payload */
508 GNUNET_STATISTICS_update (GST_stats, gettext_noop 523 GNUNET_STATISTICS_update (GST_stats,
509 ("# bytes payload received"), ntohs (message->size), GNUNET_NO); 524 gettext_noop ("# bytes payload received"),
510 GST_neighbours_notify_payload_recv (&address->peer, address, session, message); 525 ntohs (message->size),
511 ret = process_payload (&address->peer, address, session, message); 526 GNUNET_NO);
527 GST_neighbours_notify_payload_recv (&address->peer,
528 address,
529 session,
530 message);
531 ret = process_payload (&address->peer,
532 address,
533 session,
534 message);
512 break; 535 break;
513 } 536 }
514 end: 537 end:
515 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 538 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
516 "Allowing receive from peer %s to continue in %s\n", GNUNET_i2s (&address->peer), 539 "Allowing receive from peer %s to continue in %s\n",
517 GNUNET_STRINGS_relative_time_to_string (ret, GNUNET_YES)); 540 GNUNET_i2s (&address->peer),
541 GNUNET_STRINGS_relative_time_to_string (ret,
542 GNUNET_YES));
518 return ret; 543 return ret;
519} 544}
520 545
@@ -552,9 +577,9 @@ plugin_env_address_change_notification (void *cls,
552 } 577 }
553 } 578 }
554 579
555 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 580 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
556 "Transport now has %u addresses to communicate\n", 581 "Transport now has %u addresses to communicate\n",
557 addresses); 582 addresses);
558 GST_hello_modify_addresses (add_remove, address); 583 GST_hello_modify_addresses (add_remove, address);
559} 584}
560 585
@@ -595,7 +620,8 @@ plugin_env_session_end (void *cls,
595 "Notification from plugin `%s' about terminated %s session %p from peer `%s' address `%s'\n", 620 "Notification from plugin `%s' about terminated %s session %p from peer `%s' address `%s'\n",
596 address->transport_name, 621 address->transport_name,
597 GNUNET_HELLO_address_check_option (address, 622 GNUNET_HELLO_address_check_option (address,
598 GNUNET_HELLO_ADDRESS_INFO_INBOUND) ? "inbound" : "outbound", session, 623 GNUNET_HELLO_ADDRESS_INFO_INBOUND) ? "inbound" : "outbound",
624 session,
599 GNUNET_i2s (&address->peer), 625 GNUNET_i2s (&address->peer),
600 GST_plugins_a2s (address)); 626 GST_plugins_a2s (address));
601 627
@@ -839,10 +865,10 @@ neighbours_connect_notification (void *cls,
839 struct ConnectInfoMessage *connect_msg = (struct ConnectInfoMessage *) buf; 865 struct ConnectInfoMessage *connect_msg = (struct ConnectInfoMessage *) buf;
840 866
841 connections++; 867 connections++;
842 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 868 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
843 "We are now connected to peer `%s' and %u peers in total\n", 869 "We are now connected to peer `%s' and %u peers in total\n",
844 GNUNET_i2s (peer), 870 GNUNET_i2s (peer),
845 connections); 871 connections);
846 connect_msg->header.size = htons (sizeof(buf)); 872 connect_msg->header.size = htons (sizeof(buf));
847 connect_msg->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT); 873 connect_msg->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT);
848 connect_msg->id = *peer; 874 connect_msg->id = *peer;
@@ -866,9 +892,10 @@ neighbours_disconnect_notification (void *cls,
866 struct DisconnectInfoMessage disconnect_msg; 892 struct DisconnectInfoMessage disconnect_msg;
867 893
868 connections--; 894 connections--;
869 GNUNET_log(GNUNET_ERROR_TYPE_INFO, 895 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
870 "Peer `%s' disconnected and we are connected to %u peers\n", 896 "Peer `%s' disconnected and we are connected to %u peers\n",
871 GNUNET_i2s (peer), connections); 897 GNUNET_i2s (peer),
898 connections);
872 899
873 GST_manipulation_peer_disconnect (peer); 900 GST_manipulation_peer_disconnect (peer);
874 disconnect_msg.header.size = htons (sizeof(struct DisconnectInfoMessage)); 901 disconnect_msg.header.size = htons (sizeof(struct DisconnectInfoMessage));