diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2014-01-08 17:51:53 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2014-01-08 17:51:53 +0000 |
commit | 5f05330cb3d9ec30347c07522de00624de9d6c67 (patch) | |
tree | 213d4a9fdd07a2017c5768d609280fce4b6f146c /src/transport/gnunet-service-transport.c | |
parent | ce8e0739623ee25d2a29a75f393027a42bbe4d4f (diff) | |
download | gnunet-5f05330cb3d9ec30347c07522de00624de9d6c67.tar.gz gnunet-5f05330cb3d9ec30347c07522de00624de9d6c67.zip |
neighbour monitoring api implemented
Diffstat (limited to 'src/transport/gnunet-service-transport.c')
-rw-r--r-- | src/transport/gnunet-service-transport.c | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index ed7a6b81b..811ef5857 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c | |||
@@ -137,17 +137,24 @@ static struct SessionKiller *sk_tail; | |||
137 | * @param cls the 'HELLO' message | 137 | * @param cls the 'HELLO' message |
138 | * @param target a connected neighbour | 138 | * @param target a connected neighbour |
139 | * @param address the address | 139 | * @param address the address |
140 | * @param state current state this peer is in | ||
141 | * @param state_timeout timeout for the current state of the peer | ||
140 | * @param bandwidth_in inbound quota in NBO | 142 | * @param bandwidth_in inbound quota in NBO |
141 | * @param bandwidth_out outbound quota in NBO | 143 | * @param bandwidth_out outbound quota in NBO |
142 | */ | 144 | */ |
143 | static void | 145 | static void |
144 | transmit_our_hello (void *cls, const struct GNUNET_PeerIdentity *target, | 146 | transmit_our_hello (void *cls, const struct GNUNET_PeerIdentity *target, |
145 | const struct GNUNET_HELLO_Address *address, | 147 | const struct GNUNET_HELLO_Address *address, |
148 | enum GNUNET_TRANSPORT_PeerState state, | ||
149 | struct GNUNET_TIME_Absolute state_timeout, | ||
146 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | 150 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, |
147 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out) | 151 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out) |
148 | { | 152 | { |
149 | const struct GNUNET_MessageHeader *hello = cls; | 153 | const struct GNUNET_MessageHeader *hello = cls; |
150 | 154 | ||
155 | if ( GNUNET_NO == GST_neighbours_test_connected(target) ) | ||
156 | return; | ||
157 | |||
151 | GST_neighbours_send (target, | 158 | GST_neighbours_send (target, |
152 | hello, | 159 | hello, |
153 | ntohs (hello->size), | 160 | ntohs (hello->size), |
@@ -838,13 +845,28 @@ neighbours_disconnect_notification (void *cls, | |||
838 | * @param cls closure | 845 | * @param cls closure |
839 | * @param peer peer this update is about (never NULL) | 846 | * @param peer peer this update is about (never NULL) |
840 | * @param address address, NULL on disconnect | 847 | * @param address address, NULL on disconnect |
848 | * @param state current state this peer is in | ||
849 | * @param state_timeout timeout for the current state of the peer | ||
850 | * @param bandwidth_in bandwidth assigned inbound | ||
851 | * @param bandwidth_out bandwidth assigned outbound | ||
841 | */ | 852 | */ |
842 | static void | 853 | static void |
843 | neighbours_address_notification (void *cls, | 854 | neighbours_changed_notification (void *cls, |
844 | const struct GNUNET_PeerIdentity *peer, | 855 | const struct GNUNET_PeerIdentity *peer, |
845 | const struct GNUNET_HELLO_Address *address) | 856 | const struct GNUNET_HELLO_Address *address, |
857 | enum GNUNET_TRANSPORT_PeerState state, | ||
858 | struct GNUNET_TIME_Absolute state_timeout, | ||
859 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | ||
860 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out) | ||
846 | { | 861 | { |
847 | GST_clients_broadcast_address_notification (peer, address); | 862 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
863 | "Notifying about change for peer `%s' with address `%s' in state `%s' timing out at %s\n", | ||
864 | GNUNET_i2s (peer), | ||
865 | (NULL != address) ? GST_plugins_a2s (address) : "<none>", | ||
866 | GNUNET_TRANSPORT_p2s(state), | ||
867 | GNUNET_STRINGS_absolute_time_to_string(state_timeout)); | ||
868 | |||
869 | GST_clients_broadcast_peer_notification (peer, address, state, state_timeout); | ||
848 | } | 870 | } |
849 | 871 | ||
850 | 872 | ||
@@ -994,7 +1016,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, | |||
994 | GST_neighbours_start (NULL, | 1016 | GST_neighbours_start (NULL, |
995 | &neighbours_connect_notification, | 1017 | &neighbours_connect_notification, |
996 | &neighbours_disconnect_notification, | 1018 | &neighbours_disconnect_notification, |
997 | &neighbours_address_notification, | 1019 | &neighbours_changed_notification, |
998 | (max_fd / 3) * 2); | 1020 | (max_fd / 3) * 2); |
999 | GST_clients_start (GST_server); | 1021 | GST_clients_start (GST_server); |
1000 | GST_validation_start ((max_fd / 3)); | 1022 | GST_validation_start ((max_fd / 3)); |