diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-02-02 23:16:13 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-02-02 23:16:13 +0000 |
commit | 8727c5c69097aeb474ce6039bf31650400b6286a (patch) | |
tree | 7159a82133c6d5d411a02a513aa247df7031a263 /src | |
parent | fee260b50973a0e26eaa10a5736a3e16ee6201ae (diff) | |
download | gnunet-8727c5c69097aeb474ce6039bf31650400b6286a.tar.gz gnunet-8727c5c69097aeb474ce6039bf31650400b6286a.zip |
reduce callback insanity for callbacks that are always bound to only one value
Diffstat (limited to 'src')
-rw-r--r-- | src/transport/gnunet-service-transport.c | 109 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport.h | 2 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_neighbours.c | 210 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_neighbours.h | 16 |
4 files changed, 133 insertions, 204 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index ca0f6b813..cd6bd9dff 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | (C) 2010,2011 Christian Grothoff (and other contributing authors) | 3 | (C) 2010-2015 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -132,11 +132,6 @@ struct GNUNET_ATS_SchedulingHandle *GST_ats; | |||
132 | struct GNUNET_TIME_Relative hello_expiration; | 132 | struct GNUNET_TIME_Relative hello_expiration; |
133 | 133 | ||
134 | /** | 134 | /** |
135 | * DEBUGGING connection counter | ||
136 | */ | ||
137 | static int connections; | ||
138 | |||
139 | /** | ||
140 | * Head of DLL of asynchronous tasks to kill sessions. | 135 | * Head of DLL of asynchronous tasks to kill sessions. |
141 | */ | 136 | */ |
142 | static struct SessionKiller *sk_head; | 137 | static struct SessionKiller *sk_head; |
@@ -845,102 +840,6 @@ ats_request_address_change (void *cls, | |||
845 | 840 | ||
846 | 841 | ||
847 | /** | 842 | /** |
848 | * Function called to notify transport users that another | ||
849 | * peer connected to us. | ||
850 | * | ||
851 | * @param cls closure | ||
852 | * @param peer the peer that connected | ||
853 | * @param bandwidth_in inbound bandwidth in NBO | ||
854 | * @param bandwidth_out outbound bandwidth in NBO | ||
855 | */ | ||
856 | static void | ||
857 | neighbours_connect_notification (void *cls, | ||
858 | const struct GNUNET_PeerIdentity *peer, | ||
859 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | ||
860 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out) | ||
861 | { | ||
862 | size_t len = sizeof(struct ConnectInfoMessage); | ||
863 | char buf[len] GNUNET_ALIGN; | ||
864 | struct ConnectInfoMessage *connect_msg = (struct ConnectInfoMessage *) buf; | ||
865 | |||
866 | connections++; | ||
867 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
868 | "We are now connected to peer `%s' and %u peers in total\n", | ||
869 | GNUNET_i2s (peer), | ||
870 | connections); | ||
871 | connect_msg->header.size = htons (sizeof(buf)); | ||
872 | connect_msg->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT); | ||
873 | connect_msg->id = *peer; | ||
874 | connect_msg->quota_in = bandwidth_in; | ||
875 | connect_msg->quota_out = bandwidth_out; | ||
876 | GST_clients_broadcast (&connect_msg->header, GNUNET_NO); | ||
877 | } | ||
878 | |||
879 | |||
880 | /** | ||
881 | * Function called to notify transport users that another | ||
882 | * peer disconnected from us. | ||
883 | * | ||
884 | * @param cls closure | ||
885 | * @param peer the peer that disconnected | ||
886 | */ | ||
887 | static void | ||
888 | neighbours_disconnect_notification (void *cls, | ||
889 | const struct GNUNET_PeerIdentity *peer) | ||
890 | { | ||
891 | struct DisconnectInfoMessage disconnect_msg; | ||
892 | |||
893 | connections--; | ||
894 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
895 | "Peer `%s' disconnected and we are connected to %u peers\n", | ||
896 | GNUNET_i2s (peer), | ||
897 | connections); | ||
898 | |||
899 | GST_manipulation_peer_disconnect (peer); | ||
900 | disconnect_msg.header.size = htons (sizeof(struct DisconnectInfoMessage)); | ||
901 | disconnect_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT); | ||
902 | disconnect_msg.reserved = htonl (0); | ||
903 | disconnect_msg.peer = *peer; | ||
904 | GST_clients_broadcast (&disconnect_msg.header, GNUNET_NO); | ||
905 | } | ||
906 | |||
907 | |||
908 | /** | ||
909 | * Function called to notify transport users that a neighbour peer changed its | ||
910 | * active address. | ||
911 | * | ||
912 | * @param cls closure | ||
913 | * @param peer identity of the peer | ||
914 | * @param address address possibly NULL if peer is not connected | ||
915 | * @param state current state this peer is in | ||
916 | * @param state_timeout timeout for the current state of the peer | ||
917 | * @param bandwidth_in bandwidth assigned inbound, 0 on disconnect | ||
918 | * @param bandwidth_out bandwidth assigned outbound, 0 on disconnect | ||
919 | */ | ||
920 | static void | ||
921 | neighbours_changed_notification (void *cls, | ||
922 | const struct GNUNET_PeerIdentity *peer, | ||
923 | const struct GNUNET_HELLO_Address *address, | ||
924 | enum GNUNET_TRANSPORT_PeerState state, | ||
925 | struct GNUNET_TIME_Absolute state_timeout, | ||
926 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | ||
927 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out) | ||
928 | { | ||
929 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
930 | "Notifying about change for peer `%s' with address `%s' in state `%s' timing out at %s\n", | ||
931 | GNUNET_i2s (peer), | ||
932 | GST_plugins_a2s (address), | ||
933 | GNUNET_TRANSPORT_ps2s (state), | ||
934 | GNUNET_STRINGS_absolute_time_to_string (state_timeout)); | ||
935 | /* FIXME: include bandwidth in notification! */ | ||
936 | GST_clients_broadcast_peer_notification (peer, | ||
937 | address, | ||
938 | state, | ||
939 | state_timeout); | ||
940 | } | ||
941 | |||
942 | |||
943 | /** | ||
944 | * Function called when the service shuts down. Unloads our plugins | 843 | * Function called when the service shuts down. Unloads our plugins |
945 | * and cancels pending validations. | 844 | * and cancels pending validations. |
946 | * | 845 | * |
@@ -1097,11 +996,7 @@ run (void *cls, | |||
1097 | &plugin_env_session_end, | 996 | &plugin_env_session_end, |
1098 | &plugin_env_address_to_type, | 997 | &plugin_env_address_to_type, |
1099 | &plugin_env_update_metrics); | 998 | &plugin_env_update_metrics); |
1100 | GST_neighbours_start (NULL, | 999 | GST_neighbours_start ((max_fd / 3) * 2); |
1101 | &neighbours_connect_notification, | ||
1102 | &neighbours_disconnect_notification, | ||
1103 | &neighbours_changed_notification, | ||
1104 | (max_fd / 3) * 2); | ||
1105 | GST_clients_start (GST_server); | 1000 | GST_clients_start (GST_server); |
1106 | GST_validation_start ((max_fd / 3)); | 1001 | GST_validation_start ((max_fd / 3)); |
1107 | } | 1002 | } |
diff --git a/src/transport/gnunet-service-transport.h b/src/transport/gnunet-service-transport.h index 34b0083a2..350ae5b6c 100644 --- a/src/transport/gnunet-service-transport.h +++ b/src/transport/gnunet-service-transport.h | |||
@@ -101,5 +101,7 @@ GST_receive_callback (void *cls, | |||
101 | const struct GNUNET_MessageHeader *message); | 101 | const struct GNUNET_MessageHeader *message); |
102 | 102 | ||
103 | 103 | ||
104 | |||
105 | |||
104 | #endif | 106 | #endif |
105 | /* end of file gnunet-service-transport_plugins.h */ | 107 | /* end of file gnunet-service-transport_plugins.h */ |
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c index 401e6eb2b..f1095095a 100644 --- a/src/transport/gnunet-service-transport_neighbours.c +++ b/src/transport/gnunet-service-transport_neighbours.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include "gnunet-service-transport_blacklist.h" | 29 | #include "gnunet-service-transport_blacklist.h" |
30 | #include "gnunet-service-transport_clients.h" | 30 | #include "gnunet-service-transport_clients.h" |
31 | #include "gnunet-service-transport_neighbours.h" | 31 | #include "gnunet-service-transport_neighbours.h" |
32 | #include "gnunet-service-transport_manipulation.h" | ||
32 | #include "gnunet-service-transport_plugins.h" | 33 | #include "gnunet-service-transport_plugins.h" |
33 | #include "gnunet-service-transport_validation.h" | 34 | #include "gnunet-service-transport_validation.h" |
34 | #include "gnunet-service-transport.h" | 35 | #include "gnunet-service-transport.h" |
@@ -507,26 +508,6 @@ static struct BlacklistCheckSwitchContext *pending_bc_head; | |||
507 | static struct BlacklistCheckSwitchContext *pending_bc_tail; | 508 | static struct BlacklistCheckSwitchContext *pending_bc_tail; |
508 | 509 | ||
509 | /** | 510 | /** |
510 | * Closure for #connect_notify_cb, #disconnect_notify_cb and #neighbour_change_cb | ||
511 | */ | ||
512 | static void *callback_cls; | ||
513 | |||
514 | /** | ||
515 | * Function to call when we connected to a neighbour. | ||
516 | */ | ||
517 | static NotifyConnect connect_notify_cb; | ||
518 | |||
519 | /** | ||
520 | * Function to call when we disconnected from a neighbour. | ||
521 | */ | ||
522 | static GNUNET_TRANSPORT_NotifyDisconnect disconnect_notify_cb; | ||
523 | |||
524 | /** | ||
525 | * Function to call when a neighbour changed address, state or bandwidth. | ||
526 | */ | ||
527 | static GNUNET_TRANSPORT_NeighbourChangeCallback neighbour_change_cb; | ||
528 | |||
529 | /** | ||
530 | * counter for connected neighbours | 511 | * counter for connected neighbours |
531 | */ | 512 | */ |
532 | static unsigned int neighbours_connected; | 513 | static unsigned int neighbours_connected; |
@@ -566,6 +547,93 @@ print_ack_state (enum GST_ACK_State s) | |||
566 | } | 547 | } |
567 | } | 548 | } |
568 | 549 | ||
550 | |||
551 | /** | ||
552 | * Notify our clients that another peer connected to us. | ||
553 | * | ||
554 | * @param peer the peer that connected | ||
555 | * @param bandwidth_in inbound bandwidth in NBO | ||
556 | * @param bandwidth_out outbound bandwidth in NBO | ||
557 | */ | ||
558 | static void | ||
559 | neighbours_connect_notification (const struct GNUNET_PeerIdentity *peer, | ||
560 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | ||
561 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out) | ||
562 | { | ||
563 | size_t len = sizeof(struct ConnectInfoMessage); | ||
564 | char buf[len] GNUNET_ALIGN; | ||
565 | struct ConnectInfoMessage *connect_msg = (struct ConnectInfoMessage *) buf; | ||
566 | |||
567 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
568 | "We are now connected to peer `%s'\n", | ||
569 | GNUNET_i2s (peer)); | ||
570 | connect_msg->header.size = htons (sizeof(buf)); | ||
571 | connect_msg->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT); | ||
572 | connect_msg->id = *peer; | ||
573 | connect_msg->quota_in = bandwidth_in; | ||
574 | connect_msg->quota_out = bandwidth_out; | ||
575 | GST_clients_broadcast (&connect_msg->header, GNUNET_NO); | ||
576 | } | ||
577 | |||
578 | |||
579 | /** | ||
580 | * Notify our clients (and manipulation) that a peer disconnected from | ||
581 | * us. | ||
582 | * | ||
583 | * @param peer the peer that disconnected | ||
584 | */ | ||
585 | static void | ||
586 | neighbours_disconnect_notification (const struct GNUNET_PeerIdentity *peer) | ||
587 | { | ||
588 | struct DisconnectInfoMessage disconnect_msg; | ||
589 | |||
590 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
591 | "Peer `%s' disconnected\n", | ||
592 | GNUNET_i2s (peer)); | ||
593 | GST_manipulation_peer_disconnect (peer); | ||
594 | disconnect_msg.header.size = htons (sizeof(struct DisconnectInfoMessage)); | ||
595 | disconnect_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT); | ||
596 | disconnect_msg.reserved = htonl (0); | ||
597 | disconnect_msg.peer = *peer; | ||
598 | GST_clients_broadcast (&disconnect_msg.header, | ||
599 | GNUNET_NO); | ||
600 | } | ||
601 | |||
602 | |||
603 | /** | ||
604 | * Notify transport clients that a neighbour peer changed its active | ||
605 | * address. | ||
606 | * | ||
607 | * @param peer identity of the peer | ||
608 | * @param address address possibly NULL if peer is not connected | ||
609 | * @param state current state this peer is in | ||
610 | * @param state_timeout timeout for the current state of the peer | ||
611 | * @param bandwidth_in bandwidth assigned inbound, 0 on disconnect | ||
612 | * @param bandwidth_out bandwidth assigned outbound, 0 on disconnect | ||
613 | */ | ||
614 | static void | ||
615 | neighbours_changed_notification (const struct GNUNET_PeerIdentity *peer, | ||
616 | const struct GNUNET_HELLO_Address *address, | ||
617 | enum GNUNET_TRANSPORT_PeerState state, | ||
618 | struct GNUNET_TIME_Absolute state_timeout, | ||
619 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | ||
620 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out) | ||
621 | { | ||
622 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
623 | "Notifying about change for peer `%s' with address `%s' in state `%s' timing out at %s\n", | ||
624 | GNUNET_i2s (peer), | ||
625 | GST_plugins_a2s (address), | ||
626 | GNUNET_TRANSPORT_ps2s (state), | ||
627 | GNUNET_STRINGS_absolute_time_to_string (state_timeout)); | ||
628 | /* FIXME: include bandwidth in notification! */ | ||
629 | GST_clients_broadcast_peer_notification (peer, | ||
630 | address, | ||
631 | state, | ||
632 | state_timeout); | ||
633 | } | ||
634 | |||
635 | |||
636 | |||
569 | /** | 637 | /** |
570 | * Lookup a neighbour entry in the neighbours hash map. | 638 | * Lookup a neighbour entry in the neighbours hash map. |
571 | * | 639 | * |
@@ -666,13 +734,12 @@ set_state (struct NeighbourMapEntry *n, | |||
666 | "Neighbour `%s' changed state to %s\n", | 734 | "Neighbour `%s' changed state to %s\n", |
667 | GNUNET_i2s (&n->id), | 735 | GNUNET_i2s (&n->id), |
668 | GNUNET_TRANSPORT_ps2s(s)); | 736 | GNUNET_TRANSPORT_ps2s(s)); |
669 | neighbour_change_cb (callback_cls, | 737 | neighbours_changed_notification (&n->id, |
670 | &n->id, | 738 | n->primary_address.address, |
671 | n->primary_address.address, | 739 | n->state, |
672 | n->state, | 740 | n->timeout, |
673 | n->timeout, | 741 | n->primary_address.bandwidth_in, |
674 | n->primary_address.bandwidth_in, | 742 | n->primary_address.bandwidth_out); |
675 | n->primary_address.bandwidth_out); | ||
676 | } | 743 | } |
677 | 744 | ||
678 | 745 | ||
@@ -695,13 +762,12 @@ set_state_and_timeout (struct NeighbourMapEntry *n, | |||
695 | GNUNET_i2s (&n->id), | 762 | GNUNET_i2s (&n->id), |
696 | GNUNET_TRANSPORT_ps2s(s), | 763 | GNUNET_TRANSPORT_ps2s(s), |
697 | GNUNET_STRINGS_absolute_time_to_string (timeout)); | 764 | GNUNET_STRINGS_absolute_time_to_string (timeout)); |
698 | neighbour_change_cb (callback_cls, | 765 | neighbours_changed_notification (&n->id, |
699 | &n->id, | 766 | n->primary_address.address, |
700 | n->primary_address.address, | 767 | n->state, |
701 | n->state, | 768 | n->timeout, |
702 | n->timeout, | 769 | n->primary_address.bandwidth_in, |
703 | n->primary_address.bandwidth_in, | 770 | n->primary_address.bandwidth_out); |
704 | n->primary_address.bandwidth_out); | ||
705 | } | 771 | } |
706 | 772 | ||
707 | 773 | ||
@@ -720,12 +786,11 @@ set_timeout (struct NeighbourMapEntry *n, | |||
720 | "Neighbour `%s' changed timeout %s\n", | 786 | "Neighbour `%s' changed timeout %s\n", |
721 | GNUNET_i2s (&n->id), | 787 | GNUNET_i2s (&n->id), |
722 | GNUNET_STRINGS_absolute_time_to_string (timeout)); | 788 | GNUNET_STRINGS_absolute_time_to_string (timeout)); |
723 | neighbour_change_cb (callback_cls, | 789 | neighbours_changed_notification (&n->id, |
724 | &n->id, | 790 | n->primary_address.address, |
725 | n->primary_address.address, | 791 | n->state, n->timeout, |
726 | n->state, n->timeout, | 792 | n->primary_address.bandwidth_in, |
727 | n->primary_address.bandwidth_in, | 793 | n->primary_address.bandwidth_out); |
728 | n->primary_address.bandwidth_out); | ||
729 | } | 794 | } |
730 | 795 | ||
731 | 796 | ||
@@ -875,13 +940,12 @@ set_primary_address (struct NeighbourMapEntry *n, | |||
875 | GNUNET_i2s (&n->id), | 940 | GNUNET_i2s (&n->id), |
876 | GST_plugins_a2s(address)); | 941 | GST_plugins_a2s(address)); |
877 | 942 | ||
878 | neighbour_change_cb (callback_cls, | 943 | neighbours_changed_notification (&n->id, |
879 | &n->id, | 944 | n->primary_address.address, |
880 | n->primary_address.address, | 945 | n->state, |
881 | n->state, | 946 | n->timeout, |
882 | n->timeout, | 947 | n->primary_address.bandwidth_in, |
883 | n->primary_address.bandwidth_in, | 948 | n->primary_address.bandwidth_out); |
884 | n->primary_address.bandwidth_out); | ||
885 | } | 949 | } |
886 | 950 | ||
887 | 951 | ||
@@ -895,13 +959,12 @@ static void | |||
895 | unset_primary_address (struct NeighbourMapEntry *n) | 959 | unset_primary_address (struct NeighbourMapEntry *n) |
896 | { | 960 | { |
897 | /* Notify monitoring about change */ | 961 | /* Notify monitoring about change */ |
898 | neighbour_change_cb (callback_cls, | 962 | neighbours_changed_notification (&n->id, |
899 | &n->id, | 963 | n->primary_address.address, |
900 | n->primary_address.address, | 964 | n->state, |
901 | n->state, | 965 | n->timeout, |
902 | n->timeout, | 966 | GNUNET_BANDWIDTH_value_init (0), |
903 | GNUNET_BANDWIDTH_value_init (0), | 967 | GNUNET_BANDWIDTH_value_init (0)); |
904 | GNUNET_BANDWIDTH_value_init (0)); | ||
905 | /* Unset primary address */ | 968 | /* Unset primary address */ |
906 | free_address (&n->primary_address); | 969 | free_address (&n->primary_address); |
907 | } | 970 | } |
@@ -957,7 +1020,7 @@ free_neighbour (struct NeighbourMapEntry *n, | |||
957 | gettext_noop ("# peers connected"), | 1020 | gettext_noop ("# peers connected"), |
958 | --neighbours_connected, | 1021 | --neighbours_connected, |
959 | GNUNET_NO); | 1022 | GNUNET_NO); |
960 | disconnect_notify_cb (callback_cls, &n->id); | 1023 | neighbours_disconnect_notification (&n->id); |
961 | } | 1024 | } |
962 | 1025 | ||
963 | /* Mark peer as disconnected */ | 1026 | /* Mark peer as disconnected */ |
@@ -1184,7 +1247,7 @@ disconnect_neighbour (struct NeighbourMapEntry *n) | |||
1184 | gettext_noop ("# peers connected"), | 1247 | gettext_noop ("# peers connected"), |
1185 | --neighbours_connected, | 1248 | --neighbours_connected, |
1186 | GNUNET_NO); | 1249 | GNUNET_NO); |
1187 | disconnect_notify_cb (callback_cls, &n->id); | 1250 | neighbours_disconnect_notification (&n->id); |
1188 | set_state (n, GNUNET_TRANSPORT_PS_DISCONNECT); | 1251 | set_state (n, GNUNET_TRANSPORT_PS_DISCONNECT); |
1189 | break; | 1252 | break; |
1190 | case GNUNET_TRANSPORT_PS_RECONNECT_ATS: | 1253 | case GNUNET_TRANSPORT_PS_RECONNECT_ATS: |
@@ -3213,10 +3276,9 @@ GST_neighbours_handle_session_syn_ack (const struct GNUNET_MessageHeader *messag | |||
3213 | gettext_noop ("# peers connected"), | 3276 | gettext_noop ("# peers connected"), |
3214 | ++neighbours_connected, | 3277 | ++neighbours_connected, |
3215 | GNUNET_NO); | 3278 | GNUNET_NO); |
3216 | connect_notify_cb (callback_cls, | 3279 | neighbours_connect_notification (&n->id, |
3217 | &n->id, | 3280 | n->primary_address.bandwidth_in, |
3218 | n->primary_address.bandwidth_in, | 3281 | n->primary_address.bandwidth_out); |
3219 | n->primary_address.bandwidth_out); | ||
3220 | /* Tell ATS that the outbound session we created to send SYN was successful */ | 3282 | /* Tell ATS that the outbound session we created to send SYN was successful */ |
3221 | set_primary_address (n, | 3283 | set_primary_address (n, |
3222 | n->primary_address.address, | 3284 | n->primary_address.address, |
@@ -3502,10 +3564,9 @@ GST_neighbours_handle_session_ack (const struct GNUNET_MessageHeader *message, | |||
3502 | if (GNUNET_NO == GST_neighbours_test_connected(&n->id)) | 3564 | if (GNUNET_NO == GST_neighbours_test_connected(&n->id)) |
3503 | { | 3565 | { |
3504 | /* Notify about connection */ | 3566 | /* Notify about connection */ |
3505 | connect_notify_cb (callback_cls, | 3567 | neighbours_connect_notification (&n->id, |
3506 | &n->id, | 3568 | n->primary_address.bandwidth_in, |
3507 | n->primary_address.bandwidth_in, | 3569 | n->primary_address.bandwidth_out); |
3508 | n->primary_address.bandwidth_out); | ||
3509 | GNUNET_STATISTICS_set (GST_stats, | 3570 | GNUNET_STATISTICS_set (GST_stats, |
3510 | gettext_noop ("# peers connected"), | 3571 | gettext_noop ("# peers connected"), |
3511 | ++neighbours_connected, | 3572 | ++neighbours_connected, |
@@ -3833,24 +3894,11 @@ GST_neighbour_get_current_address (const struct GNUNET_PeerIdentity *peer) | |||
3833 | /** | 3894 | /** |
3834 | * Initialize the neighbours subsystem. | 3895 | * Initialize the neighbours subsystem. |
3835 | * | 3896 | * |
3836 | * @param cls closure for callbacks | ||
3837 | * @param connect_cb function to call if we connect to a peer | ||
3838 | * @param disconnect_cb function to call if we disconnect from a peer | ||
3839 | * @param peer_address_cb function to call if we change an active address | ||
3840 | * of a neighbour | ||
3841 | * @param max_fds maximum number of fds to use | 3897 | * @param max_fds maximum number of fds to use |
3842 | */ | 3898 | */ |
3843 | void | 3899 | void |
3844 | GST_neighbours_start (void *cls, | 3900 | GST_neighbours_start (unsigned int max_fds) |
3845 | NotifyConnect connect_cb, | 3901 | { |
3846 | GNUNET_TRANSPORT_NotifyDisconnect disconnect_cb, | ||
3847 | GNUNET_TRANSPORT_NeighbourChangeCallback peer_address_cb, | ||
3848 | unsigned int max_fds) | ||
3849 | { | ||
3850 | callback_cls = cls; | ||
3851 | connect_notify_cb = connect_cb; | ||
3852 | disconnect_notify_cb = disconnect_cb; | ||
3853 | neighbour_change_cb = peer_address_cb; | ||
3854 | neighbours = GNUNET_CONTAINER_multipeermap_create (NEIGHBOUR_TABLE_SIZE, GNUNET_NO); | 3902 | neighbours = GNUNET_CONTAINER_multipeermap_create (NEIGHBOUR_TABLE_SIZE, GNUNET_NO); |
3855 | registered_quota_notifications = GNUNET_CONTAINER_multipeermap_create (NEIGHBOUR_TABLE_SIZE, GNUNET_NO); | 3903 | registered_quota_notifications = GNUNET_CONTAINER_multipeermap_create (NEIGHBOUR_TABLE_SIZE, GNUNET_NO); |
3856 | util_transmission_tk = GNUNET_SCHEDULER_add_delayed (UTIL_TRANSMISSION_INTERVAL, | 3904 | util_transmission_tk = GNUNET_SCHEDULER_add_delayed (UTIL_TRANSMISSION_INTERVAL, |
@@ -3926,10 +3974,6 @@ GST_neighbours_stop () | |||
3926 | registered_quota_notifications = NULL; | 3974 | registered_quota_notifications = NULL; |
3927 | 3975 | ||
3928 | neighbours = NULL; | 3976 | neighbours = NULL; |
3929 | callback_cls = NULL; | ||
3930 | connect_notify_cb = NULL; | ||
3931 | disconnect_notify_cb = NULL; | ||
3932 | neighbour_change_cb = NULL; | ||
3933 | } | 3977 | } |
3934 | 3978 | ||
3935 | 3979 | ||
diff --git a/src/transport/gnunet-service-transport_neighbours.h b/src/transport/gnunet-service-transport_neighbours.h index 0c07557d0..093bd06e1 100644 --- a/src/transport/gnunet-service-transport_neighbours.h +++ b/src/transport/gnunet-service-transport_neighbours.h | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | (C) 2010,2011 Christian Grothoff (and other contributing authors) | 3 | (C) 2010-2015 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -33,26 +33,14 @@ | |||
33 | #include "transport.h" | 33 | #include "transport.h" |
34 | #include "gnunet_util_lib.h" | 34 | #include "gnunet_util_lib.h" |
35 | 35 | ||
36 | // TODO: | ||
37 | // - ATS and similar info is a bit lacking in the API right now... | ||
38 | |||
39 | |||
40 | 36 | ||
41 | /** | 37 | /** |
42 | * Initialize the neighbours subsystem. | 38 | * Initialize the neighbours subsystem. |
43 | * | 39 | * |
44 | * @param cls closure for callbacks | ||
45 | * @param connect_cb function to call if we connect to a peer | ||
46 | * @param disconnect_cb function to call if we disconnect from a peer | ||
47 | * @param peer_address_cb function to call if a neighbour's active address changes | ||
48 | * @param max_fds maximum number of fds to use | 40 | * @param max_fds maximum number of fds to use |
49 | */ | 41 | */ |
50 | void | 42 | void |
51 | GST_neighbours_start (void *cls, | 43 | GST_neighbours_start (unsigned int max_fds); |
52 | NotifyConnect connect_cb, | ||
53 | GNUNET_TRANSPORT_NotifyDisconnect disconnect_cb, | ||
54 | GNUNET_TRANSPORT_NeighbourChangeCallback peer_address_cb, | ||
55 | unsigned int max_fds); | ||
56 | 44 | ||
57 | 45 | ||
58 | /** | 46 | /** |