aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-05-16 15:43:30 +0000
committerChristian Grothoff <christian@grothoff.org>2012-05-16 15:43:30 +0000
commitd4c278025719fc145516e98a6619b6136b768c23 (patch)
treeaf4c20adfdbe924c1e6bc954d62848c83158abac /src
parent1b0756f382f3e7d71bd31a808143f9b2ec48376c (diff)
downloadgnunet-d4c278025719fc145516e98a6619b6136b768c23.tar.gz
gnunet-d4c278025719fc145516e98a6619b6136b768c23.zip
-do switch statement cases in order of enum
Diffstat (limited to 'src')
-rw-r--r--src/core/test_core_api_reliability.c32
-rw-r--r--src/transport/gnunet-service-transport_neighbours.c2
-rw-r--r--src/transport/plugin_transport_udp.c7
3 files changed, 6 insertions, 35 deletions
diff --git a/src/core/test_core_api_reliability.c b/src/core/test_core_api_reliability.c
index 0c6a39ffb..e18d8c4fd 100644
--- a/src/core/test_core_api_reliability.c
+++ b/src/core/test_core_api_reliability.c
@@ -33,8 +33,6 @@
33#include "gnunet_transport_service.h" 33#include "gnunet_transport_service.h"
34#include <gauger.h> 34#include <gauger.h>
35 35
36#define VERBOSE GNUNET_NO
37
38#define START_ARM GNUNET_YES 36#define START_ARM GNUNET_YES
39 37
40/** 38/**
@@ -89,11 +87,7 @@ static int ok;
89static int32_t tr_n; 87static int32_t tr_n;
90 88
91 89
92#if VERBOSE
93#define OKPP do { ok++; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Now at stage %u at %s:%u\n", ok, __FILE__, __LINE__); } while (0) 90#define OKPP do { ok++; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Now at stage %u at %s:%u\n", ok, __FILE__, __LINE__); } while (0)
94#else
95#define OKPP do { ok++; } while (0)
96#endif
97 91
98struct TestMessage 92struct TestMessage
99{ 93{
@@ -113,9 +107,11 @@ get_size (unsigned int iter)
113 return sizeof (struct TestMessage) + (ret % 60000); 107 return sizeof (struct TestMessage) + (ret % 60000);
114} 108}
115 109
110
116static void 111static void
117process_hello (void *cls, const struct GNUNET_MessageHeader *message); 112process_hello (void *cls, const struct GNUNET_MessageHeader *message);
118 113
114
119static void 115static void
120terminate_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 116terminate_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
121{ 117{
@@ -183,6 +179,7 @@ try_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
183 GNUNET_TRANSPORT_try_connect (p1.th, &p2.id); 179 GNUNET_TRANSPORT_try_connect (p1.th, &p2.id);
184} 180}
185 181
182
186static size_t 183static size_t
187transmit_ready (void *cls, size_t size, void *buf) 184transmit_ready (void *cls, size_t size, void *buf)
188{ 185{
@@ -210,10 +207,8 @@ transmit_ready (void *cls, size_t size, void *buf)
210 cbuf = buf; 207 cbuf = buf;
211 do 208 do
212 { 209 {
213#if VERBOSE
214 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 210 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
215 "Sending message %u of size %u at offset %u\n", tr_n, s, ret); 211 "Sending message %u of size %u at offset %u\n", tr_n, s, ret);
216#endif
217 hdr.header.size = htons (s); 212 hdr.header.size = htons (s);
218 hdr.header.type = htons (MTYPE); 213 hdr.header.type = htons (MTYPE);
219 hdr.num = htonl (tr_n); 214 hdr.num = htonl (tr_n);
@@ -237,7 +232,6 @@ transmit_ready (void *cls, size_t size, void *buf)
237} 232}
238 233
239 234
240
241static void 235static void
242connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer, 236connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer,
243 const struct GNUNET_ATS_Information *atsi, 237 const struct GNUNET_ATS_Information *atsi,
@@ -289,10 +283,8 @@ inbound_notify (void *cls, const struct GNUNET_PeerIdentity *other,
289 const struct GNUNET_ATS_Information *atsi, 283 const struct GNUNET_ATS_Information *atsi,
290 unsigned int atsi_count) 284 unsigned int atsi_count)
291{ 285{
292#if VERBOSE
293 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 286 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
294 "Core provides inbound data from `%4s'.\n", GNUNET_i2s (other)); 287 "Core provides inbound data from `%4s'.\n", GNUNET_i2s (other));
295#endif
296 return GNUNET_OK; 288 return GNUNET_OK;
297} 289}
298 290
@@ -303,11 +295,9 @@ outbound_notify (void *cls, const struct GNUNET_PeerIdentity *other,
303 const struct GNUNET_ATS_Information *atsi, 295 const struct GNUNET_ATS_Information *atsi,
304 unsigned int atsi_count) 296 unsigned int atsi_count)
305{ 297{
306#if VERBOSE
307 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 298 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
308 "Core notifies about outbound data for `%4s'.\n", 299 "Core notifies about outbound data for `%4s'.\n",
309 GNUNET_i2s (other)); 300 GNUNET_i2s (other));
310#endif
311 return GNUNET_OK; 301 return GNUNET_OK;
312} 302}
313 303
@@ -315,6 +305,7 @@ outbound_notify (void *cls, const struct GNUNET_PeerIdentity *other,
315static size_t 305static size_t
316transmit_ready (void *cls, size_t size, void *buf); 306transmit_ready (void *cls, size_t size, void *buf);
317 307
308
318static int 309static int
319process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer, 310process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer,
320 const struct GNUNET_MessageHeader *message, 311 const struct GNUNET_MessageHeader *message,
@@ -347,10 +338,8 @@ process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer,
347 err_task = GNUNET_SCHEDULER_add_now (&terminate_task_error, NULL); 338 err_task = GNUNET_SCHEDULER_add_now (&terminate_task_error, NULL);
348 return GNUNET_SYSERR; 339 return GNUNET_SYSERR;
349 } 340 }
350#if VERBOSE
351 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got message %u of size %u\n", 341 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got message %u of size %u\n",
352 ntohl (hdr->num), ntohs (message->size)); 342 ntohl (hdr->num), ntohs (message->size));
353#endif
354 n++; 343 n++;
355 if (0 == (n % (TOTAL_MSGS / 100))) 344 if (0 == (n % (TOTAL_MSGS / 100)))
356 FPRINTF (stderr, "%s", "."); 345 FPRINTF (stderr, "%s", ".");
@@ -378,7 +367,6 @@ static struct GNUNET_CORE_MessageHandler handlers[] = {
378}; 367};
379 368
380 369
381
382static void 370static void
383init_notify (void *cls, struct GNUNET_CORE_Handle *server, 371init_notify (void *cls, struct GNUNET_CORE_Handle *server,
384 const struct GNUNET_PeerIdentity *my_identity) 372 const struct GNUNET_PeerIdentity *my_identity)
@@ -435,7 +423,6 @@ process_hello (void *cls, const struct GNUNET_MessageHeader *message)
435} 423}
436 424
437 425
438
439static void 426static void
440setup_peer (struct PeerContext *p, const char *cfgname) 427setup_peer (struct PeerContext *p, const char *cfgname)
441{ 428{
@@ -444,9 +431,6 @@ setup_peer (struct PeerContext *p, const char *cfgname)
444 p->arm_proc = 431 p->arm_proc =
445 GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm", 432 GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
446 "gnunet-service-arm", 433 "gnunet-service-arm",
447#if VERBOSE
448 "-L", "DEBUG",
449#endif
450 "-c", cfgname, NULL); 434 "-c", cfgname, NULL);
451#endif 435#endif
452 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); 436 GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
@@ -494,9 +478,6 @@ check ()
494 char *const argv[] = { "test-core-api-reliability", 478 char *const argv[] = { "test-core-api-reliability",
495 "-c", 479 "-c",
496 "test_core_api_data.conf", 480 "test_core_api_data.conf",
497#if VERBOSE
498 "-L", "DEBUG",
499#endif
500 NULL 481 NULL
501 }; 482 };
502 struct GNUNET_GETOPT_CommandLineOption options[] = { 483 struct GNUNET_GETOPT_CommandLineOption options[] = {
@@ -511,17 +492,14 @@ check ()
511 return ok; 492 return ok;
512} 493}
513 494
495
514int 496int
515main (int argc, char *argv[]) 497main (int argc, char *argv[])
516{ 498{
517 int ret; 499 int ret;
518 500
519 GNUNET_log_setup ("test-core-api", 501 GNUNET_log_setup ("test-core-api",
520#if VERBOSE
521 "DEBUG",
522#else
523 "WARNING", 502 "WARNING",
524#endif
525 NULL); 503 NULL);
526 ret = check (); 504 ret = check ();
527 GNUNET_DISK_directory_remove ("/tmp/test-gnunet-core-peer-1"); 505 GNUNET_DISK_directory_remove ("/tmp/test-gnunet-core-peer-1");
diff --git a/src/transport/gnunet-service-transport_neighbours.c b/src/transport/gnunet-service-transport_neighbours.c
index 59f03d674..8af38f010 100644
--- a/src/transport/gnunet-service-transport_neighbours.c
+++ b/src/transport/gnunet-service-transport_neighbours.c
@@ -2173,8 +2173,8 @@ GST_neighbours_switch_to_address (const struct GNUNET_PeerIdentity *peer,
2173 n->connect_ack_timestamp, 2173 n->connect_ack_timestamp,
2174 address, session, ats, ats_count); 2174 address, session, ats, ats_count);
2175 break; 2175 break;
2176 case S_CONNECT_RECV_ACK:
2177 case S_CONNECT_RECV_BLACKLIST: 2176 case S_CONNECT_RECV_BLACKLIST:
2177 case S_CONNECT_RECV_ACK:
2178 /* ATS asks us to switch while we were trying to connect; switch to new 2178 /* ATS asks us to switch while we were trying to connect; switch to new
2179 address and check blacklist again */ 2179 address and check blacklist again */
2180 set_address (&n->primary_address, 2180 set_address (&n->primary_address,
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c
index 76fd1a6cd..86af69fc8 100644
--- a/src/transport/plugin_transport_udp.c
+++ b/src/transport/plugin_transport_udp.c
@@ -2154,7 +2154,6 @@ libgnunet_plugin_transport_udp_init (void *cls)
2154 struct GNUNET_TRANSPORT_PluginEnvironment *env = cls; 2154 struct GNUNET_TRANSPORT_PluginEnvironment *env = cls;
2155 struct GNUNET_TRANSPORT_PluginFunctions *api; 2155 struct GNUNET_TRANSPORT_PluginFunctions *api;
2156 struct Plugin *plugin; 2156 struct Plugin *plugin;
2157
2158 unsigned long long port; 2157 unsigned long long port;
2159 unsigned long long aport; 2158 unsigned long long aport;
2160 unsigned long long broadcast; 2159 unsigned long long broadcast;
@@ -2163,10 +2162,8 @@ libgnunet_plugin_transport_udp_init (void *cls)
2163 char * bind4_address; 2162 char * bind4_address;
2164 char * bind6_address; 2163 char * bind6_address;
2165 struct GNUNET_TIME_Relative interval; 2164 struct GNUNET_TIME_Relative interval;
2166
2167 struct sockaddr_in serverAddrv4; 2165 struct sockaddr_in serverAddrv4;
2168 struct sockaddr_in6 serverAddrv6; 2166 struct sockaddr_in6 serverAddrv6;
2169
2170 int res; 2167 int res;
2171 2168
2172 if (NULL == env->receive) 2169 if (NULL == env->receive)
@@ -2210,7 +2207,6 @@ libgnunet_plugin_transport_udp_init (void *cls)
2210 else 2207 else
2211 enable_v6 = GNUNET_YES; 2208 enable_v6 = GNUNET_YES;
2212 2209
2213
2214 /* Addresses */ 2210 /* Addresses */
2215 memset (&serverAddrv6, 0, sizeof (serverAddrv6)); 2211 memset (&serverAddrv6, 0, sizeof (serverAddrv6));
2216 memset (&serverAddrv4, 0, sizeof (serverAddrv4)); 2212 memset (&serverAddrv4, 0, sizeof (serverAddrv4));
@@ -2247,7 +2243,6 @@ libgnunet_plugin_transport_udp_init (void *cls)
2247 } 2243 }
2248 } 2244 }
2249 2245
2250
2251 /* Enable neighbour discovery */ 2246 /* Enable neighbour discovery */
2252 broadcast = GNUNET_CONFIGURATION_get_value_yesno (env->cfg, "transport-udp", 2247 broadcast = GNUNET_CONFIGURATION_get_value_yesno (env->cfg, "transport-udp",
2253 "BROADCAST"); 2248 "BROADCAST");
@@ -2272,8 +2267,6 @@ libgnunet_plugin_transport_udp_init (void *cls)
2272 2267
2273 GNUNET_BANDWIDTH_tracker_init (&plugin->tracker, 2268 GNUNET_BANDWIDTH_tracker_init (&plugin->tracker,
2274 GNUNET_BANDWIDTH_value_init ((uint32_t)udp_max_bps), 30); 2269 GNUNET_BANDWIDTH_value_init ((uint32_t)udp_max_bps), 30);
2275
2276
2277 plugin->sessions = GNUNET_CONTAINER_multihashmap_create (10); 2270 plugin->sessions = GNUNET_CONTAINER_multihashmap_create (10);
2278 plugin->defrag_ctxs = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); 2271 plugin->defrag_ctxs = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
2279 plugin->mst = GNUNET_SERVER_mst_create (&process_inbound_tokenized_messages, plugin); 2272 plugin->mst = GNUNET_SERVER_mst_create (&process_inbound_tokenized_messages, plugin);