diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-02-13 11:30:08 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-02-13 11:30:08 +0000 |
commit | aebb866a90e9e59bb01cda646406a2ad26151895 (patch) | |
tree | 3f53c86904500b71e52d6d69399759f87d05d4eb | |
parent | e710565b349e7e45f3e650a07ddb7383de9001aa (diff) | |
download | gnunet-aebb866a90e9e59bb01cda646406a2ad26151895.tar.gz gnunet-aebb866a90e9e59bb01cda646406a2ad26151895.zip |
fixing types and comment styles and struct alignments
-rw-r--r-- | src/transport/gnunet-service-transport.c | 127 | ||||
-rw-r--r-- | src/transport/transport.h | 2 |
2 files changed, 59 insertions, 70 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 5c6c37378..937d55448 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c | |||
@@ -79,7 +79,10 @@ | |||
79 | */ | 79 | */ |
80 | #define TRANSPORT_DEFAULT_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15) | 80 | #define TRANSPORT_DEFAULT_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15) |
81 | 81 | ||
82 | #define TRANSPORT_DEFAULT_PRIORITY 4 /* Tired of remembering arbitrary priority names */ | 82 | /** |
83 | * FIXME: document! | ||
84 | */ | ||
85 | #define TRANSPORT_DEFAULT_PRIORITY 4 | ||
83 | 86 | ||
84 | /** | 87 | /** |
85 | * How often do we re-add (cheaper) plugins to our list of plugins | 88 | * How often do we re-add (cheaper) plugins to our list of plugins |
@@ -143,14 +146,6 @@ struct PeerAddressList | |||
143 | char *addr; | 146 | char *addr; |
144 | 147 | ||
145 | /** | 148 | /** |
146 | * Is this plugin ready to transmit to the specific target? | ||
147 | * GNUNET_NO if not. Initially, all plugins are marked ready. If a | ||
148 | * transmission is in progress, "transmit_ready" is set to | ||
149 | * GNUNET_NO. | ||
150 | */ | ||
151 | int transmit_ready; | ||
152 | |||
153 | /** | ||
154 | * What was the last latency observed for this plugin | 149 | * What was the last latency observed for this plugin |
155 | * and peer? Invalid if connected is GNUNET_NO. | 150 | * and peer? Invalid if connected is GNUNET_NO. |
156 | */ | 151 | */ |
@@ -180,6 +175,14 @@ struct PeerAddressList | |||
180 | int connected; | 175 | int connected; |
181 | 176 | ||
182 | /** | 177 | /** |
178 | * Is this plugin ready to transmit to the specific target? | ||
179 | * GNUNET_NO if not. Initially, all plugins are marked ready. If a | ||
180 | * transmission is in progress, "transmit_ready" is set to | ||
181 | * GNUNET_NO. | ||
182 | */ | ||
183 | int transmit_ready; | ||
184 | |||
185 | /** | ||
183 | * How often have we tried to connect using this plugin? | 186 | * How often have we tried to connect using this plugin? |
184 | */ | 187 | */ |
185 | unsigned int connect_attempts; | 188 | unsigned int connect_attempts; |
@@ -269,6 +272,7 @@ struct TransportPlugin | |||
269 | * to the list and wait for the commit call. | 272 | * to the list and wait for the commit call. |
270 | */ | 273 | */ |
271 | int rebuild; | 274 | int rebuild; |
275 | |||
272 | }; | 276 | }; |
273 | 277 | ||
274 | struct NeighborList; | 278 | struct NeighborList; |
@@ -291,7 +295,7 @@ struct MessageQueue | |||
291 | */ | 295 | */ |
292 | char *message_buf; | 296 | char *message_buf; |
293 | 297 | ||
294 | /* | 298 | /** |
295 | * Size of the message buf | 299 | * Size of the message buf |
296 | */ | 300 | */ |
297 | size_t message_buf_size; | 301 | size_t message_buf_size; |
@@ -304,6 +308,11 @@ struct MessageQueue | |||
304 | struct TransportClient *client; | 308 | struct TransportClient *client; |
305 | 309 | ||
306 | /** | 310 | /** |
311 | * Using which specific address should we send this message? | ||
312 | */ | ||
313 | struct PeerAddressList *specific_peer; | ||
314 | |||
315 | /** | ||
307 | * Neighbor this entry belongs to. | 316 | * Neighbor this entry belongs to. |
308 | */ | 317 | */ |
309 | /*struct NeighborList *neighbor;*/ | 318 | /*struct NeighborList *neighbor;*/ |
@@ -333,11 +342,6 @@ struct MessageQueue | |||
333 | */ | 342 | */ |
334 | unsigned int priority; | 343 | unsigned int priority; |
335 | 344 | ||
336 | /* | ||
337 | * Using which specific address should we send this message? | ||
338 | */ | ||
339 | struct PeerAddressList *specific_peer; | ||
340 | |||
341 | }; | 345 | }; |
342 | 346 | ||
343 | 347 | ||
@@ -363,7 +367,7 @@ struct ReadyList | |||
363 | */ | 367 | */ |
364 | struct NeighborList *neighbor; | 368 | struct NeighborList *neighbor; |
365 | 369 | ||
366 | /* | 370 | /** |
367 | * Transport addresses, latency, and readiness for | 371 | * Transport addresses, latency, and readiness for |
368 | * this particular plugin. | 372 | * this particular plugin. |
369 | */ | 373 | */ |
@@ -377,7 +381,7 @@ struct ReadyList | |||
377 | */ | 381 | */ |
378 | int plugin_transmit_ready; | 382 | int plugin_transmit_ready; |
379 | 383 | ||
380 | /* | 384 | /** |
381 | * Are any of our PeerAddressList addresses still connected? | 385 | * Are any of our PeerAddressList addresses still connected? |
382 | */ | 386 | */ |
383 | int connected; /* FIXME: dynamically check PeerAddressList addresses when asked to! */ | 387 | int connected; /* FIXME: dynamically check PeerAddressList addresses when asked to! */ |
@@ -437,6 +441,16 @@ struct NeighborList | |||
437 | struct GNUNET_TIME_Absolute retry_plugins_time; | 441 | struct GNUNET_TIME_Absolute retry_plugins_time; |
438 | 442 | ||
439 | /** | 443 | /** |
444 | * The latency we have seen for this particular address for | ||
445 | * this particular peer. This latency may have been calculated | ||
446 | * over multiple transports. This value reflects how long it took | ||
447 | * us to receive a response when SENDING via this particular | ||
448 | * transport/neighbor/address combination! | ||
449 | * FIXME: why is this NBO? | ||
450 | */ | ||
451 | struct GNUNET_TIME_RelativeNBO latency; | ||
452 | |||
453 | /** | ||
440 | * How many bytes have we received since the "last_quota_update" | 454 | * How many bytes have we received since the "last_quota_update" |
441 | * timestamp? | 455 | * timestamp? |
442 | */ | 456 | */ |
@@ -462,14 +476,6 @@ struct NeighborList | |||
462 | */ | 476 | */ |
463 | int received_pong; | 477 | int received_pong; |
464 | 478 | ||
465 | /* The latency we have seen for this particular address for | ||
466 | * this particular peer. This latency may have been calculated | ||
467 | * over multiple transports. This value reflects how long it took | ||
468 | * us to receive a response when SENDING via this particular | ||
469 | * transport/neighbor/address combination! | ||
470 | */ | ||
471 | struct GNUNET_TIME_RelativeNBO latency; | ||
472 | |||
473 | }; | 479 | }; |
474 | 480 | ||
475 | /** | 481 | /** |
@@ -544,7 +550,7 @@ struct TransportPongMessage | |||
544 | */ | 550 | */ |
545 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded signer; | 551 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded signer; |
546 | 552 | ||
547 | /* | 553 | /** |
548 | * Size of address appended to this message | 554 | * Size of address appended to this message |
549 | */ | 555 | */ |
550 | size_t addrlen; | 556 | size_t addrlen; |
@@ -620,7 +626,7 @@ struct ValidationAddress | |||
620 | */ | 626 | */ |
621 | struct ValidationAddress *next; | 627 | struct ValidationAddress *next; |
622 | 628 | ||
623 | /* | 629 | /** |
624 | * What peer_address does this validation belong to? | 630 | * What peer_address does this validation belong to? |
625 | */ | 631 | */ |
626 | struct PeerAddressList *peer_address; | 632 | struct PeerAddressList *peer_address; |
@@ -635,7 +641,7 @@ struct ValidationAddress | |||
635 | */ | 641 | */ |
636 | struct GNUNET_TIME_Absolute expiration; | 642 | struct GNUNET_TIME_Absolute expiration; |
637 | 643 | ||
638 | /* | 644 | /** |
639 | * At what time did we send this validation? | 645 | * At what time did we send this validation? |
640 | */ | 646 | */ |
641 | struct GNUNET_TIME_Absolute send_time; | 647 | struct GNUNET_TIME_Absolute send_time; |
@@ -1218,7 +1224,7 @@ try_transmission_to_peer (struct NeighborList *neighbor) | |||
1218 | mq->specific_peer->transmit_ready = GNUNET_NO; | 1224 | mq->specific_peer->transmit_ready = GNUNET_NO; |
1219 | #if DEBUG_TRANSPORT | 1225 | #if DEBUG_TRANSPORT |
1220 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1226 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1221 | "Giving message of size `%u' for `%4s' to plugin `%s'\n", | 1227 | "Giving message of size %u for `%4s' to plugin `%s'\n", |
1222 | mq->message_buf_size, | 1228 | mq->message_buf_size, |
1223 | GNUNET_i2s (&neighbor->id), rl->plugin->short_name); | 1229 | GNUNET_i2s (&neighbor->id), rl->plugin->short_name); |
1224 | #endif | 1230 | #endif |
@@ -1951,11 +1957,11 @@ run_validation (void *cls, | |||
1951 | struct GNUNET_PeerIdentity id; | 1957 | struct GNUNET_PeerIdentity id; |
1952 | struct NeighborList *neighbor; | 1958 | struct NeighborList *neighbor; |
1953 | struct PeerAddressList *peer_address; | 1959 | struct PeerAddressList *peer_address; |
1954 | int sent; | 1960 | ssize_t sent; |
1955 | struct TransportPingMessage *ping; | 1961 | struct TransportPingMessage *ping; |
1956 | char * message_buf; | 1962 | char * message_buf; |
1957 | int hello_size; | 1963 | uint16_t hello_size; |
1958 | int tsize; | 1964 | size_t tsize; |
1959 | 1965 | ||
1960 | tp = find_transport (tname); | 1966 | tp = find_transport (tname); |
1961 | if (tp == NULL) | 1967 | if (tp == NULL) |
@@ -2012,20 +2018,32 @@ run_validation (void *cls, | |||
2012 | memcpy(&ping->target, &id, sizeof(struct GNUNET_PeerIdentity)); | 2018 | memcpy(&ping->target, &id, sizeof(struct GNUNET_PeerIdentity)); |
2013 | 2019 | ||
2014 | #if DEBUG_TRANSPORT | 2020 | #if DEBUG_TRANSPORT |
2015 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "hello size is %d, ping size is %d, total size is %d\n", hello_size, sizeof(struct TransportPingMessage), tsize); | 2021 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
2022 | "`%s' message size is %u, ping size is %u, total size is %u\n", | ||
2023 | "HELLO", | ||
2024 | hello_size, | ||
2025 | sizeof(struct TransportPingMessage), | ||
2026 | tsize); | ||
2016 | #endif | 2027 | #endif |
2017 | memcpy(message_buf, our_hello, hello_size); | 2028 | memcpy(message_buf, our_hello, hello_size); |
2018 | memcpy(&message_buf[hello_size], ping, sizeof(struct TransportPingMessage)); | 2029 | memcpy(&message_buf[hello_size], |
2030 | ping, | ||
2031 | sizeof(struct TransportPingMessage)); | ||
2019 | 2032 | ||
2020 | #if DEBUG_TRANSPORT | 2033 | #if DEBUG_TRANSPORT |
2021 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending ping message of size %d to address `%s' via `%s' for `%4s'\n", | 2034 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2022 | tsize, GNUNET_a2s (addr, addrlen), tname, GNUNET_i2s (&id)); | 2035 | "Sending `%s' message of size %u to address `%s' via `%s' for `%4s'\n", |
2036 | "PING", | ||
2037 | tsize, GNUNET_a2s (addr, addrlen), | ||
2038 | tname, GNUNET_i2s (&id)); | ||
2023 | #endif | 2039 | #endif |
2024 | sent = transmit_to_peer(NULL, peer_address, GNUNET_SCHEDULER_PRIORITY_DEFAULT, | 2040 | sent = transmit_to_peer(NULL, peer_address, |
2025 | message_buf, tsize, GNUNET_NO, neighbor); | 2041 | GNUNET_SCHEDULER_PRIORITY_DEFAULT, |
2042 | message_buf, tsize, GNUNET_NO, neighbor); | ||
2026 | 2043 | ||
2027 | #if DEBUG_TRANSPORT | 2044 | #if DEBUG_TRANSPORT |
2028 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Transport returned %d from send!\n", sent); | 2045 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2046 | "Transport returned %d from send!\n", sent); | ||
2029 | #endif | 2047 | #endif |
2030 | 2048 | ||
2031 | GNUNET_free(ping); | 2049 | GNUNET_free(ping); |
@@ -2033,35 +2051,6 @@ run_validation (void *cls, | |||
2033 | return GNUNET_OK; | 2051 | return GNUNET_OK; |
2034 | } | 2052 | } |
2035 | 2053 | ||
2036 | #if WHY | ||
2037 | /* | ||
2038 | * @param cls handle to the plugin (for sending) | ||
2039 | * @param target the peer identity of the peer we are sending to | ||
2040 | * @param challenge the challenge number | ||
2041 | * @param timeout how long to await validation? | ||
2042 | * @param addr the address to validate | ||
2043 | * @param addrlen the length of the address | ||
2044 | * | ||
2045 | * Perform address validation, which means sending a PING PONG to | ||
2046 | * the address via the transport plugin. If not validated, then | ||
2047 | * do not count this as a good peer/address... | ||
2048 | * | ||
2049 | * Currently this function is not used, ping/pongs get sent from the | ||
2050 | * run_validation function. Haven't decided yet how to do this. | ||
2051 | */ | ||
2052 | static void | ||
2053 | validate_address (void *cls, struct ValidationAddress *va, | ||
2054 | const struct GNUNET_PeerIdentity *target, | ||
2055 | struct GNUNET_TIME_Relative timeout, | ||
2056 | const void *addr, size_t addrlen) | ||
2057 | { | ||
2058 | /* struct Plugin *plugin = cls; | ||
2059 | int challenge = va->challenge; */ | ||
2060 | |||
2061 | |||
2062 | return; | ||
2063 | } | ||
2064 | #endif | ||
2065 | 2054 | ||
2066 | /** | 2055 | /** |
2067 | * Check if addresses in validated hello "h" overlap with | 2056 | * Check if addresses in validated hello "h" overlap with |
@@ -2479,7 +2468,7 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
2479 | } | 2468 | } |
2480 | #if DEBUG_TRANSPORT | 2469 | #if DEBUG_TRANSPORT |
2481 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, | 2470 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK, |
2482 | "Processing message of type `%u' received by plugin...\n", | 2471 | "Processing message of type %u received by plugin...\n", |
2483 | ntohs (message->type)); | 2472 | ntohs (message->type)); |
2484 | #endif | 2473 | #endif |
2485 | if (service_context != NULL) | 2474 | if (service_context != NULL) |
diff --git a/src/transport/transport.h b/src/transport/transport.h index 89f004ab8..603f1bbc1 100644 --- a/src/transport/transport.h +++ b/src/transport/transport.h | |||
@@ -30,7 +30,7 @@ | |||
30 | #include "gnunet_time_lib.h" | 30 | #include "gnunet_time_lib.h" |
31 | #include "gnunet_transport_service.h" | 31 | #include "gnunet_transport_service.h" |
32 | 32 | ||
33 | #define DEBUG_TRANSPORT GNUNET_NO | 33 | #define DEBUG_TRANSPORT GNUNET_YES |
34 | 34 | ||
35 | /** | 35 | /** |
36 | * For how long do we allow unused bandwidth | 36 | * For how long do we allow unused bandwidth |