aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-service-transport.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-02-02 22:25:48 +0000
committerChristian Grothoff <christian@grothoff.org>2015-02-02 22:25:48 +0000
commit69c3a52cfa679175da8f06bdcb8e2e4195465e44 (patch)
tree73109126cfcf1a807c5dc1e778f40b955fc959c5 /src/transport/gnunet-service-transport.c
parentc42deb089faffd654e27bf661ce85d5c1bb38b7a (diff)
downloadgnunet-69c3a52cfa679175da8f06bdcb8e2e4195465e44.tar.gz
gnunet-69c3a52cfa679175da8f06bdcb8e2e4195465e44.zip
avoid passing both PeerIdentity and Address (which contains PeerIdentity) if address is always present as then this is redundant
Diffstat (limited to 'src/transport/gnunet-service-transport.c')
-rw-r--r--src/transport/gnunet-service-transport.c63
1 files changed, 31 insertions, 32 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index 3ff5ab172..ca0f6b813 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -161,7 +161,7 @@ struct BlacklistCheckContext *bc_tail;
161 * Transmit our HELLO message to the given (connected) neighbour. 161 * Transmit our HELLO message to the given (connected) neighbour.
162 * 162 *
163 * @param cls the 'HELLO' message 163 * @param cls the 'HELLO' message
164 * @param target a connected neighbour 164 * @param peer identity of the peer
165 * @param address the address 165 * @param address the address
166 * @param state current state this peer is in 166 * @param state current state this peer is in
167 * @param state_timeout timeout for the current state of the peer 167 * @param state_timeout timeout for the current state of the peer
@@ -169,22 +169,27 @@ struct BlacklistCheckContext *bc_tail;
169 * @param bandwidth_out outbound quota in NBO 169 * @param bandwidth_out outbound quota in NBO
170 */ 170 */
171static void 171static void
172transmit_our_hello (void *cls, const struct GNUNET_PeerIdentity *target, 172transmit_our_hello (void *cls,
173 const struct GNUNET_HELLO_Address *address, 173 const struct GNUNET_PeerIdentity *peer,
174 enum GNUNET_TRANSPORT_PeerState state, 174 const struct GNUNET_HELLO_Address *address,
175 struct GNUNET_TIME_Absolute state_timeout, 175 enum GNUNET_TRANSPORT_PeerState state,
176 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, 176 struct GNUNET_TIME_Absolute state_timeout,
177 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out) 177 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in,
178 struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out)
178{ 179{
179 const struct GNUNET_MessageHeader *hello = cls; 180 const struct GNUNET_MessageHeader *hello = cls;
180 181
181 if (GNUNET_NO == GST_neighbours_test_connected (target)) 182 if (GNUNET_NO == GST_neighbours_test_connected (peer))
182 return; 183 return;
183 184
184 GST_neighbours_send (target, hello, ntohs (hello->size), hello_expiration, 185 GST_neighbours_send (peer,
186 hello,
187 ntohs (hello->size),
188 hello_expiration,
185 NULL, NULL); 189 NULL, NULL);
186} 190}
187 191
192
188/** 193/**
189 * My HELLO has changed. Tell everyone who should know. 194 * My HELLO has changed. Tell everyone who should know.
190 * 195 *
@@ -202,7 +207,6 @@ process_hello_update (void *cls, const struct GNUNET_MessageHeader *hello)
202/** 207/**
203 * We received some payload. Prepare to pass it on to our clients. 208 * We received some payload. Prepare to pass it on to our clients.
204 * 209 *
205 * @param peer (claimed) identity of the other peer
206 * @param address address and (claimed) identity of the other peer 210 * @param address address and (claimed) identity of the other peer
207 * @param session identifier used for this session (NULL for plugins 211 * @param session identifier used for this session (NULL for plugins
208 * that do not offer bi-directional communication to the sender 212 * that do not offer bi-directional communication to the sender
@@ -211,8 +215,7 @@ process_hello_update (void *cls, const struct GNUNET_MessageHeader *hello)
211 * @return how long the plugin should wait until receiving more data 215 * @return how long the plugin should wait until receiving more data
212 */ 216 */
213static struct GNUNET_TIME_Relative 217static struct GNUNET_TIME_Relative
214process_payload (const struct GNUNET_PeerIdentity *peer, 218process_payload (const struct GNUNET_HELLO_Address *address,
215 const struct GNUNET_HELLO_Address *address,
216 struct Session *session, 219 struct Session *session,
217 const struct GNUNET_MessageHeader *message) 220 const struct GNUNET_MessageHeader *message)
218{ 221{
@@ -224,14 +227,16 @@ process_payload (const struct GNUNET_PeerIdentity *peer,
224 char buf[size] GNUNET_ALIGN; 227 char buf[size] GNUNET_ALIGN;
225 228
226 do_forward = GNUNET_SYSERR; 229 do_forward = GNUNET_SYSERR;
227 ret = GST_neighbours_calculate_receive_delay (peer, msg_size, &do_forward); 230 ret = GST_neighbours_calculate_receive_delay (&address->peer,
228 if (! GST_neighbours_test_connected (peer)) 231 msg_size,
232 &do_forward);
233 if (! GST_neighbours_test_connected (&address->peer))
229 { 234 {
230 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 235 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
231 "Discarded %u bytes type %u payload from peer `%s'\n", 236 "Discarded %u bytes type %u payload from peer `%s'\n",
232 msg_size, 237 msg_size,
233 ntohs (message->type), 238 ntohs (message->type),
234 GNUNET_i2s (peer)); 239 GNUNET_i2s (&address->peer));
235 GNUNET_STATISTICS_update (GST_stats, gettext_noop 240 GNUNET_STATISTICS_update (GST_stats, gettext_noop
236 ("# bytes payload discarded due to not connected peer"), 241 ("# bytes payload discarded due to not connected peer"),
237 msg_size, 242 msg_size,
@@ -244,7 +249,7 @@ process_payload (const struct GNUNET_PeerIdentity *peer,
244 im = (struct InboundMessage *) buf; 249 im = (struct InboundMessage *) buf;
245 im->header.size = htons (size); 250 im->header.size = htons (size);
246 im->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_RECV); 251 im->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_RECV);
247 im->peer = *peer; 252 im->peer = address->peer;
248 memcpy (&im[1], message, ntohs (message->size)); 253 memcpy (&im[1], message, ntohs (message->size));
249 GST_clients_broadcast (&im->header, GNUNET_YES); 254 GST_clients_broadcast (&im->header, GNUNET_YES);
250 return ret; 255 return ret;
@@ -427,8 +432,7 @@ GST_receive_callback (void *cls,
427 gettext_noop ("# bytes total received"), 432 gettext_noop ("# bytes total received"),
428 ntohs (message->size), 433 ntohs (message->size),
429 GNUNET_NO); 434 GNUNET_NO);
430 GST_neighbours_notify_data_recv (&address->peer, 435 GST_neighbours_notify_data_recv (address,
431 address,
432 session, 436 session,
433 message); 437 message);
434 switch (type) 438 switch (type)
@@ -489,7 +493,6 @@ GST_receive_callback (void *cls,
489 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_SYN_ACK: 493 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_SYN_ACK:
490 if (GNUNET_OK != 494 if (GNUNET_OK !=
491 GST_neighbours_handle_session_syn_ack (message, 495 GST_neighbours_handle_session_syn_ack (message,
492 &address->peer,
493 address, 496 address,
494 session)) 497 session))
495 { 498 {
@@ -500,7 +503,6 @@ GST_receive_callback (void *cls,
500 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_ACK: 503 case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_ACK:
501 if (GNUNET_OK != 504 if (GNUNET_OK !=
502 GST_neighbours_handle_session_ack (message, 505 GST_neighbours_handle_session_ack (message,
503 &address->peer,
504 address, 506 address,
505 session)) 507 session))
506 { 508 {
@@ -524,12 +526,10 @@ GST_receive_callback (void *cls,
524 gettext_noop ("# bytes payload received"), 526 gettext_noop ("# bytes payload received"),
525 ntohs (message->size), 527 ntohs (message->size),
526 GNUNET_NO); 528 GNUNET_NO);
527 GST_neighbours_notify_payload_recv (&address->peer, 529 GST_neighbours_notify_payload_recv (address,
528 address,
529 session, 530 session,
530 message); 531 message);
531 ret = process_payload (&address->peer, 532 ret = process_payload (address,
532 address,
533 session, 533 session,
534 message); 534 message);
535 break; 535 break;
@@ -838,8 +838,7 @@ ats_request_address_change (void *cls,
838 return; 838 return;
839 } 839 }
840 840
841 GST_neighbours_switch_to_address (&address->peer, 841 GST_neighbours_switch_to_address (address,
842 address,
843 session, 842 session,
844 bandwidth_in, bandwidth_out); 843 bandwidth_in, bandwidth_out);
845} 844}
@@ -911,12 +910,12 @@ neighbours_disconnect_notification (void *cls,
911 * active address. 910 * active address.
912 * 911 *
913 * @param cls closure 912 * @param cls closure
914 * @param peer peer this update is about (never NULL) 913 * @param peer identity of the peer
915 * @param address address, NULL on disconnect 914 * @param address address possibly NULL if peer is not connected
916 * @param state current state this peer is in 915 * @param state current state this peer is in
917 * @param state_timeout timeout for the current state of the peer 916 * @param state_timeout timeout for the current state of the peer
918 * @param bandwidth_in bandwidth assigned inbound 917 * @param bandwidth_in bandwidth assigned inbound, 0 on disconnect
919 * @param bandwidth_out bandwidth assigned outbound 918 * @param bandwidth_out bandwidth assigned outbound, 0 on disconnect
920 */ 919 */
921static void 920static void
922neighbours_changed_notification (void *cls, 921neighbours_changed_notification (void *cls,
@@ -930,10 +929,10 @@ neighbours_changed_notification (void *cls,
930 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 929 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
931 "Notifying about change for peer `%s' with address `%s' in state `%s' timing out at %s\n", 930 "Notifying about change for peer `%s' with address `%s' in state `%s' timing out at %s\n",
932 GNUNET_i2s (peer), 931 GNUNET_i2s (peer),
933 (NULL != address) ? GST_plugins_a2s (address) : "<none>", 932 GST_plugins_a2s (address),
934 GNUNET_TRANSPORT_ps2s (state), 933 GNUNET_TRANSPORT_ps2s (state),
935 GNUNET_STRINGS_absolute_time_to_string (state_timeout)); 934 GNUNET_STRINGS_absolute_time_to_string (state_timeout));
936 935 /* FIXME: include bandwidth in notification! */
937 GST_clients_broadcast_peer_notification (peer, 936 GST_clients_broadcast_peer_notification (peer,
938 address, 937 address,
939 state, 938 state,