summaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorng0 <ng0@n0.is>2019-09-06 22:46:29 +0000
committerng0 <ng0@n0.is>2019-09-06 22:46:29 +0000
commit6e599264ad13e8fc105493d74d7c11d46f8739ed (patch)
tree169bef1ecbade5a659831fb169f3ae6943af127f /src/transport
parent4f13bc15113021ebf71d5d81e99bc29f8a07fc9c (diff)
first step to remove plibc
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/gnunet-communicator-tcp.c8
-rw-r--r--src/transport/gnunet-communicator-udp.c4
-rw-r--r--src/transport/gnunet-communicator-unix.c2
-rw-r--r--src/transport/gnunet-helper-transport-wlan-dummy.c36
-rw-r--r--src/transport/gnunet-transport-profiler.c42
-rw-r--r--src/transport/gnunet-transport.c50
-rw-r--r--src/transport/plugin_transport_smtp.c4
-rw-r--r--src/transport/plugin_transport_tcp.c1281
-rw-r--r--src/transport/plugin_transport_udp.c1187
-rw-r--r--src/transport/plugin_transport_unix.c453
-rw-r--r--src/transport/tcp_connection_legacy.c421
-rw-r--r--src/transport/tcp_service_legacy.c458
-rw-r--r--src/transport/test_plugin_hostkeybin914 -> 915 bytes
-rw-r--r--src/transport/test_quota_compliance.c6
-rw-r--r--src/transport/test_transport_address_switch.c18
-rw-r--r--src/transport/test_transport_api_reliability.c4
-rw-r--r--src/transport/test_transport_api_timeout.c4
-rw-r--r--src/transport/test_transport_blacklisting.c2
18 files changed, 1761 insertions, 2219 deletions
diff --git a/src/transport/gnunet-communicator-tcp.c b/src/transport/gnunet-communicator-tcp.c
index 576c20278..c883166c6 100644
--- a/src/transport/gnunet-communicator-tcp.c
+++ b/src/transport/gnunet-communicator-tcp.c
@@ -1103,7 +1103,7 @@ tcp_address_to_sockaddr (const char *bindto, socklen_t *sock_len)
char *colon;
char *cp;
- if (1 == SSCANF (bindto, "%u%1s", &port, dummy))
+ if (1 == sscanf (bindto, "%u%1s", &port, dummy))
{
/* interpreting value as just a PORT number */
if (port > UINT16_MAX)
@@ -1146,7 +1146,7 @@ tcp_address_to_sockaddr (const char *bindto, socklen_t *sock_len)
/* interpet value after colon as port */
*colon = '\0';
colon++;
- if (1 == SSCANF (colon, "%u%1s", &port, dummy))
+ if (1 == sscanf (colon, "%u%1s", &port, dummy))
{
/* interpreting value as just a PORT number */
if (port > UINT16_MAX)
@@ -1877,7 +1877,7 @@ mq_init (void *cls, const struct GNUNET_PeerIdentity *peer, const char *address)
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"socket(%d) failed: %s",
in->sa_family,
- STRERROR (errno));
+ strerror (errno));
GNUNET_free (in);
return GNUNET_SYSERR;
}
@@ -1886,7 +1886,7 @@ mq_init (void *cls, const struct GNUNET_PeerIdentity *peer, const char *address)
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"connect to `%s' failed: %s",
address,
- STRERROR (errno));
+ strerror (errno));
GNUNET_NETWORK_socket_close (sock);
GNUNET_free (in);
return GNUNET_SYSERR;
diff --git a/src/transport/gnunet-communicator-udp.c b/src/transport/gnunet-communicator-udp.c
index 68635b5bf..2c8893d75 100644
--- a/src/transport/gnunet-communicator-udp.c
+++ b/src/transport/gnunet-communicator-udp.c
@@ -1725,7 +1725,7 @@ udp_address_to_sockaddr (const char *bindto, socklen_t *sock_len)
char *colon;
char *cp;
- if (1 == SSCANF (bindto, "%u%1s", &port, dummy))
+ if (1 == sscanf (bindto, "%u%1s", &port, dummy))
{
/* interpreting value as just a PORT number */
if (port > UINT16_MAX)
@@ -1768,7 +1768,7 @@ udp_address_to_sockaddr (const char *bindto, socklen_t *sock_len)
/* interpet value after colon as port */
*colon = '\0';
colon++;
- if (1 == SSCANF (colon, "%u%1s", &port, dummy))
+ if (1 == sscanf (colon, "%u%1s", &port, dummy))
{
/* interpreting value as just a PORT number */
if (port > UINT16_MAX)
diff --git a/src/transport/gnunet-communicator-unix.c b/src/transport/gnunet-communicator-unix.c
index 1d5029f20..cb1fbc230 100644
--- a/src/transport/gnunet-communicator-unix.c
+++ b/src/transport/gnunet-communicator-unix.c
@@ -430,7 +430,7 @@ resend:
GNUNET_i2s (&queue->target),
(int) sent,
(unsigned int) msg_size,
- (sent < 0) ? STRERROR (errno) : "ok");
+ (sent < 0) ? strerror (errno) : "ok");
if (-1 != sent)
{
GNUNET_STATISTICS_update (stats,
diff --git a/src/transport/gnunet-helper-transport-wlan-dummy.c b/src/transport/gnunet-helper-transport-wlan-dummy.c
index dbd9014cb..c7ed1b903 100644
--- a/src/transport/gnunet-helper-transport-wlan-dummy.c
+++ b/src/transport/gnunet-helper-transport-wlan-dummy.c
@@ -140,13 +140,13 @@ stdin_send (void *cls,
if ( (GNUNET_MESSAGE_TYPE_WLAN_DATA_TO_HELPER != ntohs (hdr->type)) ||
(sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) > sendsize) )
{
- FPRINTF (stderr, "%s", "Received malformed message\n");
+ fprintf (stderr, "%s", "Received malformed message\n");
exit (1);
}
payload_size = sendsize - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage);
if ((payload_size + sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage) + write_pout->size) > MAXLINE * 2)
{
- FPRINTF (stderr, "%s", "Packet too big for buffer\n");
+ fprintf (stderr, "%s", "Packet too big for buffer\n");
exit (1);
}
memset (&newheader, 0, sizeof (newheader));
@@ -184,7 +184,7 @@ file_in_send (void *cls,
sendsize = ntohs (hdr->size);
if ((sendsize + write_std->size) > MAXLINE * 2)
{
- FPRINTF (stderr, "%s", "Packet too big for buffer\n");
+ fprintf (stderr, "%s", "Packet too big for buffer\n");
exit (1);
}
GNUNET_memcpy (write_std->buf + write_std->size, hdr, sendsize);
@@ -227,7 +227,7 @@ main (int argc, char *argv[])
if ( (2 != argc) ||
((0 != strcmp (argv[1], "1")) && (0 != strcmp (argv[1], "2"))) )
{
- FPRINTF (stderr,
+ fprintf (stderr,
"%s",
"This program must be started with the operating mode (1 or 2) as the only argument.\n");
return 1;
@@ -238,7 +238,7 @@ main (int argc, char *argv[])
if ( (GNUNET_OK != GNUNET_DISK_directory_create_for_file (FIFO_FILE1)) ||
(GNUNET_OK != GNUNET_DISK_directory_create_for_file (FIFO_FILE2)) )
{
- FPRINTF (stderr,
+ fprintf (stderr,
"Failed to create directory for file `%s'\n",
FIFO_FILE1);
return 1;
@@ -249,7 +249,7 @@ main (int argc, char *argv[])
{
erg = mkfifo (FIFO_FILE1, 0666);
if ( (0 != erg) && (EEXIST != errno) )
- FPRINTF (stderr, "Error in mkfifo(%s): %s\n", FIFO_FILE1,
+ fprintf (stderr, "Error in mkfifo(%s): %s\n", FIFO_FILE1,
strerror (errno));
}
}
@@ -259,7 +259,7 @@ main (int argc, char *argv[])
{
GNUNET_break (0 == (erg = mkfifo (FIFO_FILE2, 0666)));
if ( (0 != erg) && (EEXIST != errno) )
- FPRINTF (stderr,
+ fprintf (stderr,
"Error in mkfifo(%s): %s\n",
FIFO_FILE2,
strerror (errno));
@@ -272,7 +272,7 @@ main (int argc, char *argv[])
fpin = fopen (FIFO_FILE1, "r");
if (NULL == fpin)
{
- FPRINTF (stderr,
+ fprintf (stderr,
"fopen of read FIFO_FILE1 failed: %s\n",
STRERROR (errno));
goto end;
@@ -284,7 +284,7 @@ main (int argc, char *argv[])
}
if (NULL == fpout)
{
- FPRINTF (stderr,
+ fprintf (stderr,
"fopen of write FIFO_FILE2 failed: %s\n",
STRERROR (errno));
goto end;
@@ -300,7 +300,7 @@ main (int argc, char *argv[])
}
if (NULL == fpout)
{
- FPRINTF (stderr,
+ fprintf (stderr,
"fopen of write FIFO_FILE1 failed: %s\n",
STRERROR (errno));
goto end;
@@ -308,7 +308,7 @@ main (int argc, char *argv[])
fpin = fopen (FIFO_FILE2, "r");
if (NULL == fpin)
{
- FPRINTF (stderr,
+ fprintf (stderr,
"fopen of read FIFO_FILE2 failed: %s\n",
STRERROR (errno));
goto end;
@@ -319,7 +319,7 @@ main (int argc, char *argv[])
GNUNET_assert (fpin >= 0);
if (fdpin >= FD_SETSIZE)
{
- FPRINTF (stderr,
+ fprintf (stderr,
"File fdpin number too large (%d > %u)\n",
fdpin,
(unsigned int) FD_SETSIZE);
@@ -331,7 +331,7 @@ main (int argc, char *argv[])
if (fdpout >= FD_SETSIZE)
{
- FPRINTF (stderr,
+ fprintf (stderr,
"File fdpout number too large (%d > %u)\n",
fdpout,
(unsigned int) FD_SETSIZE);
@@ -395,7 +395,7 @@ main (int argc, char *argv[])
continue;
if (0 > retval)
{
- FPRINTF (stderr, "select failed: %s\n", STRERROR (errno));
+ fprintf (stderr, "select failed: %s\n", STRERROR (errno));
closeprog = 1;
break;
}
@@ -408,7 +408,7 @@ main (int argc, char *argv[])
if (0 > ret)
{
closeprog = 1;
- FPRINTF (stderr, "Write ERROR to STDOUT_FILENO: %s\n",
+ fprintf (stderr, "Write ERROR to STDOUT_FILENO: %s\n",
STRERROR (errno));
break;
}
@@ -433,7 +433,7 @@ main (int argc, char *argv[])
if (0 > ret)
{
closeprog = 1;
- FPRINTF (stderr, "Write ERROR to fdpout failed: %s\n", STRERROR (errno));
+ fprintf (stderr, "Write ERROR to fdpout failed: %s\n", STRERROR (errno));
}
else
{
@@ -454,7 +454,7 @@ main (int argc, char *argv[])
if (0 > readsize)
{
closeprog = 1;
- FPRINTF (stderr, "Error reading from STDIN_FILENO: %s\n",
+ fprintf (stderr, "Error reading from STDIN_FILENO: %s\n",
STRERROR (errno));
}
else if (0 < readsize)
@@ -477,7 +477,7 @@ main (int argc, char *argv[])
if (0 > readsize)
{
closeprog = 1;
- FPRINTF (stderr, "Error reading from fdpin: %s\n", STRERROR (errno));
+ fprintf (stderr, "Error reading from fdpin: %s\n", STRERROR (errno));
break;
}
else if (0 < readsize)
diff --git a/src/transport/gnunet-transport-profiler.c b/src/transport/gnunet-transport-profiler.c
index 89f5b4108..d4f8589d1 100644
--- a/src/transport/gnunet-transport-profiler.c
+++ b/src/transport/gnunet-transport-profiler.c
@@ -195,7 +195,7 @@ shutdown_task (void *cls)
}
if (verbosity > 0)
- FPRINTF (stdout, "\n");
+ fprintf (stdout, "\n");
/* Output format:
* All time values in ms
@@ -216,7 +216,7 @@ shutdown_task (void *cls)
icur->rate = ((benchmark_count * benchmark_size) / 1024) /
((float) icur->dur.rel_value_us / (1000 * 1000));
if (verbosity > 0)
- FPRINTF (stdout,
+ fprintf (stdout,
_ ("%llu B in %llu ms == %.2f KB/s!\n"),
((long long unsigned int) benchmark_count * benchmark_size),
((long long unsigned int) icur->dur.rel_value_us / 1000),
@@ -252,7 +252,7 @@ shutdown_task (void *cls)
stddev_duration = sqrtf (stddev_duration);
/* Output */
- FPRINTF (stdout,
+ fprintf (stdout,
"%u;%u;%llu;%llu;%.2f;%.2f",
benchmark_count,
benchmark_size,
@@ -267,7 +267,7 @@ shutdown_task (void *cls)
inext = icur->next;
GNUNET_CONTAINER_DLL_remove (ihead, itail, icur);
- FPRINTF (stdout,
+ fprintf (stdout,
";%llu;%.2f",
(long long unsigned int) (icur->dur.rel_value_us / 1000),
icur->rate);
@@ -279,14 +279,14 @@ shutdown_task (void *cls)
if (benchmark_receive)
{
duration = GNUNET_TIME_absolute_get_duration (start_time);
- FPRINTF (stdout,
+ fprintf (stdout,
"Received %llu bytes/s (%llu bytes in %s)\n",
1000LL * 1000LL * traffic_received / (1 + duration.rel_value_us),
traffic_received,
GNUNET_STRINGS_relative_time_to_string (duration, GNUNET_YES));
}
#endif
- FPRINTF (stdout, "\n");
+ fprintf (stdout, "\n");
}
@@ -326,7 +326,7 @@ send_msg (void *cls)
}
GNUNET_MQ_send (mq, env);
if ((verbosity > 0) && (0 == itail->msgs_sent % 10))
- FPRINTF (stdout, ".");
+ fprintf (stdout, ".");
}
@@ -343,7 +343,7 @@ iteration_start ()
GNUNET_CONTAINER_DLL_insert_tail (ihead, itail, icur);
icur->start = GNUNET_TIME_absolute_get ();
if (verbosity > 0)
- FPRINTF (
+ fprintf (
stdout,
"\nStarting benchmark, starting to send %u messages in %u byte blocks\n",
benchmark_count,
@@ -385,12 +385,12 @@ notify_connect (void *cls,
{
if (0 != memcmp (&pid, peer, sizeof (struct GNUNET_PeerIdentity)))
{
- FPRINTF (stdout, "Connected to different peer `%s'\n", GNUNET_i2s (&pid));
+ fprintf (stdout, "Connected to different peer `%s'\n", GNUNET_i2s (&pid));
return NULL;
}
if (verbosity > 0)
- FPRINTF (stdout, "Successfully connected to `%s'\n", GNUNET_i2s (&pid));
+ fprintf (stdout, "Successfully connected to `%s'\n", GNUNET_i2s (&pid));
mq = m;
iteration_start ();
return NULL;
@@ -415,7 +415,7 @@ notify_disconnect (void *cls,
mq = NULL;
if (GNUNET_YES == benchmark_running)
{
- FPRINTF (stdout,
+ fprintf (stdout,
"Disconnected from peer `%s' while benchmarking\n",
GNUNET_i2s (&pid));
return;
@@ -449,7 +449,7 @@ handle_dummy (void *cls, const struct GNUNET_MessageHeader *message)
if (! benchmark_receive)
return;
if (verbosity > 0)
- FPRINTF (stdout,
+ fprintf (stdout,
"Received %u bytes\n",
(unsigned int) ntohs (message->size));
}
@@ -461,7 +461,7 @@ blacklist_cb (void *cls, const struct GNUNET_PeerIdentity *peer)
if (0 != memcmp (&pid, peer, sizeof (struct GNUNET_PeerIdentity)))
{
if (verbosity > 0)
- FPRINTF (stdout, "Denying connection to `%s'\n", GNUNET_i2s (peer));
+ fprintf (stdout, "Denying connection to `%s'\n", GNUNET_i2s (peer));
return GNUNET_SYSERR;
}
return GNUNET_OK;
@@ -494,26 +494,26 @@ run (void *cls,
ret = 1;
if (GNUNET_MAX_MESSAGE_SIZE <= benchmark_size)
{
- FPRINTF (stderr, "Message size too big!\n");
+ fprintf (stderr, "Message size too big!\n");
return;
}
if (NULL == cpid)
{
- FPRINTF (stderr, "No peer identity given\n");
+ fprintf (stderr, "No peer identity given\n");
return;
}
if (GNUNET_OK != GNUNET_CRYPTO_eddsa_public_key_from_string (cpid,
strlen (cpid),
&pid.public_key))
{
- FPRINTF (stderr, "Failed to parse peer identity `%s'\n", cpid);
+ fprintf (stderr, "Failed to parse peer identity `%s'\n", cpid);
return;
}
if (1 == benchmark_send)
{
if (verbosity > 0)
- FPRINTF (stderr,
+ fprintf (stderr,
"Trying to send %u messages with size %u to peer `%s'\n",
benchmark_count,
benchmark_size,
@@ -521,20 +521,20 @@ run (void *cls,
}
else if (1 == benchmark_receive)
{
- FPRINTF (stderr,
+ fprintf (stderr,
"Trying to receive messages from peer `%s'\n",
GNUNET_i2s (&pid));
}
else
{
- FPRINTF (stderr, "No operation given\n");
+ fprintf (stderr, "No operation given\n");
return;
}
ats = GNUNET_ATS_connectivity_init (cfg);
if (NULL == ats)
{
- FPRINTF (stderr, "Failed to connect to ATS service\n");
+ fprintf (stderr, "Failed to connect to ATS service\n");
ret = 1;
return;
}
@@ -548,7 +548,7 @@ run (void *cls,
NULL);
if (NULL == handle)
{
- FPRINTF (stderr, "Failed to connect to transport service\n");
+ fprintf (stderr, "Failed to connect to transport service\n");
GNUNET_ATS_connectivity_done (ats);
ats = NULL;
ret = 1;
diff --git a/src/transport/gnunet-transport.c b/src/transport/gnunet-transport.c
index 36c8fc451..ebc3f402d 100644
--- a/src/transport/gnunet-transport.c
+++ b/src/transport/gnunet-transport.c
@@ -402,7 +402,7 @@ shutdown_task (void *cls)
if (benchmark_send)
{
duration = GNUNET_TIME_absolute_get_duration (start_time);
- FPRINTF (stdout,
+ fprintf (stdout,
_ ("Transmitted %llu bytes/s (%llu bytes in %s)\n"),
1000LL * 1000LL * traffic_sent / (1 + duration.rel_value_us),
traffic_sent,
@@ -411,7 +411,7 @@ shutdown_task (void *cls)
if (benchmark_receive)
{
duration = GNUNET_TIME_absolute_get_duration (start_time);
- FPRINTF (stdout,
+ fprintf (stdout,
_ ("Received %llu bytes/s (%llu bytes in %s)\n"),
1000LL * 1000LL * traffic_received / (1 + duration.rel_value_us),
traffic_received,
@@ -451,7 +451,7 @@ operation_timeout (void *cls)
op_timeout = NULL;
if ((benchmark_send) || (benchmark_receive))
{
- FPRINTF (stdout, _ ("Failed to connect to `%s'\n"), GNUNET_i2s_full (&pid));
+ fprintf (stdout, _ ("Failed to connect to `%s'\n"), GNUNET_i2s_full (&pid));
GNUNET_SCHEDULER_shutdown ();
ret = 1;
return;
@@ -462,7 +462,7 @@ operation_timeout (void *cls)
while (NULL != (cur = next))
{
next = cur->next;
- FPRINTF (stdout,
+ fprintf (stdout,
_ ("Failed to resolve address for peer `%s'\n"),
GNUNET_i2s (&cur->addrcp->peer));
@@ -472,7 +472,7 @@ operation_timeout (void *cls)
GNUNET_free (cur->addrcp);
GNUNET_free (cur);
}
- FPRINTF (stdout,
+ fprintf (stdout,
"%s",
_ ("Failed to list connections, timeout occurred\n"));
GNUNET_SCHEDULER_shutdown ();
@@ -500,7 +500,7 @@ do_send (void *cls)
traffic_sent += BLOCKSIZE * 1024;
GNUNET_MQ_notify_sent (env, &do_send, mq);
if (verbosity > 0)
- FPRINTF (stdout,
+ fprintf (stdout,
_ ("Transmitting %u bytes\n"),
(unsigned int) BLOCKSIZE * 1024);
GNUNET_MQ_send (mq, env);
@@ -531,7 +531,7 @@ notify_connect (void *cls,
op_timeout = NULL;
}
if (verbosity > 0)
- FPRINTF (
+ fprintf (
stdout,
_ (
"Successfully connected to `%s', starting to send benchmark data in %u Kb blocks\n"),
@@ -562,7 +562,7 @@ notify_disconnect (void *cls,
return; /* not about target peer */
if (! benchmark_send)
return; /* not transmitting */
- FPRINTF (stdout,
+ fprintf (stdout,
_ ("Disconnected from peer `%s' while benchmarking\n"),
GNUNET_i2s (&pid));
}
@@ -586,7 +586,7 @@ monitor_notify_connect (void *cls,
const char *now_str = GNUNET_STRINGS_absolute_time_to_string (now);
monitor_connect_counter++;
- FPRINTF (stdout,
+ fprintf (stdout,
_ ("%24s: %-17s %4s (%u connections in total)\n"),
now_str,
_ ("Connected to"),
@@ -615,7 +615,7 @@ monitor_notify_disconnect (void *cls,
GNUNET_assert (monitor_connect_counter > 0);
monitor_connect_counter--;
- FPRINTF (stdout,
+ fprintf (stdout,
_ ("%24s: %-17s %4s (%u connections in total)\n"),
now_str,
_ ("Disconnected from"),
@@ -650,7 +650,7 @@ handle_dummy (void *cls, const struct GNUNET_MessageHeader *message)
if (! benchmark_receive)
return;
if (verbosity > 0)
- FPRINTF (stdout,
+ fprintf (stdout,
_ ("Received %u bytes\n"),
(unsigned int) ntohs (message->size));
if (0 == traffic_received)
@@ -686,7 +686,7 @@ print_info (const struct GNUNET_PeerIdentity *id,
if (((GNUNET_YES == iterate_connections) && (GNUNET_YES == iterate_all)) ||
(GNUNET_YES == monitor_connections))
{
- FPRINTF (stdout,
+ fprintf (stdout,
_ ("Peer `%s': %s %s in state `%s' until %s\n"),
GNUNET_i2s (id),
(NULL == transport) ? "<none>" : transport,
@@ -698,7 +698,7 @@ print_info (const struct GNUNET_PeerIdentity *id,
(GNUNET_TRANSPORT_is_connected (state)))
{
/* Only connected peers, skip state */
- FPRINTF (stdout,
+ fprintf (stdout,
_ ("Peer `%s': %s %s\n"),
GNUNET_i2s (id),
transport,
@@ -732,7 +732,7 @@ process_peer_string (void *cls, const char *address, int res)
{
if (GNUNET_SYSERR == res)
{
- FPRINTF (
+ fprintf (
stderr,
"Failed to convert address for peer `%s' plugin `%s' length %u to string \n",
GNUNET_i2s (&rc->addrcp->peer),
@@ -1094,7 +1094,7 @@ process_peer_monitoring_cb (void *cls,
if (NULL == peer)
{
- FPRINTF (stdout,
+ fprintf (stdout,
"%s",
_ (
"Monitor disconnected from transport service. Reconnecting.\n"));
@@ -1189,7 +1189,7 @@ run (void *cls,
if (1 < counter)
{
- FPRINTF (
+ fprintf (
stderr,
_ (
"Multiple operations given. Please choose only one operation: %s, %s, %s, %s, %s, %s %s\n"),
@@ -1204,7 +1204,7 @@ run (void *cls,
}
if (0 == counter)
{
- FPRINTF (
+ fprintf (
stderr,
_ (
"No operation given. Please choose one operation: %s, %s, %s, %s, %s, %s, %s\n"),
@@ -1222,7 +1222,7 @@ run (void *cls,
{
if (0 == memcmp (&zero_pid, &pid, sizeof (pid)))
{
- FPRINTF (stderr,
+ fprintf (stderr,
_ ("Option `%s' makes no sense without option `%s'.\n"),
"-D",
"-p");
@@ -1232,14 +1232,14 @@ run (void *cls,
blacklist = GNUNET_TRANSPORT_blacklist (cfg, &blacklist_cb, NULL);
if (NULL == blacklist)
{
- FPRINTF (stderr,
+ fprintf (stderr,
"%s",
_ (
"Failed to connect to transport service for disconnection\n"));
ret = 1;
return;
}
- FPRINTF (stdout,
+ fprintf (stdout,
"%s",
_ ("Blacklisting request in place, stop with CTRL-C\n"));
}
@@ -1247,7 +1247,7 @@ run (void *cls,
{
if (0 == memcmp (&zero_pid, &pid, sizeof (pid)))
{
- FPRINTF (stderr,
+ fprintf (stderr,
_ ("Option `%s' makes no sense without option `%s'.\n"),
"-s",
"-p");
@@ -1263,7 +1263,7 @@ run (void *cls,
NULL);
if (NULL == handle)
{
- FPRINTF (stderr, "%s", _ ("Failed to connect to transport service\n"));
+ fprintf (stderr, "%s", _ ("Failed to connect to transport service\n"));
ret = 1;
return;
}
@@ -1289,12 +1289,12 @@ run (void *cls,
NULL);
if (NULL == handle)
{
- FPRINTF (stderr, "%s", _ ("Failed to connect to transport service\n"));
+ fprintf (stderr, "%s", _ ("Failed to connect to transport service\n"));
ret = 1;
return;
}
if (verbosity > 0)
- FPRINTF (stdout, "%s", _ ("Starting to receive benchmark data\n"));
+ fprintf (stdout, "%s", _ ("Starting to receive benchmark data\n"));
start_time = GNUNET_TIME_absolute_get ();
}
else if (iterate_connections) /* -i: List information about peers once */
@@ -1335,7 +1335,7 @@ run (void *cls,
NULL);
if (NULL == handle)
{
- FPRINTF (stderr, "%s", _ ("Failed to connect to transport service\n"));
+ fprintf (stderr, "%s", _ ("Failed to connect to transport service\n"));
ret = 1;
return;
}
diff --git a/src/transport/plugin_transport_smtp.c b/src/transport/plugin_transport_smtp.c
index 705c91b85..1c61f07d7 100644
--- a/src/transport/plugin_transport_smtp.c
+++ b/src/transport/plugin_transport_smtp.c
@@ -667,7 +667,7 @@ inittransport_smtp (struct GNUNET_CoreAPIForTransport * core)
stats->create (gettext_noop ("# bytes dropped by SMTP (outgoing)"));
}
GNUNET_GC_get_configuration_value_filename (core_api->cfg, "SMTP", "PIPE", &pipename);
- UNLINK (pipename);
+ unlink (pipename);
if (0 != mkfifo (pipename, S_IWUSR | S_IRUSR | S_IWGRP | S_IWOTH))
{
GNUNET_GE_LOG_STRERROR (ectx,
@@ -722,7 +722,7 @@ donetransport_smtp ()
}
GNUNET_mutex_destroy (lock);
lock = NULL;
- UNLINK (pipename);
+ unlink (pipename);
GNUNET_free (pipename);
pipename = NULL;
GNUNET_free (email);
diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c
index a0dd80617..0ea0bf460 100644
--- a/src/transport/plugin_transport_tcp.c
+++ b/src/transport/plugin_transport_tcp.c
@@ -35,7 +35,7 @@
#include "gnunet_transport_plugin.h"
#include "transport.h"
-#define LOG(kind,...) GNUNET_log_from (kind, "transport-tcp",__VA_ARGS__)
+#define LOG(kind, ...) GNUNET_log_from (kind, "transport-tcp", __VA_ARGS__)
#define PLUGIN_NAME "tcp"
@@ -86,7 +86,6 @@ void
LEGACY_SERVICE_stop (struct LEGACY_SERVICE_Context *srv);
-
/**
* Function called to notify a client about the connection begin ready
* to queue more data. @a buf will be NULL and @a size zero if the
@@ -97,10 +96,9 @@ LEGACY_SERVICE_stop (struct LEGACY_SERVICE_Context *srv);
* @param buf where the callee should write the message
* @return number of bytes written to @a buf
*/
-typedef size_t
-(*GNUNET_CONNECTION_TransmitReadyNotify) (void *cls,
- size_t size,
- void *buf);
+typedef size_t (*GNUNET_CONNECTION_TransmitReadyNotify) (void *cls,
+ size_t size,
+ void *buf);
/**
* Credentials for UNIX domain sockets.
@@ -127,9 +125,9 @@ struct GNUNET_CONNECTION_Credentials
* @param client identification of the client; NULL
* for the last call when the server is destroyed
*/
-typedef void
-(*GNUNET_SERVER_DisconnectCallback) (void *cls,
- struct GNUNET_SERVER_Client *client);
+typedef void (*GNUNET_SERVER_DisconnectCallback) (
+ void *cls,
+ struct GNUNET_SERVER_Client *client);
/**
@@ -139,11 +137,9 @@ typedef void
* @param cls closure
* @param client identification of the client
*/
-typedef void
-(*GNUNET_SERVER_ConnectCallback) (void *cls,
- struct GNUNET_SERVER_Client *client);
-
-
+typedef void (*GNUNET_SERVER_ConnectCallback) (
+ void *cls,
+ struct GNUNET_SERVER_Client *client);
/**
@@ -156,13 +152,11 @@ typedef void
* @return GNUNET_YES to allow, GNUNET_NO to deny, GNUNET_SYSERR
* for unknown address family (will be denied).
*/
-typedef int
-(*GNUNET_CONNECTION_AccessCheck) (void *cls,
- const struct
- GNUNET_CONNECTION_Credentials *
- ucred,
- const struct sockaddr * addr,
- socklen_t addrlen);
+typedef int (*GNUNET_CONNECTION_AccessCheck) (
+ void *cls,
+ const struct GNUNET_CONNECTION_Credentials *ucred,
+ const struct sockaddr *addr,
+ socklen_t addrlen);
/**
* Callback function for data received from the network. Note that
@@ -176,12 +170,12 @@ typedef int
* @param addrlen size of addr
* @param errCode value of errno (on errors receiving)
*/
-typedef void
-(*GNUNET_CONNECTION_Receiver) (void *cls, const void *buf,
- size_t available,
- const struct sockaddr * addr,
- socklen_t addrlen, int errCode);
-
+typedef void (*GNUNET_CONNECTION_Receiver) (void *cls,
+ const void *buf,
+ size_t available,
+ const struct sockaddr *addr,
+ socklen_t addrlen,
+ int errCode);
/**
@@ -202,9 +196,9 @@ GNUNET_CONNECTION_destroy (struct GNUNET_CONNECTION_Handle *connection);
* @param client handle to client the tokenzier will be used for
* @return handle to custom tokenizer ('mst')
*/
-typedef void*
-(*GNUNET_SERVER_MstCreateCallback) (void *cls,
- struct GNUNET_SERVER_Client *client);
+typedef void *(*GNUNET_SERVER_MstCreateCallback) (
+ void *cls,
+ struct GNUNET_SERVER_Client *client);
/**
@@ -213,9 +207,7 @@ typedef void*
* @param cls closure from #GNUNET_SERVER_set_callbacks
* @param mst custom tokenizer handle
*/
-typedef void
-(*GNUNET_SERVER_MstDestroyCallback) (void *cls,
- void *mst);
+typedef void (*GNUNET_SERVER_MstDestroyCallback) (void *cls, void *mst);
/**
* Signature of a function to receive data for a custom tokenizer.
@@ -233,13 +225,14 @@ typedef void
* #GNUNET_NO if one_shot was set and we have another message ready
* #GNUNET_SYSERR if the data stream is corrupt
*/
-typedef int
-(*GNUNET_SERVER_MstReceiveCallback) (void *cls, void *mst,
- struct GNUNET_SERVER_Client *client,
- const char *buf,
- size_t size,
- int purge,
- int one_shot);
+typedef int (*GNUNET_SERVER_MstReceiveCallback) (
+ void *cls,
+ void *mst,
+ struct GNUNET_SERVER_Client *client,
+ const char *buf,
+ size_t size,
+ int purge,
+ int one_shot);
/**
* Functions with this signature are called whenever a message is
* received.
@@ -248,10 +241,10 @@ typedef int
* @param client identification of the client
* @param message the actual message
*/
-typedef void
-(*GNUNET_SERVER_MessageCallback) (void *cls,
- struct GNUNET_SERVER_Client *client,
- const struct GNUNET_MessageHeader *message);
+typedef void (*GNUNET_SERVER_MessageCallback) (
+ void *cls,
+ struct GNUNET_SERVER_Client *client,
+ const struct GNUNET_MessageHeader *message);
/**
* Message handler. Each struct specifies how to handle on particular
@@ -281,7 +274,6 @@ struct GNUNET_SERVER_MessageHandler
* if they do not have the right size.
*/
uint16_t expected_size;
-
};
@@ -311,7 +303,6 @@ enum LEGACY_SERVICE_Options
};
-
/**
* Ask the server to disconnect from the given client. This is the
* same as passing #GNUNET_SYSERR to #GNUNET_SERVER_receive_done,
@@ -348,10 +339,10 @@ GNUNET_SERVER_client_get_user_context_ (struct GNUNET_SERVER_Client *client,
* @param message the actual message
* @return #GNUNET_OK on success, #GNUNET_SYSERR to stop further processing
*/
-typedef int
-(*GNUNET_SERVER_MessageTokenizerCallback) (void *cls,
- void *client,
- const struct GNUNET_MessageHeader *message);
+typedef int (*GNUNET_SERVER_MessageTokenizerCallback) (
+ void *cls,
+ void *client,
+ const struct GNUNET_MessageHeader *message);
/**
@@ -384,9 +375,10 @@ GNUNET_SERVER_mst_create (GNUNET_SERVER_MessageTokenizerCallback cb,
int
GNUNET_SERVER_mst_receive (struct GNUNET_SERVER_MessageStreamTokenizer *mst,
void *client_identity,
- const char *buf, size_t size,
- int purge, int one_shot);
-
+ const char *buf,
+ size_t size,
+ int purge,
+ int one_shot);
/**
@@ -417,7 +409,7 @@ GNUNET_SERVER_client_set_user_context_ (struct GNUNET_SERVER_Client *client,
* @param type expected return type (i.e. 'struct Foo')
* @return pointer to user context of type 'type *'.
*/
-#define GNUNET_SERVER_client_get_user_context(client,type) \
+#define GNUNET_SERVER_client_get_user_context(client, type) \
(type *) GNUNET_SERVER_client_get_user_context_ (client, sizeof (type))
/**
@@ -426,11 +418,10 @@ GNUNET_SERVER_client_set_user_context_ (struct GNUNET_SERVER_Client *client,
* @param client client to query
* @param value pointer to user context
*/
-#define GNUNET_SERVER_client_set_user_context(client,value) \
+#define GNUNET_SERVER_client_set_user_context(client, value) \
GNUNET_SERVER_client_set_user_context_ (client, value, sizeof (*value))
-
/**
* Notify us when the server has enough space to transmit
* a message of the given size to the given client.
@@ -447,11 +438,12 @@ GNUNET_SERVER_client_set_user_context_ (struct GNUNET_SERVER_Client *client,
* NULL if we are already going to notify someone else (busy)
*/
struct GNUNET_SERVER_TransmitHandle *
-GNUNET_SERVER_notify_transmit_ready (struct GNUNET_SERVER_Client *client,
- size_t size,
- struct GNUNET_TIME_Relative timeout,
- GNUNET_CONNECTION_TransmitReadyNotify callback,
- void *callback_cls);
+GNUNET_SERVER_notify_transmit_ready (
+ struct GNUNET_SERVER_Client *client,
+ size_t size,
+ struct GNUNET_TIME_Relative timeout,
+ GNUNET_CONNECTION_TransmitReadyNotify callback,
+ void *callback_cls);
/**
* Abort transmission request.
@@ -459,9 +451,8 @@ GNUNET_SERVER_notify_transmit_ready (struct GNUNET_SERVER_Client *client,
* @param th request to abort
*/
void
-GNUNET_SERVER_notify_transmit_ready_cancel (struct GNUNET_SERVER_TransmitHandle *th);
-
-
+GNUNET_SERVER_notify_transmit_ready_cancel (
+ struct GNUNET_SERVER_TransmitHandle *th);
/**
@@ -495,11 +486,10 @@ GNUNET_SERVER_client_drop (struct GNUNET_SERVER_Client *client);
* @param server the initialized server
* @param cfg configuration to use
*/
-typedef void
-(*LEGACY_SERVICE_Main) (void *cls,
- struct GNUNET_SERVER_Handle *server,
- const struct GNUNET_CONFIGURATION_Handle *cfg);
-
+typedef void (*LEGACY_SERVICE_Main) (
+ void *cls,
+ struct GNUNET_SERVER_Handle *server,
+ const struct GNUNET_CONFIGURATION_Handle *cfg);
/**
@@ -527,11 +517,12 @@ GNUNET_SERVER_suspend (struct GNUNET_SERVER_Handle *server);
* NULL if we are already going to notify someone else (busy)
*/
struct GNUNET_SERVER_TransmitHandle *
-GNUNET_SERVER_notify_transmit_ready (struct GNUNET_SERVER_Client *client,
- size_t size,
- struct GNUNET_TIME_Relative timeout,
- GNUNET_CONNECTION_TransmitReadyNotify callback,
- void *callback_cls);
+GNUNET_SERVER_notify_transmit_ready (
+ struct GNUNET_SERVER_Client *client,
+ size_t size,
+ struct GNUNET_TIME_Relative timeout,
+ GNUNET_CONNECTION_TransmitReadyNotify callback,
+ void *callback_cls);
/**
@@ -567,8 +558,6 @@ void
GNUNET_SERVER_destroy (struct GNUNET_SERVER_Handle *server);
-
-
#include "tcp_connection_legacy.c"
#include "tcp_server_mst_legacy.c"
#include "tcp_server_legacy.c"
@@ -590,7 +579,6 @@ struct WelcomeMessage
* Identity of the node connecting (TCP client)
*/
struct GNUNET_PeerIdentity clientIdentity;
-
};
/**
@@ -608,7 +596,6 @@ struct TCP_NAT_ProbeMessage
* Identity of the sender of the message.
*/
struct GNUNET_PeerIdentity clientIdentity;
-
};
GNUNET_NETWORK_STRUCT_END
@@ -693,7 +680,6 @@ struct IPv4TcpAddress
* Port number, in network byte order.
*/
uint16_t t4_port GNUNET_PACKED;
-
};
/**
@@ -716,7 +702,6 @@ struct IPv6TcpAddress
* Port number, in network byte order.
*/
uint16_t t6_port GNUNET_PACKED;
-
};
GNUNET_NETWORK_STRUCT_END
@@ -770,7 +755,6 @@ struct PendingMessage
* instead of just a `struct GNUNET_MessageHeader`.
*/
size_t message_size;
-
};
/**
@@ -872,7 +856,6 @@ struct GNUNET_ATS_Session
* Was this session created using NAT traversal?
*/
int is_nat;
-
};
@@ -1045,7 +1028,6 @@ struct Plugin
* rest of the world.
*/
uint16_t adv_port;
-
};
@@ -1071,9 +1053,9 @@ struct Plugin
*/
static int
get_server_addresses (const char *service_name,
- const struct GNUNET_CONFIGURATION_Handle *cfg,
- struct sockaddr ***addrs,
- socklen_t ** addr_lens)
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
+ struct sockaddr ***addrs,
+ socklen_t **addr_lens)
{
int disablev6;
struct GNUNET_NETWORK_Handle *desc;
@@ -1097,8 +1079,9 @@ get_server_addresses (const char *service_name,
if (GNUNET_CONFIGURATION_have_value (cfg, service_name, "DISABLEV6"))
{
if (GNUNET_SYSERR ==
- (disablev6 =
- GNUNET_CONFIGURATION_get_value_yesno (cfg, service_name, "DISABLEV6")))
+ (disablev6 = GNUNET_CONFIGURATION_get_value_yesno (cfg,
+ service_name,
+ "DISABLEV6")))
return GNUNET_SYSERR;
}
else
@@ -1117,8 +1100,10 @@ get_server_addresses (const char *service_name,
return GNUNET_SYSERR;
}
LOG (GNUNET_ERROR_TYPE_INFO,
- _("Disabling IPv6 support for service `%s', failed to create IPv6 socket: %s\n"),
- service_name, STRERROR (errno));
+ _ (
+ "Disabling IPv6 support for service `%s', failed to create IPv6 socket: %s\n"),
+ service_name,
+ strerror (errno));
disablev6 = GNUNET_YES;
}
else
@@ -1131,18 +1116,19 @@ get_server_addresses (const char *service_name,
port = 0;
if (GNUNET_CONFIGURATION_have_value (cfg, service_name, "PORT"))
{
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_number (cfg, service_name,
- "PORT", &port))
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg,
+ service_name,
+ "PORT",
+ &port))
{
LOG (GNUNET_ERROR_TYPE_ERROR,
- _("Require valid port number for service `%s' in configuration!\n"),
+ _ ("Require valid port number for service `%s' in configuration!\n"),
service_name);
}
if (port > 65535)
{
LOG (GNUNET_ERROR_TYPE_ERROR,
- _("Require valid port number for service `%s' in configuration!\n"),
+ _ ("Require valid port number for service `%s' in configuration!\n"),
service_name);
return GNUNET_SYSERR;
}
@@ -1151,8 +1137,10 @@ get_server_addresses (const char *service_name,
if (GNUNET_CONFIGURATION_have_value (cfg, service_name, "BINDTO"))
{
GNUNET_break (GNUNET_OK ==
- GNUNET_CONFIGURATION_get_value_string (cfg, service_name,
- "BINDTO", &hostname));
+ GNUNET_CONFIGURATION_get_value_string (cfg,
+ service_name,
+ "BINDTO",
+ &hostname));
}
else
hostname = NULL;
@@ -1162,9 +1150,10 @@ get_server_addresses (const char *service_name,
#ifdef AF_UNIX
if ((GNUNET_YES ==
GNUNET_CONFIGURATION_have_value (cfg, service_name, "UNIXPATH")) &&
- (GNUNET_OK ==
- GNUNET_CONFIGURATION_get_value_filename (cfg, service_name, "UNIXPATH",
- &unixpath)) &&
+ (GNUNET_OK == GNUNET_CONFIGURATION_get_value_filename (cfg,
+ service_name,
+ "UNIXPATH",
+ &unixpath)) &&
(0 < strlen (unixpath)))
{
/* probe UNIX support */
@@ -1173,12 +1162,11 @@ get_server_addresses (const char *service_name,
if (strlen (unixpath) >= sizeof (s_un.sun_path))
{
LOG (GNUNET_ERROR_TYPE_WARNING,
- _("UNIXPATH `%s' too long, maximum length is %llu\n"), unixpath,
+ _ ("UNIXPATH `%s' too long, maximum length is %llu\n"),
+ unixpath,
(unsigned long long) sizeof (s_un.sun_path));
unixpath = GNUNET_NETWORK_shorten_unixpath (unixpath);
- LOG (GNUNET_ERROR_TYPE_INFO,
- _("Using `%s' instead\n"),
- unixpath);
+ LOG (GNUNET_ERROR_TYPE_INFO, _ ("Using `%s' instead\n"), unixpath);
}
#ifdef LINUX
abstract = GNUNET_CONFIGURATION_get_value_yesno (cfg,
@@ -1187,12 +1175,9 @@ get_server_addresses (const char *service_name,
if (GNUNET_SYSERR == abstract)
abstract = GNUNET_NO;
#endif
- if ((GNUNET_YES != abstract)
- && (GNUNET_OK !=
- GNUNET_DISK_directory_create_for_file (unixpath)))
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
- "mkdir",
- unixpath);
+ if ((GNUNET_YES != abstract) &&
+ (GNUNET_OK != GNUNET_DISK_directory_create_for_file (unixpath)))
+ GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "mkdir", unixpath);
}
if (NULL != unixpath)
{
@@ -1208,9 +1193,10 @@ get_server_addresses (const char *service_name,
return GNUNET_SYSERR;
}
LOG (GNUNET_ERROR_TYPE_INFO,
- _("Disabling UNIX domain socket support for service `%s', failed to create UNIX domain socket: %s\n"),
+ _ (
+ "Disabling UNIX domain socket support for service `%s', failed to create UNIX domain socket: %s\n"),
service_name,
- STRERROR (errno));
+ strerror (errno));
GNUNET_free (unixpath);
unixpath = NULL;
}
@@ -1225,7 +1211,8 @@ get_server_addresses (const char *service_name,
if ((0 == port) && (NULL == unixpath))
{
LOG (GNUNET_ERROR_TYPE_ERROR,
- _("Have neither PORT nor UNIXPATH for service `%s', but one is required\n"),
+ _ (
+ "Have neither PORT nor UNIXPATH for service `%s', but one is required\n"),
service_name);
GNUNET_free_non_null (hostname);
return GNUNET_SYSERR;
@@ -1256,7 +1243,7 @@ get_server_addresses (const char *service_name,
(NULL == res))
{
LOG (GNUNET_ERROR_TYPE_ERROR,
- _("Failed to resolve `%s': %s\n"),
+ _ ("Failed to resolve `%s': %s\n"),
hostname,
gai_strerror (ret));
GNUNET_free (hostname);
@@ -1275,7 +1262,7 @@ get_server_addresses (const char *service_name,
if (0 == i)
{
LOG (GNUNET_ERROR_TYPE_ERROR,
- _("Failed to find %saddress for `%s'.\n"),
+ _ ("Failed to find %saddress for `%s'.\n"),
disablev6 ? "IPv4 " : "",
hostname);
freeaddrinfo (res);
@@ -1301,11 +1288,13 @@ get_server_addresses (const char *service_name,
if ((disablev6) && (AF_INET6 == pos->ai_family))
continue;
if ((IPPROTO_TCP != pos->ai_protocol) && (0 != pos->ai_protocol))
- continue; /* not TCP */
+ continue; /* not TCP */
if ((SOCK_STREAM != pos->ai_socktype) && (0 != pos->ai_socktype))
- continue; /* huh? */
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Service `%s' will bind to `%s'\n",
- service_name, GNUNET_a2s (pos->ai_addr, pos->ai_addrlen));
+ continue; /* huh? */
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Service `%s' will bind to `%s'\n",
+ service_name,
+ GNUNET_a2s (pos->ai_addr, pos->ai_addrlen));
if (AF_INET == pos->ai_family)
{
GNUNET_assert (sizeof (struct sockaddr_in) == pos->ai_addrlen);
@@ -1412,17 +1401,16 @@ notify_session_monitor (struct Plugin *plugin,
return;
memset (&info, 0, sizeof (info));
info.state = state;
- info.is_inbound = GNUNET_HELLO_address_check_option (session->address,
- GNUNET_HELLO_ADDRESS_INFO_INBOUND);
+ info.is_inbound =
+ GNUNET_HELLO_address_check_option (session->address,
+ GNUNET_HELLO_ADDRESS_INFO_INBOUND);
info.num_msg_pending = session->msgs_in_queue;
info.num_bytes_pending = session->bytes_in_queue;
if (NULL != session->receive_delay_task)
info.receive_delay = session->receive_delay;
info.session_timeout = session->timeout;
info.address = session->address;
- plugin->sic (plugin->sic_cls,
- session,
- &info);
+ plugin->sic (plugin->sic_cls, session, &info);
}
@@ -1440,10 +1428,10 @@ notify_session_monitor (struct Plugin *plugin,
*/
static void
tcp_nat_port_map_callback (void *cls,
- void **app_ctx,
+ void **app_ctx,
int add_remove,
- enum GNUNET_NAT_AddressClass ac,
- const struct sockaddr *addr,
+ enum GNUNET_NAT_AddressClass ac,
+ const struct sockaddr *addr,
socklen_t addrlen)
{
struct Plugin *plugin = cls;
@@ -1462,8 +1450,8 @@ tcp_nat_port_map_callback (void *cls,
switch (addr->sa_family)
{
case AF_INET:
- GNUNET_assert(addrlen == sizeof(struct sockaddr_in));
- memset (&t4, 0, sizeof(t4));
+ GNUNET_assert (addrlen == sizeof (struct sockaddr_in));
+ memset (&t4, 0, sizeof (t4));
t4.options = htonl (plugin->myoptions);
t4.ipv4_addr = ((struct sockaddr_in *) addr)->sin_addr.s_addr;
t4.t4_port = ((struct sockaddr_in *) addr)->sin_port;
@@ -1477,32 +1465,30 @@ tcp_nat_port_map_callback (void *cls,
#tcp_plugin_check_address() */
return;
}
- GNUNET_assert(addrlen == sizeof(struct sockaddr_in6));
- memset (&t6, 0, sizeof(t6));
+ GNUNET_assert (addrlen == sizeof (struct sockaddr_in6));
+ memset (&t6, 0, sizeof (t6));
GNUNET_memcpy (&t6.ipv6_addr,
- &((struct sockaddr_in6 *) addr)->sin6_addr,
- sizeof(struct in6_addr));
+ &((struct sockaddr_in6 *) addr)->sin6_addr,
+ sizeof (struct in6_addr));
t6.options = htonl (plugin->myoptions);
t6.t6_port = ((struct sockaddr_in6 *) addr)->sin6_port;
arg = &t6;
args = sizeof (t6);
break;
default:
- GNUNET_break(0);
+ GNUNET_break (0);
return;
}
/* modify our published address list */
GNUNET_assert ((args == sizeof (struct IPv4TcpAddress)) ||
- (args == sizeof (struct IPv6TcpAddress)));
+ (args == sizeof (struct IPv6TcpAddress)));
/* TODO: use 'ac' here in the future... */
address = GNUNET_HELLO_address_allocate (plugin->env->my_identity,
- PLUGIN_NAME,
- arg,
- args,
- GNUNET_HELLO_ADDRESS_INFO_NONE);
- plugin->env->notify_address (plugin->env->cls,
- add_remove,
- address);
+ PLUGIN_NAME,
+ arg,
+ args,
+ GNUNET_HELLO_ADDRESS_INFO_NONE);
+ plugin->env->notify_address (plugin->env->cls, add_remove, address);
GNUNET_HELLO_address_free (address);
}
@@ -1519,9 +1505,7 @@ tcp_nat_port_map_callback (void *cls,
* @return string representing the same address
*/
static const char *
-tcp_plugin_address_to_string (void *cls,
- const void *addr,
- size_t addrlen)
+tcp_plugin_address_to_string (void *cls, const void *addr, size_t addrlen)
{
static char rbuf[INET6_ADDRSTRLEN + 12];
char buf[INET6_ADDRSTRLEN];
@@ -1536,35 +1520,35 @@ tcp_plugin_address_to_string (void *cls,
switch (addrlen)
{
- case sizeof(struct IPv6TcpAddress):
+ case sizeof (struct IPv6TcpAddress):
t6 = addr;
af = AF_INET6;
port = ntohs (t6->t6_port);
options = ntohl (t6->options);
- GNUNET_memcpy (&a6, &t6->ipv6_addr, sizeof(a6));
+ GNUNET_memcpy (&a6, &t6->ipv6_addr, sizeof (a6));
sb = &a6;
break;
- case sizeof(struct IPv4TcpAddress):
+ case sizeof (struct IPv4TcpAddress):
t4 = addr;
af = AF_INET;
port = ntohs (t4->t4_port);
options = ntohl (t4->options);
- GNUNET_memcpy (&a4, &t4->ipv4_addr, sizeof(a4));
+ GNUNET_memcpy (&a4, &t4->ipv4_addr, sizeof (a4));
sb = &a4;
break;
default:
LOG (GNUNET_ERROR_TYPE_WARNING,
- _("Unexpected address length: %u bytes\n"),
+ _ ("Unexpected address length: %u bytes\n"),
(unsigned int) addrlen);
- return NULL ;
+ return NULL;
}
if (NULL == inet_ntop (af, sb, buf, INET6_ADDRSTRLEN))
{
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING,
- "inet_ntop");
- return NULL ;
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "inet_ntop");
+ return NULL;
}
- GNUNET_snprintf (rbuf, sizeof(rbuf),
+ GNUNET_snprintf (rbuf,
+ sizeof (rbuf),
(af == AF_INET6) ? "%s.%u.[%s]:%u" : "%s.%u.%s:%u",
PLUGIN_NAME,
options,
@@ -1605,25 +1589,25 @@ tcp_plugin_string_to_address (void *cls,
optionstr = NULL;
if ((NULL == addr) || (0 == addrlen))
{
- GNUNET_break(0);
+ GNUNET_break (0);
return GNUNET_SYSERR;
}
if ('\0' != addr[addrlen - 1])
{
- GNUNET_break(0);
+ GNUNET_break (0);
return GNUNET_SYSERR;
}
if (strlen (addr) != addrlen - 1)
{
- GNUNET_break(0);
+ GNUNET_break (0);
return GNUNET_SYSERR;
}
plugin = GNUNET_strdup (addr);
optionstr = strchr (plugin, '.');
if (NULL == optionstr)
{
- GNUNET_break(0);
- GNUNET_free(plugin);
+ GNUNET_break (0);
+ GNUNET_free (plugin);
return GNUNET_SYSERR;
}
optionstr[0] = '\0';
@@ -1632,28 +1616,25 @@ tcp_plugin_string_to_address (void *cls,
address = strchr (optionstr, '.');
if (NULL == address)
{
- GNUNET_break(0);
- GNUNET_free(plugin);
+ GNUNET_break (0);
+ GNUNET_free (plugin);
return GNUNET_SYSERR;
}
address[0] = '\0';
address++;
if (GNUNET_OK !=
- GNUNET_STRINGS_to_address_ip (address,
- strlen (address),
- &socket_address))
+ GNUNET_STRINGS_to_address_ip (address, strlen (address), &socket_address))
{
- GNUNET_break(0);
- GNUNET_free(plugin);
+ GNUNET_break (0);
+ GNUNET_free (plugin);
return GNUNET_SYSERR;
}
- GNUNET_free(plugin);
+ GNUNET_free (plugin);
switch (socket_address.ss_family)
{
- case AF_INET:
- {
+ case AF_INET: {
struct IPv4TcpAddress *t4;
struct sockaddr_in *in4 = (struct sockaddr_in *) &socket_address;
t4 = GNUNET_new (struct IPv4TcpAddress);
@@ -1661,11 +1642,10 @@ tcp_plugin_string_to_address (void *cls,
t4->ipv4_addr = in4->sin_addr.s_addr;
t4->t4_port = in4->sin_port;
*buf = t4;
- *added = sizeof(struct IPv4TcpAddress);
+ *added = sizeof (struct IPv4TcpAddress);
return GNUNET_OK;
}
- case AF_INET6:
- {
+ case AF_INET6: {
struct IPv6TcpAddress *t6;
struct sockaddr_in6 *in6 = (struct sockaddr_in6 *) &socket_address;
t6 = GNUNET_new (struct IPv6TcpAddress);
@@ -1673,7 +1653,7 @@ tcp_plugin_string_to_address (void *cls,
t6->ipv6_addr = in6->sin6_addr;
t6->t6_port = in6->sin6_port;
*buf = t6;
- *added = sizeof(struct IPv6TcpAddress);
+ *added = sizeof (struct IPv6TcpAddress);
return GNUNET_OK;
}
default:
@@ -1711,8 +1691,7 @@ lookup_session_by_client (struct Plugin *plugin,
* @return #GNUNET_OK on success
*/
static int
-tcp_plugin_disconnect_session (void *cls,
- struct GNUNET_ATS_Session *session)
+tcp_plugin_disconnect_session (void *cls, struct GNUNET_ATS_Session *session)
{
struct Plugin *plugin = cls;
struct PendingMessage *pm;
@@ -1731,26 +1710,24 @@ tcp_plugin_disconnect_session (void *cls,
session->timeout = GNUNET_TIME_UNIT_ZERO_ABS;
}
- if (GNUNET_YES ==
- GNUNET_CONTAINER_multipeermap_remove (plugin->sessionmap,
- &session->target,
- session))
+ if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_remove (plugin->sessionmap,
+ &session->target,
+ session))
{
GNUNET_STATISTICS_update (session->plugin->env->stats,
- gettext_noop ("# TCP sessions active"),
- -1,
- GNUNET_NO);
+ gettext_noop ("# TCP sessions active"),
+ -1,
+ GNUNET_NO);
}
else
{
GNUNET_assert (GNUNET_YES ==
- GNUNET_CONTAINER_multipeermap_remove (plugin->nat_wait_conns,
- &session->target,
- session));
+ GNUNET_CONTAINER_multipeermap_remove (plugin->nat_wait_conns,
+ &session->target,
+ session));
}
if (NULL != session->client)
- GNUNET_SERVER_client_set_user_context (session->client,
- NULL);
+ GNUNET_SERVER_client_set_user_context (session->client, NULL);
/* clean up state */
if (NULL != session->transmit_handle)
@@ -1772,17 +1749,19 @@ tcp_plugin_disconnect_session (void *cls,
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
(NULL != pm->transmit_cont)
- ? "Could not deliver message to `%s' at %s.\n"
- : "Could not deliver message to `%s' at %s, notifying.\n",
+ ? "Could not deliver message to `%s' at %s.\n"
+ : "Could not deliver message to `%s' at %s, notifying.\n",
GNUNET_i2s (&session->target),
tcp_plugin_address_to_string (session->plugin,
session->address->address,
session->address->address_length));
GNUNET_STATISTICS_update (session->plugin->env->stats,
gettext_noop ("# bytes currently in TCP buffers"),
- -(int64_t) pm->message_size, GNUNET_NO);
+ -(int64_t) pm->message_size,
+ GNUNET_NO);
GNUNET_STATISTICS_update (session->plugin->env->stats,
- gettext_noop ("# bytes discarded by TCP (disconnect)"),
+ gettext_noop (
+ "# bytes discarded by TCP (disconnect)"),
pm->message_size,
GNUNET_NO);
GNUNET_CONTAINER_DLL_remove (session->pending_messages_head,
@@ -1802,9 +1781,7 @@ tcp_plugin_disconnect_session (void *cls,
}
GNUNET_assert (0 == session->msgs_in_queue);
GNUNET_assert (0 == session->bytes_in_queue);
- notify_session_monitor (session->plugin,
- session,
- GNUNET_TRANSPORT_SS_DONE);
+ notify_session_monitor (session->plugin, session, GNUNET_TRANSPORT_SS_DONE);
if (NULL != session->receive_delay_task)
{
@@ -1855,22 +1832,18 @@ session_timeout (void *cls)
{
/* not actually our turn yet, but let's at least update
the monitor, it may think we're about to die ... */
- notify_session_monitor (s->plugin,
- s,
- GNUNET_TRANSPORT_SS_UPDATE);
- s->timeout_task = GNUNET_SCHEDULER_add_delayed (left,
- &session_timeout,
- s);
+ notify_session_monitor (s->plugin, s, GNUNET_TRANSPORT_SS_UPDATE);
+ s->timeout_task = GNUNET_SCHEDULER_add_delayed (left, &session_timeout, s);
return;
}
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Session %p was idle for %s, disconnecting\n",
s,
- GNUNET_STRINGS_relative_time_to_string (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
- GNUNET_YES));
+ GNUNET_STRINGS_relative_time_to_string (
+ GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
+ GNUNET_YES));
/* call session destroy function */
- tcp_plugin_disconnect_session (s->plugin,
- s);
+ tcp_plugin_disconnect_session (s->plugin, s);
}
@@ -1883,7 +1856,8 @@ static void
reschedule_session_timeout (struct GNUNET_ATS_Session *s)
{
GNUNET_assert (NULL != s->timeout_task);
- s->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
+ s->timeout =
+ GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
}
@@ -1927,46 +1901,41 @@ create_session (struct Plugin *plugin,
if (NULL != client)
{
session->client = client;
- GNUNET_SERVER_client_set_user_context (client,
- session);
+ GNUNET_SERVER_client_set_user_context (client, session);
}
session->address = GNUNET_HELLO_address_copy (address);
session->target = address->peer;
session->expecting_welcome = GNUNET_YES;
session->scope = scope;
pm = GNUNET_malloc (sizeof (struct PendingMessage) +
- sizeof (struct WelcomeMessage));
+ sizeof (struct WelcomeMessage));
pm->msg = (const char *) &pm[1];
- pm->message_size = sizeof(struct WelcomeMessage);
- GNUNET_memcpy (&pm[1],
- &plugin->my_welcome,
- sizeof(struct WelcomeMessage));
+ pm->message_size = sizeof (struct WelcomeMessage);
+ GNUNET_memcpy (&pm[1], &plugin->my_welcome, sizeof (struct WelcomeMessage));
pm->timeout = GNUNET_TIME_UNIT_FOREVER_ABS;
GNUNET_STATISTICS_update (plugin->env->stats,
gettext_noop ("# bytes currently in TCP buffers"),
- pm->message_size,
+ pm->message_size,
GNUNET_NO);
GNUNET_CONTAINER_DLL_insert (session->pending_messages_head,
session->pending_messages_tail,
pm);
session->msgs_in_queue++;
session->bytes_in_queue += pm->message_size;
- session->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
- session->timeout_task = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
- &session_timeout,
- session);
- notify_session_monitor (session->plugin,
- session,
- GNUNET_TRANSPORT_SS_INIT);
+ session->timeout =
+ GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
+ session->timeout_task =
+ GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
+ &session_timeout,
+ session);
+ notify_session_monitor (session->plugin, session, GNUNET_TRANSPORT_SS_INIT);
if (GNUNET_YES != is_nat)
{
GNUNET_STATISTICS_update (plugin->env->stats,
gettext_noop ("# TCP sessions active"),
1,
GNUNET_NO);
- notify_session_monitor (session->plugin,
- session,
- GNUNET_TRANSPORT_SS_UP);
+ notify_session_monitor (session->plugin, session, GNUNET_TRANSPORT_SS_UP);
}
else
{
@@ -2000,9 +1969,7 @@ process_pending_messages (struct GNUNET_ATS_Session *session);
* @return number of bytes written to @a buf
*/
static size_t
-do_transmit (void *cls,
- size_t size,
- void *buf)
+do_transmit (void *cls, size_t size, void *buf)
{
struct GNUNET_ATS_Session *session = cls;
struct GNUNET_PeerIdentity pid;
@@ -2026,8 +1993,8 @@ do_transmit (void *cls,
tl = NULL;
ret = 0;
now = GNUNET_TIME_absolute_get ();
- while ( (NULL != (pos = session->pending_messages_head)) &&
- (pos->timeout.abs_value_us <= now.abs_value_us) )
+ while ((NULL != (pos = session->pending_messages_head)) &&
+ (pos->timeout.abs_value_us <= now.abs_value_us))
{
GNUNET_CONTAINER_DLL_remove (session->pending_messages_head,
session->pending_messages_tail,
@@ -2041,10 +2008,7 @@ do_transmit (void *cls,
pos->message_size,
GNUNET_i2s (&session->target));
ret += pos->message_size;
- GNUNET_CONTAINER_DLL_insert_after (hd,
- tl,
- tl,
- pos);
+ GNUNET_CONTAINER_DLL_insert_after (hd, tl, tl, pos);
}
/* do this call before callbacks (so that if callbacks destroy
* session, they have a chance to cancel actions done by this
@@ -2055,9 +2019,7 @@ do_transmit (void *cls,
* the callbacks may abort the session */
while (NULL != (pos = hd))
{
- GNUNET_CONTAINER_DLL_remove (hd,
- tl,
- pos);
+ GNUNET_CONTAINER_DLL_remove (hd, tl, pos);
if (NULL != pos->transmit_cont)
pos->transmit_cont (pos->transmit_cont_cls,
&pid,
@@ -2067,10 +2029,12 @@ do_transmit (void *cls,
GNUNET_free (pos);
}
GNUNET_STATISTICS_update (plugin->env->stats,
- gettext_noop ("# bytes currently in TCP buffers"), -(int64_t) ret,
+ gettext_noop ("# bytes currently in TCP buffers"),
+ -(int64_t) ret,
GNUNET_NO);
GNUNET_STATISTICS_update (plugin->env->stats,
- gettext_noop ("# bytes discarded by TCP (timeout)"),
+ gettext_noop (
+ "# bytes discarded by TCP (timeout)"),
ret,
GNUNET_NO);
if (0 < ret)
@@ -2095,7 +2059,7 @@ do_transmit (void *cls,
session->msgs_in_queue--;
GNUNET_assert (pos->message_size <= session->bytes_in_queue);
session->bytes_in_queue -= pos->message_size;
- GNUNET_assert(size >= pos->message_size);
+ GNUNET_assert (size >= pos->message_size);
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Transmitting message of type %u size %u to peer %s at %s\n",
ntohs (((struct GNUNET_MessageHeader *) pos->msg)->type),
@@ -2105,19 +2069,13 @@ do_transmit (void *cls,
session->address->address,
session->address->address_length));
/* FIXME: this GNUNET_memcpy can be up to 7% of our total runtime */
- GNUNET_memcpy (cbuf,
- pos->msg,
- pos->message_size);
+ GNUNET_memcpy (cbuf, pos->msg, pos->message_size);
cbuf += pos->message_size;
ret += pos->message_size;
size -= pos->message_size;
- GNUNET_CONTAINER_DLL_insert_tail (hd,
- tl,
- pos);
+ GNUNET_CONTAINER_DLL_insert_tail (hd, tl, pos);
}
- notify_session_monitor (session->plugin,
- session,
- GNUNET_TRANSPORT_SS_UPDATE);
+ notify_session_monitor (session->plugin, session, GNUNET_TRANSPORT_SS_UPDATE);
/* schedule 'continuation' before callbacks so that callbacks that
* cancel everything don't cause us to use a session that no longer
* exists... */
@@ -2141,7 +2099,7 @@ do_transmit (void *cls,
GNUNET_assert (NULL == tl);
GNUNET_STATISTICS_update (plugin->env->stats,
gettext_noop ("# bytes currently in TCP buffers"),
- - (int64_t) ret,
+ -(int64_t) ret,
GNUNET_NO);
GNUNET_STATISTICS_update (plugin->env->stats,
gettext_noop ("# bytes transmitted via TCP"),
@@ -2168,12 +2126,13 @@ process_pending_messages (struct GNUNET_ATS_Session *session)
if (NULL == (pm = session->pending_messages_head))
return;
- session->transmit_handle
- = GNUNET_SERVER_notify_transmit_ready (session->client,
- pm->message_size,
- GNUNET_TIME_absolute_get_remaining (pm->timeout),
- &do_transmit,
- session);
+ session->transmit_handle =
+ GNUNET_SERVER_notify_transmit_ready (session->client,
+ pm->message_size,
+ GNUNET_TIME_absolute_get_remaining (
+ pm->timeout),
+ &do_transmit,
+ session);
}
@@ -2214,7 +2173,7 @@ tcp_plugin_send (void *cls,
GNUNET_TRANSPORT_TransmitContinuation cont,
void *cont_cls)
{
- struct Plugin * plugin = cls;
+ struct Plugin *plugin = cls;
struct PendingMessage *pm;
/* create new message entry */
@@ -2265,7 +2224,8 @@ tcp_plugin_send (void *cls,
"This NAT WAIT session for peer `%s' is not yet ready!\n",
GNUNET_i2s (&session->target));
GNUNET_STATISTICS_update (plugin->env->stats,
- gettext_noop ("# bytes currently in TCP buffers"), msgbuf_size,
+ gettext_noop ("# bytes currently in TCP buffers"),
+ msgbuf_size,
GNUNET_NO);
/* append pm to pending_messages list */
GNUNET_CONTAINER_DLL_insert_tail (session->pending_messages_head,
@@ -2278,15 +2238,9 @@ tcp_plugin_send (void *cls,
GNUNET_TRANSPORT_SS_HANDSHAKE);
return msgbuf_size;
}
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "Invalid session %p\n",
- session);
+ LOG (GNUNET_ERROR_TYPE_ERROR, "Invalid session %p\n", session);
if (NULL != cont)
- cont (cont_cls,
- &session->target,
- GNUNET_SYSERR,
- pm->message_size,
- 0);
+ cont (cont_cls, &session->target, GNUNET_SYSERR, pm->message_size, 0);
GNUNET_break (0);
GNUNET_free (pm);
return GNUNET_SYSERR; /* session does not exist here */
@@ -2307,7 +2261,6 @@ struct GNUNET_ATS_SessionItCtx
* Where to store the session (if we found it).
*/
struct GNUNET_ATS_Session *result;
-
};
@@ -2327,9 +2280,7 @@ session_lookup_it (void *cls,
struct GNUNET_ATS_SessionItCtx *si_ctx = cls;
struct GNUNET_ATS_Session *session = value;
- if (0 !=
- GNUNET_HELLO_address_cmp (si_ctx->address,
- session->address))
+ if (0 != GNUNET_HELLO_address_cmp (si_ctx->address, session->address))
return GNUNET_YES;
si_ctx->result = session;
return GNUNET_NO;
@@ -2353,8 +2304,7 @@ nat_connect_timeout (void *cls)
tcp_plugin_address_to_string (session->plugin,
session->address->address,
session->address->address_length));
- tcp_plugin_disconnect_session (session->plugin,
- session);
+ tcp_plugin_disconnect_session (session->plugin, session);
}
@@ -2389,8 +2339,7 @@ delayed_done (void *cls)
session->receive_delay_task = NULL;
reschedule_session_timeout (session);
- GNUNET_SERVER_receive_done (session->client,
- GNUNET_OK);
+ GNUNET_SERVER_receive_done (session->client, GNUNET_OK);
}
@@ -2414,13 +2363,11 @@ tcp_plugin_update_inbound_delay (void *cls,
return;
LOG (GNUNET_ERROR_TYPE_DEBUG,
"New inbound delay %s\n",
- GNUNET_STRINGS_relative_time_to_string (delay,
- GNUNET_NO));
+ GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_NO));
session->receive_delay = GNUNET_TIME_relative_to_absolute (delay);
GNUNET_SCHEDULER_cancel (session->receive_delay_task);
- session->receive_delay_task = GNUNET_SCHEDULER_add_delayed (delay,
- &delayed_done,
- session);
+ session->receive_delay_task =
+ GNUNET_SCHEDULER_add_delayed (delay, &delayed_done, session);
}
@@ -2434,8 +2381,7 @@ tcp_plugin_update_inbound_delay (void *cls,
* @return the session if the address is valid, NULL otherwise
*/
static struct GNUNET_ATS_Session *
-tcp_plugin_get_session (void *cls,
- const struct GNUNET_HELLO_Address *address)
+tcp_plugin_get_session (void *cls, const struct GNUNET_HELLO_Address *address)
{
struct Plugin *plugin = cls;
struct GNUNET_ATS_Session *session = NULL;
@@ -2471,9 +2417,8 @@ tcp_plugin_get_session (void *cls,
}
/* look for existing session */
- if (GNUNET_YES ==
- GNUNET_CONTAINER_multipeermap_contains (plugin->sessionmap,
- &address->peer))
+ if (GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (plugin->sessionmap,
+ &address->peer))
{
struct GNUNET_ATS_SessionItCtx si_ctx;
@@ -2482,7 +2427,7 @@ tcp_plugin_get_session (void *cls,
GNUNET_CONTAINER_multipeermap_get_multiple (plugin->sessionmap,
&address->peer,
&session_lookup_it,
- &si_ctx);
+ &si_ctx);
if (NULL != si_ctx.result)
{
session = si_ctx.result;
@@ -2503,13 +2448,13 @@ tcp_plugin_get_session (void *cls,
peer pair at the same time. */
}
- if (addrlen == sizeof(struct IPv6TcpAddress))
+ if (addrlen == sizeof (struct IPv6TcpAddress))
{
GNUNET_assert (NULL != address->address); /* make static analysis happy */
t6 = address->address;
options = t6->options;
af = AF_INET6;
- memset (&a6, 0, sizeof(a6));
+ memset (&a6, 0, sizeof (a6));
#if HAVE_SOCKADDR_IN_SIN_LEN
a6.sin6_len = sizeof (a6);
#endif
@@ -2517,17 +2462,17 @@ tcp_plugin_get_session (void *cls,
a6.sin6_port = t6->t6_port;
if (t6->t6_port == 0)
is_natd = GNUNET_YES;
- GNUNET_memcpy (&a6.sin6_addr, &t6->ipv6_addr, sizeof(struct in6_addr));
+ GNUNET_memcpy (&a6.sin6_addr, &t6->ipv6_addr, sizeof (struct in6_addr));
sb = &a6;
- sbs = sizeof(a6);
+ sbs = sizeof (a6);
}
- else if (addrlen == sizeof(struct IPv4TcpAddress))
+ else if (addrlen == sizeof (struct IPv4TcpAddress))
{
- GNUNET_assert(NULL != address->address); /* make static analysis happy */
+ GNUNET_assert (NULL != address->address); /* make static analysis happy */
t4 = address->address;
options = t4->options;
af = AF_INET;
- memset (&a4, 0, sizeof(a4));
+ memset (&a4, 0, sizeof (a4));
#if HAVE_SOCKADDR_IN_SIN_LEN
a4.sin_len = sizeof (a4);
#endif
@@ -2537,24 +2482,22 @@ tcp_plugin_get_session (void *cls,
is_natd = GNUNET_YES;
a4.sin_addr.s_addr = t4->ipv4_addr;
sb = &a4;
- sbs = sizeof(a4);
+ sbs = sizeof (a4);
}
else
{
- GNUNET_STATISTICS_update (plugin->env->stats,
- gettext_noop ("# requests to create session with invalid address"),
- 1,
- GNUNET_NO);
+ GNUNET_STATISTICS_update (
+ plugin->env->stats,
+ gettext_noop ("# requests to create session with invalid address"),
+ 1,
+ GNUNET_NO);
return NULL;
}
- net_type = plugin->env->get_address_type (plugin->env->cls,
- sb,
- sbs);
+ net_type = plugin->env->get_address_type (plugin->env->cls, sb, sbs);
GNUNET_break (net_type != GNUNET_NT_UNSPECIFIED);
- if ( (is_natd == GNUNET_YES) &&
- (addrlen == sizeof(struct IPv6TcpAddress)) )
+ if ((is_natd == GNUNET_YES) && (addrlen == sizeof (struct IPv6TcpAddress)))
{
/* NAT client only works with IPv4 addresses */
return NULL;
@@ -2566,62 +2509,51 @@ tcp_plugin_get_session (void *cls,
return NULL;
}
- if ( (is_natd == GNUNET_YES) &&
- (GNUNET_YES ==
- GNUNET_CONTAINER_multipeermap_contains (plugin->nat_wait_conns,
- &address->peer)))
+ if ((is_natd == GNUNET_YES) &&
+ (GNUNET_YES ==
+ GNUNET_CONTAINER_multipeermap_contains (plugin->nat_wait_conns,
+ &address->peer)))
{
/* Only do one NAT punch attempt per peer identity */
return NULL;
}
- if ( (is_natd == GNUNET_YES) &&
- (NULL != plugin->nat) &&
- (GNUNET_NO ==
- GNUNET_CONTAINER_multipeermap_contains (plugin->nat_wait_conns,
- &address->peer)))
+ if ((is_natd == GNUNET_YES) && (NULL != plugin->nat) &&
+ (GNUNET_NO ==
+ GNUNET_CONTAINER_multipeermap_contains (plugin->nat_wait_conns,
+ &address->peer)))
{
struct sockaddr_in local_sa;
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Found valid IPv4 NAT address (creating session)!\n");
- session = create_session (plugin,
- address,
- net_type,
- NULL,
- GNUNET_YES);
- session->nat_connection_timeout = GNUNET_SCHEDULER_add_delayed (NAT_TIMEOUT,
- &nat_connect_timeout,
- session);
+ session = create_session (plugin, address, net_type, NULL, GNUNET_YES);
+ session->nat_connection_timeout =
+ GNUNET_SCHEDULER_add_delayed (NAT_TIMEOUT, &nat_connect_timeout, session);
GNUNET_assert (GNUNET_OK ==
- GNUNET_CONTAINER_multipeermap_put (plugin->nat_wait_conns,
- &session->target,
- session,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
+ GNUNET_CONTAINER_multipeermap_put (
+ plugin->nat_wait_conns,
+ &session->target,
+ session,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Created NAT WAIT connection to `%s' at `%s'\n",
GNUNET_i2s (&session->target),
GNUNET_a2s (sb, sbs));
- memset (&local_sa,
- 0,
- sizeof (local_sa));
+ memset (&local_sa, 0, sizeof (local_sa));
local_sa.sin_family = AF_INET;
local_sa.sin_port = htons (plugin->open_port);
/* We leave sin_address at 0, let the kernel figure it out,
even if our bind() is more specific. (May want to reconsider
later.) */
- if (GNUNET_OK ==
- GNUNET_NAT_request_reversal (plugin->nat,
- &local_sa,
- &a4))
+ if (GNUNET_OK == GNUNET_NAT_request_reversal (plugin->nat, &local_sa, &a4))
return session;
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Running NAT client for `%s' at `%s' failed\n",
- GNUNET_i2s (&session->target),
- GNUNET_a2s (sb, sbs));
- tcp_plugin_disconnect_session (plugin,
- session);
+ "Running NAT client for `%s' at `%s' failed\n",
+ GNUNET_i2s (&session->target),
+ GNUNET_a2s (sb, sbs));
+ tcp_plugin_disconnect_session (plugin, session);
return NULL;
}
@@ -2638,22 +2570,22 @@ tcp_plugin_get_session (void *cls,
}
else
{
- if ( (GNUNET_OK !=
- GNUNET_NETWORK_socket_setsockopt (s,
- IPPROTO_TCP,
- TCP_STEALTH,
- &session->target,
- sizeof (struct GNUNET_PeerIdentity))) ||
- (GNUNET_OK !=
- GNUNET_NETWORK_socket_setsockopt (s,
- IPPROTO_TCP,
- TCP_STEALTH_INTEGRITY,
- &plugin->my_welcome,
- sizeof (struct WelcomeMessage))) )
+ if ((GNUNET_OK !=
+ GNUNET_NETWORK_socket_setsockopt (s,
+ IPPROTO_TCP,
+ TCP_STEALTH,
+ &session->target,
+ sizeof (
+ struct GNUNET_PeerIdentity))) ||
+ (GNUNET_OK !=
+ GNUNET_NETWORK_socket_setsockopt (s,
+ IPPROTO_TCP,
+ TCP_STEALTH_INTEGRITY,
+ &plugin->my_welcome,
+ sizeof (struct WelcomeMessage))))
{
/* TCP STEALTH not supported by kernel */
- GNUNET_break (GNUNET_OK ==
- GNUNET_NETWORK_socket_close (s));
+ GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (s));
sa = NULL;
}
else
@@ -2685,13 +2617,13 @@ tcp_plugin_get_session (void *cls,
session = create_session (plugin,
address,
net_type,
- GNUNET_SERVER_connect_socket (plugin->server,
- sa),
+ GNUNET_SERVER_connect_socket (plugin->server, sa),
GNUNET_NO);
- (void) GNUNET_CONTAINER_multipeermap_put (plugin->sessionmap,
- &session->target,
- session,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
+ (void) GNUNET_CONTAINER_multipeermap_put (
+ plugin->sessionmap,
+ &session->target,
+ session,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
/* Send TCP Welcome */
process_pending_messages (session);
@@ -2718,11 +2650,11 @@ session_disconnect_it (void *cls,
struct GNUNET_ATS_Session *session = value;
GNUNET_STATISTICS_update (session->plugin->env->stats,
- gettext_noop ("# transport-service disconnect requests for TCP"),
+ gettext_noop (
+ "# transport-service disconnect requests for TCP"),
1,
GNUNET_NO);
- tcp_plugin_disconnect_session (plugin,
- session);
+ tcp_plugin_disconnect_session (plugin, session);
return GNUNET_YES;
}
@@ -2744,8 +2676,7 @@ session_disconnect_it (void *cls,
* to be cancelled
*/
static void
-tcp_plugin_disconnect (void *cls,
- const struct GNUNET_PeerIdentity *target)
+tcp_plugin_disconnect (void *cls, const struct GNUNET_PeerIdentity *target)
{
struct Plugin *plugin = cls;
@@ -2774,8 +2705,7 @@ tcp_plugin_disconnect (void *cls,
* @param hostname hostname part of the address
*/
static void
-append_port (void *cls,
- const char *hostname)
+append_port (void *cls, const char *hostname)
{
struct PrettyPrinterContext *ppc = cls;
struct Plugin *plugin = ppc->plugin;
@@ -2791,9 +2721,7 @@ append_port (void *cls,
GNUNET_CONTAINER_DLL_remove (plugin->ppc_dll_head,
plugin->ppc_dll_tail,
ppc);
- ppc->asc (ppc->asc_cls,
- NULL,
- GNUNET_OK);
+ ppc->asc (ppc->asc_cls, NULL, GNUNET_OK);
GNUNET_free (ppc);
return;
}
@@ -2811,9 +2739,7 @@ append_port (void *cls,
ppc->options,
hostname,
ppc->port);
- ppc->asc (ppc->asc_cls,
- ret,
- GNUNET_OK);
+ ppc->asc (ppc->asc_cls, ret, GNUNET_OK);
GNUNET_free (ret);
}
@@ -2852,35 +2778,35 @@ tcp_plugin_address_pretty_printer (void *cls,
uint16_t port;
uint32_t options;
- if (sizeof(struct IPv6TcpAddress) == addrlen)
+ if (sizeof (struct IPv6TcpAddress) == addrlen)
{
t6 = addr;
- memset (&a6, 0, sizeof(a6));
+ memset (&a6, 0, sizeof (a6));
a6.sin6_family = AF_INET6;
a6.sin6_port = t6->t6_port;
- GNUNET_memcpy (&a6.sin6_addr, &t6->ipv6_addr, sizeof(struct in6_addr));
+ GNUNET_memcpy (&a6.sin6_addr, &t6->ipv6_addr, sizeof (struct in6_addr));
port = ntohs (t6->t6_port);
options = ntohl (t6->options);
sb = &a6;
- sbs = sizeof(a6);
+ sbs = sizeof (a6);
}
- else if (sizeof(struct IPv4TcpAddress) == addrlen)
+ else if (sizeof (struct IPv4TcpAddress) == addrlen)
{
t4 = addr;
- memset (&a4, 0, sizeof(a4));
+ memset (&a4, 0, sizeof (a4));
a4.sin_family = AF_INET;
a4.sin_port = t4->t4_port;
a4.sin_addr.s_addr = t4->ipv4_addr;
port = ntohs (t4->t4_port);
options = ntohl (t4->options);
sb = &a4;
- sbs = sizeof(a4);
+ sbs = sizeof (a4);
}
else
{
/* invalid address */
LOG (GNUNET_ERROR_TYPE_WARNING,
- _("Unexpected address length: %u bytes\n"),
+ _ ("Unexpected address length: %u bytes\n"),
(unsigned int) addrlen);
asc (asc_cls, NULL, GNUNET_SYSERR);
asc (asc_cls, NULL, GNUNET_OK);
@@ -2888,7 +2814,7 @@ tcp_plugin_address_pretty_printer (void *cls,
}
ppc = GNUNET_new (struct PrettyPrinterContext);
ppc->plugin = plugin;
- if (addrlen == sizeof(struct IPv6TcpAddress))
+ if (addrlen == sizeof (struct IPv6TcpAddress))
ppc->ipv6 = GNUNET_YES;
else
ppc->ipv6 = GNUNET_NO;
@@ -2896,23 +2822,20 @@ tcp_plugin_address_pretty_printer (void *cls,
ppc->asc_cls = asc_cls;
ppc->port = port;
ppc->options = options;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Starting DNS reverse lookup\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting DNS reverse lookup\n");
ppc->resolver_handle = GNUNET_RESOLVER_hostname_get (sb,
sbs,
! numeric,
timeout,
&append_port,
- ppc);
+ ppc);
if (NULL == ppc->resolver_handle)
{
GNUNET_break (0);
GNUNET_free (ppc);
return;
}
- GNUNET_CONTAINER_DLL_insert (plugin->ppc_dll_head,
- plugin->ppc_dll_tail,
- ppc);
+ GNUNET_CONTAINER_DLL_insert (plugin->ppc_dll_head, plugin->ppc_dll_tail, ppc);
}
@@ -2932,29 +2855,25 @@ tcp_plugin_address_pretty_printer (void *cls,
* and transport, #GNUNET_SYSERR if not
*/
static int
-tcp_plugin_check_address (void *cls,
- const void *addr,
- size_t addrlen)
+tcp_plugin_check_address (void *cls, const void *addr, size_t addrlen)
{
struct Plugin *plugin = cls;
const struct IPv4TcpAddress *v4;
const struct IPv6TcpAddress *v6;
- if ( (addrlen != sizeof(struct IPv4TcpAddress)) &&
- (addrlen != sizeof(struct IPv6TcpAddress)) )
+ if ((addrlen != sizeof (struct IPv4TcpAddress)) &&
+ (addrlen != sizeof (struct IPv6TcpAddress)))
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
- if (addrlen == sizeof(struct IPv4TcpAddress))
+ if (addrlen == sizeof (struct IPv4TcpAddress))
{
struct sockaddr_in s4;
v4 = (const struct IPv4TcpAddress *) addr;
- if (0 != memcmp (&v4->options,
- &plugin->myoptions,
- sizeof(uint32_t)))
+ if (0 != memcmp (&v4->options, &plugin->myoptions, sizeof (uint32_t)))
{
GNUNET_break (0);
return GNUNET_SYSERR;
@@ -2968,9 +2887,7 @@ tcp_plugin_check_address (void *cls,
s4.sin_addr.s_addr = v4->ipv4_addr;
if (GNUNET_OK !=
- GNUNET_NAT_test_address (plugin->nat,
- &s4,
- sizeof (struct sockaddr_in)))
+ GNUNET_NAT_test_address (plugin->nat, &s4, sizeof (struct sockaddr_in)))
return GNUNET_SYSERR;
}
else
@@ -2983,9 +2900,7 @@ tcp_plugin_check_address (void *cls,
GNUNET_break_op (0);
return GNUNET_SYSERR;
}
- if (0 != memcmp (&v6->options,
- &plugin->myoptions,
- sizeof (uint32_t)))
+ if (0 != memcmp (&v6->options, &plugin->myoptions, sizeof (uint32_t)))
{
GNUNET_break (0);
return GNUNET_SYSERR;
@@ -2998,10 +2913,9 @@ tcp_plugin_check_address (void *cls,
s6.sin6_port = v6->t6_port;
s6.sin6_addr = v6->ipv6_addr;
- if (GNUNET_OK !=
- GNUNET_NAT_test_address (plugin->nat,
- &s6,
- sizeof(struct sockaddr_in6)))
+ if (GNUNET_OK != GNUNET_NAT_test_address (plugin->nat,
+ &s6,
+ sizeof (struct sockaddr_in6)))
return GNUNET_SYSERR;
}
return GNUNET_OK;
@@ -3032,29 +2946,27 @@ handle_tcp_nat_probe (void *cls,
const struct sockaddr_in *s4;
const struct sockaddr_in6 *s6;
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Received NAT probe\n");
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Received NAT probe\n");
/* We have received a TCP NAT probe, meaning we (hopefully) initiated
* a connection to this peer by running gnunet-nat-client. This peer
* received the punch message and now wants us to use the new connection
* as the default for that peer. Do so and then send a WELCOME message
* so we can really be connected!
*/
- if (ntohs (message->size) != sizeof(struct TCP_NAT_ProbeMessage))
+ if (ntohs (message->size) != sizeof (struct TCP_NAT_ProbeMessage))
{
- GNUNET_break_op(0);
- GNUNET_SERVER_receive_done (client,
- GNUNET_SYSERR);
+ GNUNET_break_op (0);
+ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
tcp_nat_probe = (const struct TCP_NAT_ProbeMessage *) message;
- if (0 == memcmp (&tcp_nat_probe->clientIdentity, plugin->env->my_identity,
- sizeof(struct GNUNET_PeerIdentity)))
+ if (0 == memcmp (&tcp_nat_probe->clientIdentity,
+ plugin->env->my_identity,
+ sizeof (struct GNUNET_PeerIdentity)))
{
/* refuse connections from ourselves */
- GNUNET_SERVER_receive_done (client,
- GNUNET_SYSERR);
+ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
@@ -3062,14 +2974,11 @@ handle_tcp_nat_probe (void *cls,
&tcp_nat_probe->clientIdentity);
if (NULL == session)
{
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Did NOT find session for NAT probe!\n");
- GNUNET_SERVER_receive_done (client,
- GNUNET_OK);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Did NOT find session for NAT probe!\n");
+ GNUNET_SERVER_receive_done (client, GNUNET_OK);
return;
}
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Found session for NAT probe!\n");
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Found session for NAT probe!\n");
if (NULL != session->nat_connection_timeout)
{
@@ -3077,28 +2986,24 @@ handle_tcp_nat_probe (void *cls,
session->nat_connection_timeout = NULL;
}
- if (GNUNET_OK !=
- GNUNET_SERVER_client_get_address (client,
- &vaddr,
- &alen))
+ if (GNUNET_OK != GNUNET_SERVER_client_get_address (client, &vaddr, &alen))
{
- GNUNET_break(0);
- GNUNET_SERVER_receive_done (client,
- GNUNET_SYSERR);
- tcp_plugin_disconnect_session (plugin,
- session);
+ GNUNET_break (0);
+ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+ tcp_plugin_disconnect_session (plugin, session);
return;
}
- GNUNET_assert (GNUNET_YES ==
- GNUNET_CONTAINER_multipeermap_remove (plugin->nat_wait_conns,
- &tcp_nat_probe->clientIdentity,
- session));
- GNUNET_SERVER_client_set_user_context (client,
- session);
- (void) GNUNET_CONTAINER_multipeermap_put (plugin->sessionmap,
- &session->target,
- session,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
+ GNUNET_assert (
+ GNUNET_YES ==
+ GNUNET_CONTAINER_multipeermap_remove (plugin->nat_wait_conns,
+ &tcp_nat_probe->clientIdentity,
+ session));
+ GNUNET_SERVER_client_set_user_context (client, session);
+ (void) GNUNET_CONTAINER_multipeermap_put (
+ plugin->sessionmap,
+ &session->target,
+ session,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
session->last_activity = GNUNET_TIME_absolute_get ();
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Found address `%s' for incoming connection\n",
@@ -3111,45 +3016,43 @@ handle_tcp_nat_probe (void *cls,
t4->options = htonl (TCP_OPTIONS_NONE);
t4->t4_port = s4->sin_port;
t4->ipv4_addr = s4->sin_addr.s_addr;
- session->address = GNUNET_HELLO_address_allocate (&tcp_nat_probe->clientIdentity,
- PLUGIN_NAME,
- &t4,
- sizeof(struct IPv4TcpAddress),
- GNUNET_HELLO_ADDRESS_INFO_NONE);
+ session->address =
+ GNUNET_HELLO_address_allocate (&tcp_nat_probe->clientIdentity,
+ PLUGIN_NAME,
+ &t4,
+ sizeof (struct IPv4TcpAddress),
+ GNUNET_HELLO_ADDRESS_INFO_NONE);
break;
case AF_INET6:
s6 = vaddr;
t6 = GNUNET_new (struct IPv6TcpAddress);
t6->options = htonl (TCP_OPTIONS_NONE);
t6->t6_port = s6->sin6_port;
- GNUNET_memcpy (&t6->ipv6_addr, &s6->sin6_addr, sizeof(struct in6_addr));
- session->address = GNUNET_HELLO_address_allocate (&tcp_nat_probe->clientIdentity,
- PLUGIN_NAME,
- &t6,
- sizeof(struct IPv6TcpAddress),
- GNUNET_HELLO_ADDRESS_INFO_NONE);
+ GNUNET_memcpy (&t6->ipv6_addr, &s6->sin6_addr, sizeof (struct in6_addr));
+ session->address =
+ GNUNET_HELLO_address_allocate (&tcp_nat_probe->clientIdentity,
+ PLUGIN_NAME,
+ &t6,
+ sizeof (struct IPv6TcpAddress),
+ GNUNET_HELLO_ADDRESS_INFO_NONE);
break;
default:
- GNUNET_break_op(0);
- LOG(GNUNET_ERROR_TYPE_DEBUG,
- "Bad address for incoming connection!\n");
- GNUNET_free(vaddr);
- GNUNET_SERVER_receive_done (client,
- GNUNET_SYSERR);
- tcp_plugin_disconnect_session (plugin,
- session);
+ GNUNET_break_op (0);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Bad address for incoming connection!\n");
+ GNUNET_free (vaddr);
+ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+ tcp_plugin_disconnect_session (plugin, session);
return;
}
GNUNET_free (vaddr);
GNUNET_break (NULL == session->client);
session->client = client;
GNUNET_STATISTICS_update (plugin->env->stats,
- gettext_noop ("# TCP sessions active"),
- 1,
- GNUNET_NO);
+ gettext_noop ("# TCP sessions active"),
+ 1,
+ GNUNET_NO);
process_pending_messages (session);
- GNUNET_SERVER_receive_done (client,
- GNUNET_OK);
+ GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
@@ -3179,13 +3082,10 @@ handle_tcp_welcome (void *cls,
if (0 == memcmp (&wm->clientIdentity,
plugin->env->my_identity,
- sizeof(struct GNUNET_PeerIdentity)))
+ sizeof (struct GNUNET_PeerIdentity)))
{
/* refuse connections from ourselves */
- if (GNUNET_OK ==
- GNUNET_SERVER_client_get_address (client,
- &vaddr,
- &alen))
+ if (GNUNET_OK == GNUNET_SERVER_client_get_address (client, &vaddr, &alen))
{
LOG (GNUNET_ERROR_TYPE_INFO,
"Received WELCOME message from my own identity `%s' on address `%s'\n",
@@ -3193,34 +3093,26 @@ handle_tcp_welcome (void *cls,
GNUNET_a2s (vaddr, alen));
GNUNET_free (vaddr);
}
- GNUNET_SERVER_receive_done (client,
- GNUNET_SYSERR);
+ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
- if (GNUNET_OK ==
- GNUNET_SERVER_client_get_address (client,
- &vaddr,
- &alen))
+ if (GNUNET_OK == GNUNET_SERVER_client_get_address (client, &vaddr, &alen))
{
- LOG(GNUNET_ERROR_TYPE_DEBUG,
- "Received WELCOME message from `%s' on address `%s'\n",
- GNUNET_i2s (&wm->clientIdentity),
- GNUNET_a2s (vaddr, alen));
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Received WELCOME message from `%s' on address `%s'\n",
+ GNUNET_i2s (&wm->clientIdentity),
+ GNUNET_a2s (vaddr, alen));
GNUNET_free (vaddr);
}
GNUNET_STATISTICS_update (plugin->env->stats,
gettext_noop ("# TCP WELCOME messages received"),
1,
GNUNET_NO);
- session = lookup_session_by_client (plugin,
- client);
+ session = lookup_session_by_client (plugin, client);
if (NULL != session)
{
- if (GNUNET_OK ==
- GNUNET_SERVER_client_get_address (client,
- &vaddr,
- &alen))
+ if (GNUNET_OK == GNUNET_SERVER_client_get_address (client, &vaddr, &alen))
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Found existing session %p for peer `%s'\n",
@@ -3231,41 +3123,41 @@ handle_tcp_welcome (void *cls,
}
else
{
- if (GNUNET_OK ==
- GNUNET_SERVER_client_get_address (client, &vaddr, &alen))
+ if (GNUNET_OK == GNUNET_SERVER_client_get_address (client, &vaddr, &alen))
{
- if (alen == sizeof(struct sockaddr_in))
+ if (alen == sizeof (struct sockaddr_in))
{
s4 = vaddr;
memset (&t4, '\0', sizeof (t4));
t4.options = htonl (TCP_OPTIONS_NONE);
t4.t4_port = s4->sin_port;
t4.ipv4_addr = s4->sin_addr.s_addr;
- address = GNUNET_HELLO_address_allocate (&wm->clientIdentity,
- PLUGIN_NAME,
- &t4,
- sizeof(t4),
- GNUNET_HELLO_ADDRESS_INFO_INBOUND);
+ address =
+ GNUNET_HELLO_address_allocate (&wm->clientIdentity,
+ PLUGIN_NAME,
+ &t4,
+ sizeof (t4),
+ GNUNET_HELLO_ADDRESS_INFO_INBOUND);
}
- else if (alen == sizeof(struct sockaddr_in6))
+ else if (alen == sizeof (struct sockaddr_in6))
{
s6 = vaddr;
memset (&t6, '\0', sizeof (t6));
t6.options = htonl (TCP_OPTIONS_NONE);
t6.t6_port = s6->sin6_port;
- GNUNET_memcpy (&t6.ipv6_addr, &s6->sin6_addr, sizeof(struct in6_addr));
- address = GNUNET_HELLO_address_allocate (&wm->clientIdentity,
- PLUGIN_NAME,
- &t6,
- sizeof (t6),
- GNUNET_HELLO_ADDRESS_INFO_INBOUND);
+ GNUNET_memcpy (&t6.ipv6_addr, &s6->sin6_addr, sizeof (struct in6_addr));
+ address =
+ GNUNET_HELLO_address_allocate (&wm->clientIdentity,
+ PLUGIN_NAME,
+ &t6,
+ sizeof (t6),
+ GNUNET_HELLO_ADDRESS_INFO_INBOUND);
}
else
{
GNUNET_break (0);
GNUNET_free_non_null (vaddr);
- GNUNET_SERVER_receive_done (client,
- GNUNET_SYSERR);
+ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
session = create_session (plugin,
@@ -3281,17 +3173,19 @@ handle_tcp_welcome (void *cls,
"Creating new%s session %p for peer `%s' client %p\n",
GNUNET_HELLO_address_check_option (session->address,
GNUNET_HELLO_ADDRESS_INFO_INBOUND)
- ? " inbound" : "",
+ ? " inbound"
+ : "",
session,
tcp_plugin_address_to_string (plugin,
session->address->address,
session->address->address_length),
client);
GNUNET_free (vaddr);
- (void) GNUNET_CONTAINER_multipeermap_put (plugin->sessionmap,
- &session->target,
- session,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
+ (void) GNUNET_CONTAINER_multipeermap_put (
+ plugin->sessionmap,
+ &session->target,
+ session,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
/* Notify transport and ATS about new session */
plugin->env->session_start (plugin->env->cls,
session->address,
@@ -3300,11 +3194,10 @@ handle_tcp_welcome (void *cls,
}
else
{
- LOG(GNUNET_ERROR_TYPE_DEBUG,
- "Did not obtain TCP socket address for incoming connection\n");
- GNUNET_break(0);
- GNUNET_SERVER_receive_done (client,
- GNUNET_SYSERR);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Did not obtain TCP socket address for incoming connection\n");
+ GNUNET_break (0);
+ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
}
@@ -3312,8 +3205,7 @@ handle_tcp_welcome (void *cls,
if (GNUNET_YES != session->expecting_welcome)
{
GNUNET_break_op (0);
- GNUNET_SERVER_receive_done (client,
- GNUNET_SYSERR);
+ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
return;
}
session->last_activity = GNUNET_TIME_absolute_get ();
@@ -3322,8 +3214,7 @@ handle_tcp_welcome (void *cls,
process_pending_messages (session);
GNUNET_SERVER_client_set_timeout (client,
GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
- GNUNET_SERVER_receive_done (client,
- GNUNET_OK);
+ GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
@@ -3346,12 +3237,11 @@ handle_tcp_data (void *cls,
uint16_t type;
type = ntohs (message->type);
- if ( (GNUNET_MESSAGE_TYPE_TRANSPORT_TCP_WELCOME == type) ||
- (GNUNET_MESSAGE_TYPE_TRANSPORT_TCP_NAT_PROBE == type) )
+ if ((GNUNET_MESSAGE_TYPE_TRANSPORT_TCP_WELCOME == type) ||
+ (GNUNET_MESSAGE_TYPE_TRANSPORT_TCP_NAT_PROBE == type))
{
/* We don't want to propagate WELCOME and NAT Probe messages up! */
- GNUNET_SERVER_receive_done (client,
- GNUNET_OK);
+ GNUNET_SERVER_receive_done (client, GNUNET_OK);
return;
}
session = lookup_session_by_client (plugin, client);
@@ -3362,18 +3252,14 @@ handle_tcp_data (void *cls,
size_t alen;
GNUNET_assert (GNUNET_OK ==
- GNUNET_SERVER_client_get_address (client,
- &vaddr,
- &alen));
+ GNUNET_SERVER_client_get_address (client, &vaddr, &alen));
LOG (GNUNET_ERROR_TYPE_ERROR,
"Received unexpected %u bytes of type %u from `%s'\n",
(unsigned int) ntohs (message->size),
(unsigned int) ntohs (message->type),
- GNUNET_a2s (vaddr,
- alen));
- GNUNET_break_op(0);
- GNUNET_SERVER_receive_done (client,
- GNUNET_SYSERR);
+ GNUNET_a2s (vaddr, alen));
+ GNUNET_break_op (0);
+ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
GNUNET_free_non_null (vaddr);
return;
}
@@ -3383,17 +3269,14 @@ handle_tcp_data (void *cls,
void *vaddr = NULL;
size_t alen;
- GNUNET_SERVER_client_get_address (client,
- &vaddr,
- &alen);
+ GNUNET_SERVER_client_get_address (client, &vaddr, &alen);
LOG (GNUNET_ERROR_TYPE_ERROR,
"Received unexpected %u bytes of type %u from `%s'\n",
(unsigned int) ntohs (message->size),
(unsigned int) ntohs (message->type),
GNUNET_a2s (vaddr, alen));
- GNUNET_break_op(0);
- GNUNET_SERVER_receive_done (client,
- GNUNET_SYSERR);
+ GNUNET_break_op (0);
+ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
GNUNET_free_non_null (vaddr);
return;
}
@@ -3403,9 +3286,7 @@ handle_tcp_data (void *cls,
void *vaddr = NULL;
size_t alen;
- GNUNET_SERVER_client_get_address (client,
- &vaddr,
- &alen);
+ GNUNET_SERVER_client_get_address (client, &vaddr, &alen);
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Passing %u bytes of type %u from `%s' at %s to transport service.\n",
(unsigned int) ntohs (message->size),
@@ -3420,31 +3301,27 @@ handle_tcp_data (void *cls,
ntohs (message->size),
GNUNET_NO);
- GNUNET_assert (GNUNET_CONTAINER_multipeermap_contains_value (plugin->sessionmap,
- &session->target,
- session));
- delay = plugin->env->receive (plugin->env->cls,
- session->address,
- session,
- message);
+ GNUNET_assert (
+ GNUNET_CONTAINER_multipeermap_contains_value (plugin->sessionmap,
+ &session->target,
+ session));
+ delay =
+ plugin->env->receive (plugin->env->cls, session->address, session, message);
reschedule_session_timeout (session);
if (0 == delay.rel_value_us)
{
- GNUNET_SERVER_receive_done (client,
- GNUNET_OK);
+ GNUNET_SERVER_receive_done (client, GNUNET_OK);
}
else
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Throttling receiving from `%s' for %s\n",
GNUNET_i2s (&session->target),
- GNUNET_STRINGS_relative_time_to_string (delay,
- GNUNET_YES));
+ GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES));
GNUNET_SERVER_disable_receive_done_warning (client);
GNUNET_assert (NULL == session->receive_delay_task);
- session->receive_delay_task = GNUNET_SCHEDULER_add_delayed (delay,
- &delayed_done,
- session);
+ session->receive_delay_task =
+ GNUNET_SCHEDULER_add_delayed (delay, &delayed_done, session);
}
}
@@ -3458,8 +3335,7 @@ handle_tcp_data (void *cls,
* @param client identification of the client
*/
static void
-connect_notify (void *cls,
- struct GNUNET_SERVER_Client *client)
+connect_notify (void *cls, struct GNUNET_SERVER_Client *client)
{
struct Plugin *plugin = cls;
@@ -3471,18 +3347,19 @@ connect_notify (void *cls,
plugin->cur_connections,
GNUNET_NO);
GNUNET_STATISTICS_update (plugin->env->stats,
- gettext_noop ("# TCP server connect events"),
- 1,
- GNUNET_NO);
+ gettext_noop ("# TCP server connect events"),
+ 1,
+ GNUNET_NO);
if (plugin->cur_connections != plugin->max_connections)
return;
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- _("TCP connection limit reached, suspending server\n"));
+ _ ("TCP connection limit reached, suspending server\n"));
GNUNET_STATISTICS_update (plugin->env->stats,
- gettext_noop ("# TCP service suspended"),
- 1,
- GNUNET_NO);
- GNUNET_SERVER_suspend (plugin->server); /* Maximum number of connections rechead */
+ gettext_noop ("# TCP service suspended"),
+ 1,
+ GNUNET_NO);
+ GNUNET_SERVER_suspend (
+ plugin->server); /* Maximum number of connections rechead */
}
@@ -3495,8 +3372,7 @@ connect_notify (void *cls,
* @param client identification of the client
*/
static void
-disconnect_notify (void *cls,
- struct GNUNET_SERVER_Client *client)
+disconnect_notify (void *cls, struct GNUNET_SERVER_Client *client)
{
struct Plugin *plugin = cls;
struct GNUNET_ATS_Session *session;
@@ -3505,8 +3381,7 @@ disconnect_notify (void *cls,
return;
GNUNET_assert (plugin->cur_connections >= 1);
plugin->cur_connections--;
- session = lookup_session_by_client (plugin,
- client);
+ session = lookup_session_by_client (plugin, client);
if (NULL == session)
return; /* unknown, nothing to do */
LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -3529,11 +3404,11 @@ disconnect_notify (void *cls,
plugin->cur_connections,
GNUNET_NO);
GNUNET_STATISTICS_update (session->plugin->env->stats,
- gettext_noop ("# network-level TCP disconnect events"),
+ gettext_noop (
+ "# network-level TCP disconnect events"),
1,
GNUNET_NO);
- tcp_plugin_disconnect_session (plugin,
- session);
+ tcp_plugin_disconnect_session (plugin, session);
}
@@ -3546,9 +3421,7 @@ disconnect_notify (void *cls,
* @return number of bytes copied into @a buf
*/
static size_t
-notify_send_probe (void *cls,
- size_t size,
- void *buf)
+notify_send_probe (void *cls, size_t size, void *buf)
{
struct TCPProbeContext *tcp_probe_ctx = cls;
struct Plugin *plugin = tcp_probe_ctx->plugin;
@@ -3561,16 +3434,14 @@ notify_send_probe (void *cls,
if (NULL == buf)
{
GNUNET_CONNECTION_destroy (tcp_probe_ctx->sock);
- GNUNET_free(tcp_probe_ctx);
+ GNUNET_free (tcp_probe_ctx);
return 0;
}
- GNUNET_assert(size >= sizeof(tcp_probe_ctx->message));
- GNUNET_memcpy (buf,
- &tcp_probe_ctx->message,
- sizeof(tcp_probe_ctx->message));
+ GNUNET_assert (size >= sizeof (tcp_probe_ctx->message));
+ GNUNET_memcpy (buf, &tcp_probe_ctx->message, sizeof (tcp_probe_ctx->message));
GNUNET_SERVER_connect_socket (tcp_probe_ctx->plugin->server,
tcp_probe_ctx->sock);
- ret = sizeof(tcp_probe_ctx->message);
+ ret = sizeof (tcp_probe_ctx->message);
GNUNET_free (tcp_probe_ctx);
return ret;
}
@@ -3598,9 +3469,7 @@ try_connection_reversal (void *cls,
* We have received an ICMP response, ostensibly from a peer
* that wants to connect to us! Send a message to establish a connection.
*/
- sock = GNUNET_CONNECTION_create_from_sockaddr (AF_INET,
- addr,
- addrlen);
+ sock = GNUNET_CONNECTION_create_from_sockaddr (AF_INET, addr, addrlen);
if (NULL == sock)
{
/* failed for some odd reason (out of sockets?); ignore attempt */
@@ -3608,23 +3477,23 @@ try_connection_reversal (void *cls,
}
tcp_probe_ctx = GNUNET_new (struct TCPProbeContext);
- tcp_probe_ctx->message.header.size
- = htons (sizeof (struct TCP_NAT_ProbeMessage));
- tcp_probe_ctx->message.header.type
- = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_TCP_NAT_PROBE);
- tcp_probe_ctx->message.clientIdentity
- = *plugin->env->my_identity;
+ tcp_probe_ctx->message.header.size =
+ htons (sizeof (struct TCP_NAT_ProbeMessage));
+ tcp_probe_ctx->message.header.type =
+ htons (GNUNET_MESSAGE_TYPE_TRANSPORT_TCP_NAT_PROBE);
+ tcp_probe_ctx->message.clientIdentity = *plugin->env->my_identity;
tcp_probe_ctx->plugin = plugin;
tcp_probe_ctx->sock = sock;
GNUNET_CONTAINER_DLL_insert (plugin->probe_head,
plugin->probe_tail,
tcp_probe_ctx);
- tcp_probe_ctx->transmit_handle
- = GNUNET_CONNECTION_notify_transmit_ready (sock,
- ntohs (tcp_probe_ctx->message.header.size),
- GNUNET_TIME_UNIT_FOREVER_REL,
- &notify_send_probe,
- tcp_probe_ctx);
+ tcp_probe_ctx->transmit_handle =
+ GNUNET_CONNECTION_notify_transmit_ready (sock,
+ ntohs (tcp_probe_ctx->message
+ .header.size),
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ &notify_send_probe,
+ tcp_probe_ctx);
}
@@ -3636,8 +3505,7 @@ try_connection_reversal (void *cls,
* @return the network type in HBO or #GNUNET_SYSERR
*/
static enum GNUNET_NetworkType
-tcp_plugin_get_network (void *cls,
- struct GNUNET_ATS_Session *session)
+tcp_plugin_get_network (void *cls, struct GNUNET_ATS_Session *session)
{
return session->scope;
}
@@ -3664,25 +3532,25 @@ tcp_plugin_get_network_for_address (void *cls,
size_t sbs;
addrlen = address->address_length;
- if (addrlen == sizeof(struct IPv6TcpAddress))
+ if (addrlen == sizeof (struct IPv6TcpAddress))
{
GNUNET_assert (NULL != address->address); /* make static analysis happy */
t6 = address->address;
- memset (&a6, 0, sizeof(a6));
+ memset (&a6, 0, sizeof (a6));
#if HAVE_SOCKADDR_IN_SIN_LEN
a6.sin6_len = sizeof (a6);
#endif
a6.sin6_family = AF_INET6;
a6.sin6_port = t6->t6_port;
- GNUNET_memcpy (&a6.sin6_addr, &t6->ipv6_addr, sizeof(struct in6_addr));
+ GNUNET_memcpy (&a6.sin6_addr, &t6->ipv6_addr, sizeof (struct in6_addr));
sb = &a6;
- sbs = sizeof(a6);
+ sbs = sizeof (a6);
}
- else if (addrlen == sizeof(struct IPv4TcpAddress))
+ else if (addrlen == sizeof (struct IPv4TcpAddress))
{
GNUNET_assert (NULL != address->address); /* make static analysis happy */
t4 = address->address;
- memset (&a4, 0, sizeof(a4));
+ memset (&a4, 0, sizeof (a4));
#if HAVE_SOCKADDR_IN_SIN_LEN
a4.sin_len = sizeof (a4);
#endif
@@ -3690,16 +3558,14 @@ tcp_plugin_get_network_for_address (void *cls,
a4.sin_port = t4->t4_port;
a4.sin_addr.s_addr = t4->ipv4_addr;
sb = &a4;
- sbs = sizeof(a4);
+ sbs = sizeof (a4);
}
else
{
GNUNET_break (0);
return GNUNET_NT_UNSPECIFIED;
}
- return plugin->env->get_address_type (plugin->env->cls,
- sb,
- sbs);
+ return plugin->env->get_address_type (plugin->env->cls, sb, sbs);
}
@@ -3720,14 +3586,10 @@ send_session_info_iter (void *cls,
struct Plugin *plugin = cls;
struct GNUNET_ATS_Session *session = value;
- notify_session_monitor (plugin,
- session,
- GNUNET_TRANSPORT_SS_INIT);
+ notify_session_monitor (plugin, session, GNUNET_TRANSPORT_SS_INIT);
/* FIXME: cannot tell if this is up or not from current
session state... */
- notify_session_monitor (plugin,
- session,
- GNUNET_TRANSPORT_SS_UP);
+ notify_session_monitor (plugin, session, GNUNET_TRANSPORT_SS_UP);
return GNUNET_OK;
}
@@ -3773,17 +3635,17 @@ tcp_plugin_setup_monitor (void *cls,
void *
libgnunet_plugin_transport_tcp_init (void *cls)
{
- static const struct GNUNET_SERVER_MessageHandler my_handlers[] = {
- { &handle_tcp_welcome, NULL,
+ static const struct GNUNET_SERVER_MessageHandler my_handlers[] =
+ {{&handle_tcp_welcome,
+ NULL,
GNUNET_MESSAGE_TYPE_TRANSPORT_TCP_WELCOME,
- sizeof(struct WelcomeMessage) },
- { &handle_tcp_nat_probe, NULL,
+ sizeof (struct WelcomeMessage)},
+ {&handle_tcp_nat_probe,
+ NULL,
GNUNET_MESSAGE_TYPE_TRANSPORT_TCP_NAT_PROBE,
- sizeof(struct TCP_NAT_ProbeMessage) },
- { &handle_tcp_data, NULL,
- GNUNET_MESSAGE_TYPE_ALL, 0 },
- { NULL, NULL, 0, 0 }
- };
+ sizeof (struct TCP_NAT_ProbeMessage)},
+ {&handle_tcp_data, NULL, GNUNET_MESSAGE_TYPE_ALL, 0},
+ {NULL, NULL, 0, 0}};
struct GNUNET_TRANSPORT_PluginEnvironment *env = cls;
struct GNUNET_TRANSPORT_PluginFunctions *api;
struct Plugin *plugin;
@@ -3794,7 +3656,7 @@ libgnunet_plugin_transport_tcp_init (void *cls)
unsigned int i;
struct GNUNET_TIME_Relative idle_timeout;
#ifdef TCP_STEALTH
- struct GNUNET_NETWORK_Handle *const*lsocks;
+ struct GNUNET_NETWORK_Handle *const *lsocks;
#endif
int ret;
int ret_s;
@@ -3814,27 +3676,28 @@ libgnunet_plugin_transport_tcp_init (void *cls)
}
GNUNET_assert (NULL != env->cfg);
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_number (env->cfg,
- "transport-tcp",
- "MAX_CONNECTIONS",
- &max_connections))
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (env->cfg,
+ "transport-tcp",
+ "MAX_CONNECTIONS",
+ &max_connections))
max_connections = 128;
aport = 0;
- if ((GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-tcp",
- "PORT", &bport)) ||
+ if ((GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (env->cfg,
+ "transport-tcp",
+ "PORT",
+ &bport)) ||
(bport > 65535) ||
- ((GNUNET_OK ==
- GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-tcp",
- "ADVERTISED-PORT", &aport)) &&
- (aport > 65535) ))
+ ((GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (env->cfg,
+ "transport-tcp",
+ "ADVERTISED-PORT",
+ &aport)) &&
+ (aport > 65535)))
{
- LOG(GNUNET_ERROR_TYPE_ERROR,
- _("Require valid port number for service `%s' in configuration!\n"),
- "transport-tcp");
- return NULL ;
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ _ ("Require valid port number for service `%s' in configuration!\n"),
+ "transport-tcp");
+ return NULL;
}
if (0 == aport)
aport = bport;
@@ -3847,8 +3710,7 @@ libgnunet_plugin_transport_tcp_init (void *cls)
LEGACY_SERVICE_OPTION_NONE);
if (NULL == service)
{
- LOG (GNUNET_ERROR_TYPE_WARNING,
- _("Failed to start service.\n"));
+ LOG (GNUNET_ERROR_TYPE_WARNING, _ ("Failed to start service.\n"));
return NULL;
}
}
@@ -3857,21 +3719,21 @@ libgnunet_plugin_transport_tcp_init (void *cls)
api = NULL;
plugin = GNUNET_new (struct Plugin);
- plugin->sessionmap = GNUNET_CONTAINER_multipeermap_create (max_connections,
- GNUNET_YES);
+ plugin->sessionmap =
+ GNUNET_CONTAINER_multipeermap_create (max_connections, GNUNET_YES);
plugin->max_connections = max_connections;
plugin->open_port = bport;
plugin->adv_port = aport;
plugin->env = env;
- plugin->my_welcome.header.size = htons (sizeof(struct WelcomeMessage));
- plugin->my_welcome.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_TCP_WELCOME);
+ plugin->my_welcome.header.size = htons (sizeof (struct WelcomeMessage));
+ plugin->my_welcome.header.type =
+ htons (GNUNET_MESSAGE_TYPE_TRANSPORT_TCP_WELCOME);
plugin->my_welcome.clientIdentity = *plugin->env->my_identity;
- if ( (NULL != service) &&
- (GNUNET_YES ==
- GNUNET_CONFIGURATION_get_value_yesno (env->cfg,
- "transport-tcp",
- "TCP_STEALTH")) )
+ if ((NULL != service) &&
+ (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (env->cfg,
+ "transport-tcp",
+ "TCP_STEALTH")))
{
#ifdef TCP_STEALTH
plugin->myoptions |= TCP_OPTIONS_TCP_STEALTH;
@@ -3880,59 +3742,57 @@ libgnunet_plugin_transport_tcp_init (void *cls)
{
uint32_t len = sizeof (struct WelcomeMessage);
- for (i=0;NULL!=lsocks[i];i++)
+ for (i = 0; NULL != lsocks[i]; i++)
{
- if ( (GNUNET_OK !=
- GNUNET_NETWORK_socket_setsockopt (lsocks[i],
- IPPROTO_TCP,
- TCP_STEALTH,
- env->my_identity,
- sizeof (struct GNUNET_PeerIdentity))) ||
- (GNUNET_OK !=
- GNUNET_NETWORK_socket_setsockopt (lsocks[i],
- IPPROTO_TCP,
- TCP_STEALTH_INTEGRITY_LEN,
- &len,
- sizeof (len))) )
+ if (
+ (GNUNET_OK !=
+ GNUNET_NETWORK_socket_setsockopt (lsocks[i],
+ IPPROTO_TCP,
+ TCP_STEALTH,
+ env->my_identity,
+ sizeof (
+ struct GNUNET_PeerIdentity))) ||
+ (GNUNET_OK !=
+ GNUNET_NETWORK_socket_setsockopt (lsocks[i],
+ IPPROTO_TCP,
+ TCP_STEALTH_INTEGRITY_LEN,
+ &len,
+ sizeof (len))))
{
/* TCP STEALTH not supported by kernel */
GNUNET_assert (0 == i);
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("TCP_STEALTH not supported on this platform.\n"));
+ _ ("TCP_STEALTH not supported on this platform.\n"));
goto die;
}
}
}
#else
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("TCP_STEALTH not supported on this platform.\n"));
+ _ ("TCP_STEALTH not supported on this platform.\n"));
goto die;
#endif
}
- if ( (NULL != service) &&
- (GNUNET_SYSERR !=
- (ret_s =
- get_server_addresses ("transport-tcp",
- env->cfg,
- &addrs,
- &addrlens))))
+ if ((NULL != service) &&
+ (GNUNET_SYSERR !=
+ (ret_s =
+ get_server_addresses ("transport-tcp", env->cfg, &addrs, &addrlens))))
{
- for (ret = ret_s-1; ret >= 0; ret--)
+ for (ret = ret_s - 1; ret >= 0; ret--)
LOG (GNUNET_ERROR_TYPE_INFO,
"Binding to address `%s'\n",
GNUNET_a2s (addrs[ret], addrlens[ret]));
- plugin->nat
- = GNUNET_NAT_register (env->cfg,
- "transport-tcp",
- IPPROTO_TCP,
- (unsigned int) ret_s,
- (const struct sockaddr **) addrs,
- addrlens,
- &tcp_nat_port_map_callback,
- &try_connection_reversal,
- plugin);
- for (ret = ret_s -1; ret >= 0; ret--)
+ plugin->nat = GNUNET_NAT_register (env->cfg,
+ "transport-tcp",
+ IPPROTO_TCP,
+ (unsigned int) ret_s,
+ (const struct sockaddr **) addrs,
+ addrlens,
+ &tcp_nat_port_map_callback,
+ &try_connection_reversal,
+ plugin);
+ for (ret = ret_s - 1; ret >= 0; ret--)
GNUNET_free (addrs[ret]);
GNUNET_free_non_null (addrs);
GNUNET_free_non_null (addrlens);
@@ -3941,7 +3801,7 @@ libgnunet_plugin_transport_tcp_init (void *cls)
{
plugin->nat = GNUNET_NAT_register (plugin->env->cfg,
"transport-tcp",
- IPPROTO_TCP,
+ IPPROTO_TCP,
0,
NULL,
NULL,
@@ -3972,52 +3832,44 @@ libgnunet_plugin_transport_tcp_init (void *cls)
}
else
{
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_time (env->cfg,
- "transport-tcp",
- "TIMEOUT",
- &idle_timeout))
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time (env->cfg,
+ "transport-tcp",
+ "TIMEOUT",
+ &idle_timeout))
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
"transport-tcp",
"TIMEOUT");
goto die;
}
- plugin->server
- = GNUNET_SERVER_create_with_sockets (NULL,
- plugin,
- NULL,
- idle_timeout,
- GNUNET_YES);
+ plugin->server = GNUNET_SERVER_create_with_sockets (NULL,
+ plugin,
+ NULL,
+ idle_timeout,
+ GNUNET_YES);
}
plugin->handlers = GNUNET_malloc (sizeof (my_handlers));
- GNUNET_memcpy (plugin->handlers,
- my_handlers,
- sizeof(my_handlers));
- for (i = 0;i < sizeof(my_handlers) / sizeof(struct GNUNET_SERVER_MessageHandler);i++)
+ GNUNET_memcpy (plugin->handlers, my_handlers, sizeof (my_handlers));
+ for (i = 0;
+ i < sizeof (my_handlers) / sizeof (struct GNUNET_SERVER_MessageHandler);
+ i++)
plugin->handlers[i].callback_cls = plugin;
- GNUNET_SERVER_add_handlers (plugin->server,
- plugin->handlers);
- GNUNET_SERVER_connect_notify (plugin->server,
- &connect_notify,
- plugin);
- GNUNET_SERVER_disconnect_notify (plugin->server,
- &disconnect_notify,
- plugin);
- plugin->nat_wait_conns = GNUNET_CONTAINER_multipeermap_create (16,
- GNUNET_YES);
+ GNUNET_SERVER_add_handlers (plugin->server, plugin->handlers);
+ GNUNET_SERVER_connect_notify (plugin->server, &connect_notify, plugin);
+ GNUNET_SERVER_disconnect_notify (plugin->server, &disconnect_notify, plugin);
+ plugin->nat_wait_conns =
+ GNUNET_CONTAINER_multipeermap_create (16, GNUNET_YES);
if (0 != bport)
LOG (GNUNET_ERROR_TYPE_INFO,
- _("TCP transport listening on port %llu\n"),
+ _ ("TCP transport listening on port %llu\n"),
bport);
else
LOG (GNUNET_ERROR_TYPE_INFO,
- _("TCP transport not listening on any port (client only)\n"));
- if ( (aport != bport) &&
- (0 != bport) )
+ _ ("TCP transport not listening on any port (client only)\n"));
+ if ((aport != bport) && (0 != bport))
LOG (GNUNET_ERROR_TYPE_INFO,
- _("TCP transport advertises itself as being on port %llu\n"),
+ _ ("TCP transport advertises itself as being on port %llu\n"),
aport);
/* Initially set connections to 0 */
GNUNET_STATISTICS_set (plugin->env->stats,
@@ -4026,7 +3878,7 @@ libgnunet_plugin_transport_tcp_init (void *cls)
GNUNET_NO);
return api;
- die:
+die:
if (NULL != plugin->nat)
GNUNET_NAT_unregister (plugin->nat);
GNUNET_CONTAINER_multipeermap_destroy (plugin->sessionmap);
@@ -4055,11 +3907,10 @@ libgnunet_plugin_transport_tcp_done (void *cls)
if (NULL == plugin)
{
- GNUNET_free(api);
- return NULL ;
+ GNUNET_free (api);
+ return NULL;
}
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Shutting down TCP plugin\n");
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Shutting down TCP plugin\n");
/* Removing leftover sessions */
GNUNET_CONTAINER_multipeermap_iterate (plugin->sessionmap,
@@ -4077,9 +3928,7 @@ libgnunet_plugin_transport_tcp_done (void *cls)
plugin->ppc_dll_tail,
cur);
GNUNET_RESOLVER_request_cancel (cur->resolver_handle);
- cur->asc (cur->asc_cls,
- NULL,
- GNUNET_OK);
+ cur->asc (cur->asc_cls, NULL, GNUNET_OK);
GNUNET_free (cur);
}
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c
index b05192e06..1d34cdd1a 100644
--- a/src/transport/plugin_transport_udp.c
+++ b/src/transport/plugin_transport_udp.c
@@ -40,12 +40,13 @@
#include "gnunet_transport_plugin.h"
#include "transport.h"
-#define LOG(kind,...) GNUNET_log_from (kind, "transport-udp", __VA_ARGS__)
+#define LOG(kind, ...) GNUNET_log_from (kind, "transport-udp", __VA_ARGS__)
/**
* After how much inactivity should a UDP session time out?
*/
-#define UDP_SESSION_TIME_OUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
+#define UDP_SESSION_TIME_OUT \
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
/**
* Number of messages we can defragment in parallel. We only really
@@ -86,7 +87,6 @@ struct UDPMessage
* What is the identity of the sender
*/
struct GNUNET_PeerIdentity sender;
-
};
@@ -144,7 +144,6 @@ struct PrettyPrinterContext
* Port to add after the IP address.
*/
uint16_t port;
-
};
@@ -248,7 +247,6 @@ struct GNUNET_ATS_Session
};
-
/**
* Data structure to track defragmentation contexts based
* on the source of the UDP traffic.
@@ -374,7 +372,6 @@ struct UDP_FragmentationContext
* Bytes used to send all fragments on wire including UDP overhead
*/
size_t on_wire_size;
-
};
@@ -388,10 +385,9 @@ struct UDP_FragmentationContext
* #GNUNET_SYSERR if the target disconnected
* or we had a timeout or other trouble sending
*/
-typedef void
-(*QueueContinuation) (void *cls,
- struct UDP_MessageWrapper *udpw,
- int result);
+typedef void (*QueueContinuation) (void *cls,
+ struct UDP_MessageWrapper *udpw,
+ int result);
/**
@@ -474,7 +470,6 @@ struct UDP_MessageWrapper
* Payload size of original message.
*/
size_t payload_size;
-
};
@@ -501,7 +496,6 @@ struct UDP_ACK_Message
* What is the identity of the sender
*/
struct GNUNET_PeerIdentity sender;
-
};
GNUNET_NETWORK_STRUCT_END
@@ -529,9 +523,7 @@ notify_session_monitor (struct Plugin *plugin,
return;
if (GNUNET_YES == session->in_destroy)
return; /* already destroyed, just RC>0 left-over actions */
- memset (&info,
- 0,
- sizeof (info));
+ memset (&info, 0, sizeof (info));
info.state = state;
info.is_inbound = GNUNET_SYSERR; /* hard to say */
info.num_msg_pending = session->msgs_in_queue;
@@ -541,9 +533,7 @@ notify_session_monitor (struct Plugin *plugin,
to receive from others) */
info.session_timeout = session->timeout;
info.address = session->address;
- plugin->sic (plugin->sic_cls,
- session,
- &info);
+ plugin->sic (plugin->sic_cls, session, &info);
}
@@ -563,12 +553,8 @@ send_session_info_iter (void *cls,
struct Plugin *plugin = cls;
struct GNUNET_ATS_Session *session = value;
- notify_session_monitor (plugin,
- session,
- GNUNET_TRANSPORT_SS_INIT);
- notify_session_monitor (plugin,
- session,
- GNUNET_TRANSPORT_SS_UP);
+ notify_session_monitor (plugin, session, GNUNET_TRANSPORT_SS_INIT);
+ notify_session_monitor (plugin, session, GNUNET_TRANSPORT_SS_UP);
return GNUNET_OK;
}
@@ -600,9 +586,7 @@ udp_plugin_setup_monitor (void *cls,
&send_session_info_iter,
plugin);
/* signal end of first iteration */
- sic (sic_cls,
- NULL,
- NULL);
+ sic (sic_cls, NULL, NULL);
}
}
@@ -625,9 +609,7 @@ free_session (struct GNUNET_ATS_Session *s)
}
if (NULL != s->frag_ctx)
{
- GNUNET_FRAGMENT_context_destroy (s->frag_ctx->frag,
- NULL,
- NULL);
+ GNUNET_FRAGMENT_context_destroy (s->frag_ctx->frag, NULL, NULL);
GNUNET_free (s->frag_ctx);
s->frag_ctx = NULL;
}
@@ -663,8 +645,7 @@ udp_query_keepalive_factor (void *cls)
* @return the network type
*/
static enum GNUNET_NetworkType
-udp_plugin_get_network (void *cls,
- struct GNUNET_ATS_Session *session)
+udp_plugin_get_network (void *cls, struct GNUNET_ATS_Session *session)
{
return session->scope;
}
@@ -691,25 +672,25 @@ udp_plugin_get_network_for_address (void *cls,
size_t sbs;
addrlen = address->address_length;
- if (addrlen == sizeof(struct IPv6UdpAddress))
+ if (addrlen == sizeof (struct IPv6UdpAddress))
{
GNUNET_assert (NULL != address->address); /* make static analysis happy */
u6 = address->address;
- memset (&a6, 0, sizeof(a6));
+ memset (&a6, 0, sizeof (a6));
#if HAVE_SOCKADDR_IN_SIN_LEN
a6.sin6_len = sizeof (a6);
#endif
a6.sin6_family = AF_INET6;
a6.sin6_port = u6->u6_port;
- GNUNET_memcpy (&a6.sin6_addr, &u6->ipv6_addr, sizeof(struct in6_addr));
+ GNUNET_memcpy (&a6.sin6_addr, &u6->ipv6_addr, sizeof (struct in6_addr));
sb = &a6;
- sbs = sizeof(a6);
+ sbs = sizeof (a6);
}
- else if (addrlen == sizeof(struct IPv4UdpAddress))
+ else if (addrlen == sizeof (struct IPv4UdpAddress))
{
GNUNET_assert (NULL != address->address); /* make static analysis happy */
u4 = address->address;
- memset (&a4, 0, sizeof(a4));
+ memset (&a4, 0, sizeof (a4));
#if HAVE_SOCKADDR_IN_SIN_LEN
a4.sin_len = sizeof (a4);
#endif
@@ -717,16 +698,14 @@ udp_plugin_get_network_for_address (void *cls,
a4.sin_port = u4->u4_port;
a4.sin_addr.s_addr = u4->ipv4_addr;
sb = &a4;
- sbs = sizeof(a4);
+ sbs = sizeof (a4);
}
else
{
GNUNET_break (0);
return GNUNET_NT_UNSPECIFIED;
}
- return plugin->env->get_address_type (plugin->env->cls,
- sb,
- sbs);
+ return plugin->env->get_address_type (plugin->env->cls, sb, sbs);
}
@@ -767,8 +746,7 @@ schedule_select_v4 (struct Plugin *plugin)
struct UDP_MessageWrapper *udpw;
struct UDP_MessageWrapper *min_udpw;
- if ( (GNUNET_YES == plugin->enable_ipv4) &&
- (NULL != plugin->sockv4) )
+ if ((GNUNET_YES == plugin->enable_ipv4) && (NULL != plugin->sockv4))
{
/* Find a message ready to send:
* Flow delay from other peer is expired or not set (0) */
@@ -804,11 +782,11 @@ schedule_select_v4 (struct Plugin *plugin)
GNUNET_i2s (&min_udpw->session->target));
}
}
- plugin->select_task_v4
- = GNUNET_SCHEDULER_add_read_net (min_delay,
- plugin->sockv4,
- &udp_plugin_select_v4,
- plugin);
+ plugin->select_task_v4 =
+ GNUNET_SCHEDULER_add_read_net (min_delay,
+ plugin->sockv4,
+ &udp_plugin_select_v4,
+ plugin);
}
}
@@ -826,8 +804,7 @@ schedule_select_v6 (struct Plugin *plugin)
struct UDP_MessageWrapper *udpw;
struct UDP_MessageWrapper *min_udpw;
- if ( (GNUNET_YES == plugin->enable_ipv6) &&
- (NULL != plugin->sockv6) )
+ if ((GNUNET_YES == plugin->enable_ipv6) && (NULL != plugin->sockv6))
{
min_delay = GNUNET_TIME_UNIT_FOREVER_REL;
min_udpw = NULL;
@@ -861,11 +838,11 @@ schedule_select_v6 (struct Plugin *plugin)
GNUNET_i2s (&min_udpw->session->target));
}
}
- plugin->select_task_v6
- = GNUNET_SCHEDULER_add_read_net (min_delay,
- plugin->sockv6,
- &udp_plugin_select_v6,
- plugin);
+ plugin->select_task_v6 =
+ GNUNET_SCHEDULER_add_read_net (min_delay,
+ plugin->sockv6,
+ &udp_plugin_select_v6,
+ plugin);
}
}
@@ -885,9 +862,7 @@ schedule_select_v6 (struct Plugin *plugin)
* @return string representing the same address
*/
const char *
-udp_address_to_string (void *cls,
- const void *addr,
- size_t addrlen)
+udp_address_to_string (void *cls, const void *addr, size_t addrlen)
{
static char rbuf[INET6_ADDRSTRLEN + 10];
char buf[INET6_ADDRSTRLEN];
@@ -906,7 +881,7 @@ udp_address_to_string (void *cls,
return NULL;
}
- if (addrlen == sizeof(struct IPv6UdpAddress))
+ if (addrlen == sizeof (struct IPv6UdpAddress))
{
t6 = addr;
af = AF_INET6;
@@ -915,7 +890,7 @@ udp_address_to_string (void *cls,
a6 = t6->ipv6_addr;
sb = &a6;
}
- else if (addrlen == sizeof(struct IPv4UdpAddress))
+ else if (addrlen == sizeof (struct IPv4UdpAddress))
{
t4 = addr;
af = AF_INET;
@@ -929,15 +904,10 @@ udp_address_to_string (void *cls,
GNUNET_break_op (0);
return NULL;
}
- inet_ntop (af,
- sb,
- buf,
- INET6_ADDRSTRLEN);
+ inet_ntop (af, sb, buf, INET6_ADDRSTRLEN);
GNUNET_snprintf (rbuf,
- sizeof(rbuf),
- (af == AF_INET6)
- ? "%s.%u.[%s]:%u"
- : "%s.%u.%s:%u",
+ sizeof (rbuf),
+ (af == AF_INET6) ? "%s.%u.[%s]:%u" : "%s.%u.%s:%u",
PLUGIN_NAME,
options,
buf,
@@ -1012,44 +982,42 @@ udp_string_to_address (void *cls,
address++;
if (GNUNET_OK !=
- GNUNET_STRINGS_to_address_ip (address,
- strlen (address),
- &socket_address))
+ GNUNET_STRINGS_to_address_ip (address, strlen (address), &socket_address))
{
GNUNET_break (0);
GNUNET_free (plugin);
return GNUNET_SYSERR;
}
- GNUNET_free(plugin);
+ GNUNET_free (plugin);
switch (socket_address.ss_family)
{
- case AF_INET:
- {
- struct IPv4UdpAddress *u4;
- const struct sockaddr_in *in4 = (const struct sockaddr_in *) &socket_address;
-
- u4 = GNUNET_new (struct IPv4UdpAddress);
- u4->options = htonl (options);
- u4->ipv4_addr = in4->sin_addr.s_addr;
- u4->u4_port = in4->sin_port;
- *buf = u4;
- *added = sizeof (struct IPv4UdpAddress);
- return GNUNET_OK;
- }
- case AF_INET6:
- {
- struct IPv6UdpAddress *u6;
- const struct sockaddr_in6 *in6 = (const struct sockaddr_in6 *) &socket_address;
-
- u6 = GNUNET_new (struct IPv6UdpAddress);
- u6->options = htonl (options);
- u6->ipv6_addr = in6->sin6_addr;
- u6->u6_port = in6->sin6_port;
- *buf = u6;
- *added = sizeof (struct IPv6UdpAddress);
- return GNUNET_OK;
- }
+ case AF_INET: {
+ struct IPv4UdpAddress *u4;
+ const struct sockaddr_in *in4 =
+ (const struct sockaddr_in *) &socket_address;
+
+ u4 = GNUNET_new (struct IPv4UdpAddress);
+ u4->options = htonl (options);
+ u4->ipv4_addr = in4->sin_addr.s_addr;
+ u4->u4_port = in4->sin_port;
+ *buf = u4;
+ *added = sizeof (struct IPv4UdpAddress);
+ return GNUNET_OK;
+ }
+ case AF_INET6: {
+ struct IPv6UdpAddress *u6;
+ const struct sockaddr_in6 *in6 =
+ (const struct sockaddr_in6 *) &socket_address;
+
+ u6 = GNUNET_new (struct IPv6UdpAddress);
+ u6->options = htonl (options);
+ u6->ipv6_addr = in6->sin6_addr;
+ u6->u6_port = in6->sin6_port;
+ *buf = u6;
+ *added = sizeof (struct IPv6UdpAddress);
+ return GNUNET_OK;
+ }
default:
GNUNET_break (0);
return GNUNET_SYSERR;
@@ -1064,8 +1032,7 @@ udp_string_to_address (void *cls,
* @param hostname result from DNS resolver
*/
static void
-append_port (void *cls,
- const char *hostname)
+append_port (void *cls, const char *hostname)
{
struct PrettyPrinterContext *ppc = cls;
struct Plugin *plugin = ppc->plugin;
@@ -1078,9 +1045,7 @@ append_port (void *cls,
plugin->ppc_dll_tail,
ppc);
ppc->resolver_handle = NULL;
- ppc->asc (ppc->asc_cls,
- NULL,
- GNUNET_OK);
+ ppc->asc (ppc->asc_cls, NULL, GNUNET_OK);
GNUNET_free (ppc);
return;
}
@@ -1098,9 +1063,7 @@ append_port (void *cls,
ppc->options,
hostname,
ppc->port);
- ppc->asc (ppc->asc_cls,
- ret,
- GNUNET_OK);
+ ppc->asc (ppc->asc_cls, ret, GNUNET_OK);
GNUNET_free (ret);
}
@@ -1140,12 +1103,10 @@ udp_plugin_address_pretty_printer (void *cls,
uint16_t port;
uint32_t options;
- if (addrlen == sizeof(struct IPv6UdpAddress))
+ if (addrlen == sizeof (struct IPv6UdpAddress))
{
u6 = addr;
- memset (&a6,
- 0,
- sizeof (a6));
+ memset (&a6, 0, sizeof (a6));
a6.sin6_family = AF_INET6;
#if HAVE_SOCKADDR_IN_SIN_LEN
a6.sin6_len = sizeof (a6);
@@ -1160,9 +1121,7 @@ udp_plugin_address_pretty_printer (void *cls,
else if (addrlen == sizeof (struct IPv4UdpAddress))
{
u4 = addr;
- memset (&a4,
- 0,
- sizeof(a4));
+ memset (&a4, 0, sizeof (a4));
a4.sin_family = AF_INET;
#if HAVE_SOCKADDR_IN_SIN_LEN
a4.sin_len = sizeof (a4);
@@ -1172,18 +1131,14 @@ udp_plugin_address_pretty_printer (void *cls,
port = ntohs (u4->u4_port);
options = ntohl (u4->options);
sb = (const struct sockaddr *) &a4;
- sbs = sizeof(a4);
+ sbs = sizeof (a4);
}
else
{
/* invalid address */
GNUNET_break_op (0);
- asc (asc_cls,
- NULL,
- GNUNET_SYSERR);
- asc (asc_cls,
- NULL,
- GNUNET_OK);
+ asc (asc_cls, NULL, GNUNET_SYSERR);
+ asc (asc_cls, NULL, GNUNET_OK);
return;
}
ppc = GNUNET_new (struct PrettyPrinterContext);
@@ -1196,16 +1151,13 @@ udp_plugin_address_pretty_printer (void *cls,
ppc->ipv6 = GNUNET_YES;
else
ppc->ipv6 = GNUNET_NO;
- GNUNET_CONTAINER_DLL_insert (plugin->ppc_dll_head,
- plugin->ppc_dll_tail,
- ppc);
- ppc->resolver_handle
- = GNUNET_RESOLVER_hostname_get (sb,
- sbs,
- ! numeric,
- timeout,
- &append_port,
- ppc);
+ GNUNET_CONTAINER_DLL_insert (plugin->ppc_dll_head, plugin->ppc_dll_tail, ppc);
+ ppc->resolver_handle = GNUNET_RESOLVER_hostname_get (sb,
+ sbs,
+ ! numeric,
+ timeout,
+ &append_port,
+ ppc);
}
@@ -1219,11 +1171,9 @@ udp_plugin_address_pretty_printer (void *cls,
* @return #GNUNET_OK if port is either our open or advertised port
*/
static int
-check_port (const struct Plugin *plugin,
- uint16_t in_port)
+check_port (const struct Plugin *plugin, uint16_t in_port)
{
- if ( (plugin->port == in_port) ||
- (plugin->aport == in_port) )
+ if ((plugin->port == in_port) || (plugin->aport == in_port))
return GNUNET_OK;
return GNUNET_SYSERR;
}
@@ -1245,21 +1195,18 @@ check_port (const struct Plugin *plugin,
* and transport, #GNUNET_SYSERR if not
*/
static int
-udp_plugin_check_address (void *cls,
- const void *addr,
- size_t addrlen)
+udp_plugin_check_address (void *cls, const void *addr, size_t addrlen)
{
struct Plugin *plugin = cls;
const struct IPv4UdpAddress *v4;
const struct IPv6UdpAddress *v6;
- if (sizeof(struct IPv4UdpAddress) == addrlen)
+ if (sizeof (struct IPv4UdpAddress) == addrlen)
{
struct sockaddr_in s4;
v4 = (const struct IPv4UdpAddress *) addr;
- if (GNUNET_OK != check_port (plugin,
- ntohs (v4->u4_port)))
+ if (GNUNET_OK != check_port (plugin, ntohs (v4->u4_port)))
return GNUNET_SYSERR;
memset (&s4, 0, sizeof (s4));
s4.sin_family = AF_INET;
@@ -1270,12 +1217,10 @@ udp_plugin_check_address (void *cls,
s4.sin_addr.s_addr = v4->ipv4_addr;
if (GNUNET_OK !=
- GNUNET_NAT_test_address (plugin->nat,
- &s4,
- sizeof (struct sockaddr_in)))
+ GNUNET_NAT_test_address (plugin->nat, &s4, sizeof (struct sockaddr_in)))
return GNUNET_SYSERR;
}
- else if (sizeof(struct IPv6UdpAddress) == addrlen)
+ else if (sizeof (struct IPv6UdpAddress) == addrlen)
{
struct sockaddr_in6 s6;
@@ -1290,10 +1235,9 @@ udp_plugin_check_address (void *cls,
s6.sin6_port = v6->u6_port;
s6.sin6_addr = v6->ipv6_addr;
- if (GNUNET_OK !=
- GNUNET_NAT_test_address (plugin->nat,
- &s6,
- sizeof(struct sockaddr_in6)))
+ if (GNUNET_OK != GNUNET_NAT_test_address (plugin->nat,
+ &s6,
+ sizeof (struct sockaddr_in6)))
return GNUNET_SYSERR;
}
else
@@ -1319,9 +1263,9 @@ udp_plugin_check_address (void *cls,
*/
static void
udp_nat_port_map_callback (void *cls,
- void **app_ctx,
+ void **app_ctx,
int add_remove,
- enum GNUNET_NAT_AddressClass ac,
+ enum GNUNET_NAT_AddressClass ac,
const struct sockaddr *addr,
socklen_t addrlen)
{
@@ -1334,50 +1278,42 @@ udp_nat_port_map_callback (void *cls,
(void) app_ctx;
LOG (GNUNET_ERROR_TYPE_DEBUG,
- (GNUNET_YES == add_remove)
- ? "NAT notification to add address `%s'\n"
- : "NAT notification to remove address `%s'\n",
- GNUNET_a2s (addr,
- addrlen));
+ (GNUNET_YES == add_remove) ? "NAT notification to add address `%s'\n"
+ : "NAT notification to remove address `%s'\n",
+ GNUNET_a2s (addr, addrlen));
/* convert 'address' to our internal format */
switch (addr->sa_family)
{
- case AF_INET:
- {
- const struct sockaddr_in *i4;
-
- GNUNET_assert (sizeof(struct sockaddr_in) == addrlen);
- i4 = (const struct sockaddr_in *) addr;
- if (0 == ntohs (i4->sin_port))
- return; /* Port = 0 means unmapped, ignore these for UDP. */
- memset (&u4,
- 0,
- sizeof(u4));
- u4.options = htonl (plugin->myoptions);
- u4.ipv4_addr = i4->sin_addr.s_addr;
- u4.u4_port = i4->sin_port;
- arg = &u4;
- args = sizeof (struct IPv4UdpAddress);
- break;
- }
- case AF_INET6:
- {
- const struct sockaddr_in6 *i6;
-
- GNUNET_assert (sizeof(struct sockaddr_in6) == addrlen);
- i6 = (const struct sockaddr_in6 *) addr;
- if (0 == ntohs (i6->sin6_port))
- return; /* Port = 0 means unmapped, ignore these for UDP. */
- memset (&u6,
- 0,
- sizeof(u6));
- u6.options = htonl (plugin->myoptions);
- u6.ipv6_addr = i6->sin6_addr;
- u6.u6_port = i6->sin6_port;
- arg = &u6;
- args = sizeof (struct IPv6UdpAddress);
- break;
- }
+ case AF_INET: {
+ const struct sockaddr_in *i4;
+
+ GNUNET_assert (sizeof (struct sockaddr_in) == addrlen);
+ i4 = (const struct sockaddr_in *) addr;
+ if (0 == ntohs (i4->sin_port))
+ return; /* Port = 0 means unmapped, ignore these for UDP. */
+ memset (&u4, 0, sizeof (u4));
+ u4.options = htonl (plugin->myoptions);
+ u4.ipv4_addr = i4->sin_addr.s_addr;
+ u4.u4_port = i4->sin_port;
+ arg = &u4;
+ args = sizeof (struct IPv4UdpAddress);
+ break;
+ }
+ case AF_INET6: {
+ const struct sockaddr_in6 *i6;
+
+ GNUNET_assert (sizeof (struct sockaddr_in6) == addrlen);
+ i6 = (const struct sockaddr_in6 *) addr;
+ if (0 == ntohs (i6->sin6_port))
+ return; /* Port = 0 means unmapped, ignore these for UDP. */
+ memset (&u6, 0, sizeof (u6));
+ u6.options = htonl (plugin->myoptions);
+ u6.ipv6_addr = i6->sin6_addr;
+ u6.u6_port = i6->sin6_port;
+ arg = &u6;
+ args = sizeof (struct IPv6UdpAddress);
+ break;
+ }
default:
GNUNET_break (0);
return;
@@ -1389,9 +1325,7 @@ udp_nat_port_map_callback (void *cls,
arg,
args,
GNUNET_HELLO_ADDRESS_INFO_NONE);
- plugin->env->notify_address (plugin->env->cls,
- add_remove,
- address);
+ plugin->env->notify_address (plugin->env->cls, add_remove, address);
GNUNET_HELLO_address_free (address);
}
@@ -1425,15 +1359,12 @@ struct GNUNET_ATS_SessionCompareContext
* @return #GNUNET_NO if we found the session, #GNUNET_OK if not
*/
static int
-session_cmp_it (void *cls,
- const struct GNUNET_PeerIdentity *key,
- void *value)
+session_cmp_it (void *cls, const struct GNUNET_PeerIdentity *key, void *value)
{
struct GNUNET_ATS_SessionCompareContext *cctx = cls;
struct GNUNET_ATS_Session *s = value;
- if (0 == GNUNET_HELLO_address_cmp (s->address,
- cctx->address))
+ if (0 == GNUNET_HELLO_address_cmp (s->address, cctx->address))
{
GNUNET_assert (GNUNET_NO == s->in_destroy);
cctx->res = s;
@@ -1466,7 +1397,7 @@ udp_plugin_lookup_session (void *cls,
GNUNET_break (0);
return NULL;
}
- if (sizeof(struct IPv4UdpAddress) == address->address_length)
+ if (sizeof (struct IPv4UdpAddress) == address->address_length)
{
if (NULL == plugin->sockv4)
return NULL;
@@ -1477,7 +1408,7 @@ udp_plugin_lookup_session (void *cls,
return NULL;
}
}
- else if (sizeof(struct IPv6UdpAddress) == address->address_length)
+ else if (sizeof (struct IPv6UdpAddress) == address->address_length)
{
if (NULL == plugin->sockv6)
return NULL;
@@ -1509,9 +1440,7 @@ udp_plugin_lookup_session (void *cls,
&cctx);
if (NULL == cctx.res)
return NULL;
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Found existing session %p\n",
- cctx.res);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Found existing session %p\n", cctx.res);
return cctx.res;
}
@@ -1534,7 +1463,6 @@ reschedule_session_timeout (struct GNUNET_ATS_Session *s)
}
-
/**
* Function that will be called whenever the transport service wants to
* notify the plugin that a session is still active and in use and
@@ -1575,8 +1503,7 @@ udp_plugin_update_session_timeout (void *cls,
* @param udpw message wrapper to dequeue
*/
static void
-dequeue (struct Plugin *plugin,
- struct UDP_MessageWrapper *udpw)
+dequeue (struct Plugin *plugin, struct UDP_MessageWrapper *udpw)
{
struct GNUNET_ATS_Session *session = udpw->session;
@@ -1588,7 +1515,7 @@ dequeue (struct Plugin *plugin,
{
GNUNET_STATISTICS_update (plugin->env->stats,
"# UDP, total bytes in send buffers",
- - (long long) udpw->msg_size,
+ -(long long) udpw->msg_size,
GNUNET_NO);
plugin->bytes_in_buffer -= udpw->msg_size;
}
@@ -1596,13 +1523,14 @@ dequeue (struct Plugin *plugin,
"# UDP, total messages in send buffers",
-1,
GNUNET_NO);
- if (sizeof(struct IPv4UdpAddress) == udpw->session->address->address_length)
+ if (sizeof (struct IPv4UdpAddress) == udpw->session->address->address_length)
{
GNUNET_CONTAINER_DLL_remove (plugin->ipv4_queue_head,
plugin->ipv4_queue_tail,
udpw);
}
- else if (sizeof(struct IPv6UdpAddress) == udpw->session->address->address_length)
+ else if (sizeof (struct IPv6UdpAddress) ==
+ udpw->session->address->address_length)
{
GNUNET_CONTAINER_DLL_remove (plugin->ipv6_queue_head,
plugin->ipv6_queue_tail,
@@ -1627,8 +1555,7 @@ dequeue (struct Plugin *plugin,
* @param udpw message wrapper to queue
*/
static void
-enqueue (struct Plugin *plugin,
- struct UDP_MessageWrapper *udpw)
+enqueue (struct Plugin *plugin, struct UDP_MessageWrapper *udpw)
{
struct GNUNET_ATS_Session *session = udpw->session;
@@ -1656,11 +1583,12 @@ enqueue (struct Plugin *plugin,
GNUNET_NO);
if (sizeof (struct IPv4UdpAddress) == udpw->session->address->address_length)
{
- GNUNET_CONTAINER_DLL_insert(plugin->ipv4_queue_head,
- plugin->ipv4_queue_tail,
- udpw);
+ GNUNET_CONTAINER_DLL_insert (plugin->ipv4_queue_head,
+ plugin->ipv4_queue_tail,
+ udpw);
}
- else if (sizeof (struct IPv6UdpAddress) == udpw->session->address->address_length)
+ else if (sizeof (struct IPv6UdpAddress) ==
+ udpw->session->address->address_length)
{
GNUNET_CONTAINER_DLL_insert (plugin->ipv6_queue_head,
plugin->ipv6_queue_tail,
@@ -1693,8 +1621,7 @@ enqueue (struct Plugin *plugin,
* #GNUNET_SYSERR if the transmission failed
*/
static void
-fragmented_message_done (struct UDP_FragmentationContext *frag_ctx,
- int result)
+fragmented_message_done (struct UDP_FragmentationContext *frag_ctx, int result)
{
struct Plugin *plugin = frag_ctx->plugin;
struct GNUNET_ATS_Session *s = frag_ctx->session;
@@ -1717,16 +1644,14 @@ fragmented_message_done (struct UDP_FragmentationContext *frag_ctx,
{
LOG (GNUNET_ERROR_TYPE_WARNING,
"Fragmented message acknowledged after %s (expected at %s)\n",
- GNUNET_STRINGS_relative_time_to_string (delay,
- GNUNET_YES),
+ GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES),
GNUNET_STRINGS_absolute_time_to_string (frag_ctx->next_frag_time));
}
else
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Fragmented message acknowledged after %s (expected at %s)\n",
- GNUNET_STRINGS_relative_time_to_string (delay,
- GNUNET_YES),
+ GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES),
GNUNET_STRINGS_absolute_time_to_string (frag_ctx->next_frag_time));
}
@@ -1751,10 +1676,11 @@ fragmented_message_done (struct UDP_FragmentationContext *frag_ctx,
"# UDP, fragmented msgs, bytes payload, sent, success",
s->frag_ctx->payload_size,
GNUNET_NO);
- GNUNET_STATISTICS_update (plugin->env->stats,
- "# UDP, fragmented msgs, bytes overhead, sent, success",
- overhead,
- GNUNET_NO);
+ GNUNET_STATISTICS_update (
+ plugin->env->stats,
+ "# UDP, fragmented msgs, bytes overhead, sent, success",
+ overhead,
+ GNUNET_NO);
GNUNET_STATISTICS_update (plugin->env->stats,
"# UDP, total, bytes overhead, sent",
overhead,
@@ -1786,41 +1712,35 @@ fragmented_message_done (struct UDP_FragmentationContext *frag_ctx,
/* Remove remaining fragments from queue, no need to transmit those
any longer. */
- if (s->address->address_length == sizeof(struct IPv6UdpAddress))
+ if (s->address->address_length == sizeof (struct IPv6UdpAddress))
{
udpw = plugin->ipv6_queue_head;
while (NULL != udpw)
{
tmp = udpw->next;
- if ( (udpw->frag_ctx != NULL) &&
- (udpw->frag_ctx == frag_ctx) )
+ if ((udpw->frag_ctx != NULL) && (udpw->frag_ctx == frag_ctx))
{
- dequeue (plugin,
- udpw);
- GNUNET_free (udpw);
+ dequeue (plugin, udpw);
+ GNUNET_free (udpw);
}
udpw = tmp;
}
}
- if (s->address->address_length == sizeof(struct IPv4UdpAddress))
+ if (s->address->address_length == sizeof (struct IPv4UdpAddress))
{
udpw = plugin->ipv4_queue_head;
while (NULL != udpw)
{
tmp = udpw->next;
- if ( (NULL != udpw->frag_ctx) &&
- (udpw->frag_ctx == frag_ctx) )
+ if ((NULL != udpw->frag_ctx) && (udpw->frag_ctx == frag_ctx))
{
- dequeue (plugin,
- udpw);
+ dequeue (plugin, udpw);
GNUNET_free (udpw);
}
udpw = tmp;
}
}
- notify_session_monitor (s->plugin,
- s,
- GNUNET_TRANSPORT_SS_UPDATE);
+ notify_session_monitor (s->plugin, s, GNUNET_TRANSPORT_SS_UPDATE);
GNUNET_FRAGMENT_context_destroy (frag_ctx->frag,
&s->last_expected_msg_delay,
&s->last_expected_ack_delay);
@@ -1838,9 +1758,7 @@ fragmented_message_done (struct UDP_FragmentationContext *frag_ctx,
* @param result #GNUNET_OK on success, #GNUNET_SYSERR on failure
*/
static void
-qc_fragment_sent (void *cls,
- struct UDP_MessageWrapper *udpw,
- int result)
+qc_fragment_sent (void *cls, struct UDP_MessageWrapper *udpw, int result)
{
struct Plugin *plugin = cls;
@@ -1856,10 +1774,11 @@ qc_fragment_sent (void *cls,
"# UDP, fragmented msgs, fragments, sent, success",
1,
GNUNET_NO);
- GNUNET_STATISTICS_update (plugin->env->stats,
- "# UDP, fragmented msgs, fragments bytes, sent, success",
- udpw->msg_size,
- GNUNET_NO);
+ GNUNET_STATISTICS_update (
+ plugin->env->stats,
+ "# UDP, fragmented msgs, fragments bytes, sent, success",
+ udpw->msg_size,
+ GNUNET_NO);
}
else
{
@@ -1867,16 +1786,16 @@ qc_fragment_sent (void *cls,
"Failed to transmit fragment of message with %u bytes to %s\n",
(unsigned int) udpw->payload_size,
GNUNET_i2s (&udpw->session->target));
- fragmented_message_done (udpw->frag_ctx,
- GNUNET_SYSERR);
+ fragmented_message_done (udpw->frag_ctx, GNUNET_SYSERR);
GNUNET_STATISTICS_update (plugin->env->stats,
"# UDP, fragmented msgs, fragments, sent, failure",
1,
GNUNET_NO);
- GNUNET_STATISTICS_update (plugin->env->stats,
- "# UDP, fragmented msgs, fragments bytes, sent, failure",
- udpw->msg_size,
- GNUNET_NO);
+ GNUNET_STATISTICS_update (
+ plugin->env->stats,
+ "# UDP, fragmented msgs, fragments bytes, sent, failure",
+ udpw->msg_size,
+ GNUNET_NO);
}
}
@@ -1891,8 +1810,7 @@ qc_fragment_sent (void *cls,
* @param msg the message that was created
*/
static void
-enqueue_fragment (void *cls,
- const struct GNUNET_MessageHeader *msg)
+enqueue_fragment (void *cls, const struct GNUNET_MessageHeader *msg)
{
struct UDP_FragmentationContext *frag_ctx = cls;
struct Plugin *plugin = frag_ctx->plugin;
@@ -1900,9 +1818,7 @@ enqueue_fragment (void *cls,
struct GNUNET_ATS_Session *session = frag_ctx->session;
size_t msg_len = ntohs (msg->size);
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Enqueuing fragment with %u bytes\n",
- msg_len);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Enqueuing fragment with %u bytes\n", msg_len);
udpw = GNUNET_malloc (sizeof (struct UDP_MessageWrapper) + msg_len);
udpw->session = session;
udpw->msg_buf = (char *) &udpw[1];
@@ -1911,17 +1827,14 @@ enqueue_fragment (void *cls,
udpw->timeout = frag_ctx->timeout;
udpw->start_time = frag_ctx->start_time;
udpw->transmission_time = frag_ctx->next_frag_time;
- frag_ctx->next_frag_time
- = GNUNET_TIME_absolute_add (frag_ctx->next_frag_time,
- frag_ctx->flow_delay_from_other_peer);
+ frag_ctx->next_frag_time =
+ GNUNET_TIME_absolute_add (frag_ctx->next_frag_time,
+ frag_ctx->flow_delay_from_other_peer);
udpw->frag_ctx = frag_ctx;
udpw->qc = &qc_fragment_sent;
udpw->qc_cls = plugin;
- GNUNET_memcpy (udpw->msg_buf,
- msg,
- msg_len);
- enqueue (plugin,
- udpw);
+ GNUNET_memcpy (udpw->msg_buf, msg, msg_len);
+ enqueue (plugin, udpw);
if (session->address->address_length == sizeof (struct IPv4UdpAddress))
schedule_select_v4 (plugin);
else
@@ -1938,9 +1851,7 @@ enqueue_fragment (void *cls,
* @param result #GNUNET_OK on success, #GNUNET_SYSERR on failure
*/
static void
-qc_message_sent (void *cls,
- struct UDP_MessageWrapper *udpw,
- int result)
+qc_message_sent (void *cls, struct UDP_MessageWrapper *udpw, int result)
{
struct Plugin *plugin = cls;
size_t overhead;
@@ -1958,15 +1869,13 @@ qc_message_sent (void *cls,
{
LOG (GNUNET_ERROR_TYPE_WARNING,
"Message sent via UDP with delay of %s\n",
- GNUNET_STRINGS_relative_time_to_string (delay,
- GNUNET_YES));
+ GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES));
}
else
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Message sent via UDP with delay of %s\n",
- GNUNET_STRINGS_relative_time_to_string (delay,
- GNUNET_YES));
+ GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES));
}
udpw->cont (udpw->cont_cls,
&udpw->session->target,
@@ -1980,14 +1889,16 @@ qc_message_sent (void *cls,
"# UDP, unfragmented msgs, messages, sent, success",
1,
GNUNET_NO);
- GNUNET_STATISTICS_update (plugin->env->stats,
- "# UDP, unfragmented msgs, bytes payload, sent, success",
- udpw->payload_size,
- GNUNET_NO);
- GNUNET_STATISTICS_update (plugin->env->stats,
- "# UDP, unfragmented msgs, bytes overhead, sent, success",
- overhead,
- GNUNET_NO);
+ GNUNET_STATISTICS_update (
+ plugin->env->stats,
+ "# UDP, unfragmented msgs, bytes payload, sent, success",
+ udpw->payload_size,
+ GNUNET_NO);
+ GNUNET_STATISTICS_update (
+ plugin->env->stats,
+ "# UDP, unfragmented msgs, bytes overhead, sent, success",
+ overhead,
+ GNUNET_NO);
GNUNET_STATISTICS_update (plugin->env->stats,
"# UDP, total, bytes overhead, sent",
overhead,
@@ -2003,14 +1914,16 @@ qc_message_sent (void *cls,
"# UDP, unfragmented msgs, messages, sent, failure",
1,
GNUNET_NO);
- GNUNET_STATISTICS_update (plugin->env->stats,
- "# UDP, unfragmented msgs, bytes payload, sent, failure",
- udpw->payload_size,
- GNUNET_NO);
- GNUNET_STATISTICS_update (plugin->env->stats,
- "# UDP, unfragmented msgs, bytes overhead, sent, failure",
- overhead,
- GNUNET_NO);
+ GNUNET_STATISTICS_update (
+ plugin->env->stats,
+ "# UDP, unfragmented msgs, bytes payload, sent, failure",
+ udpw->payload_size,
+ GNUNET_NO);
+ GNUNET_STATISTICS_update (
+ plugin->env->stats,
+ "# UDP, unfragmented msgs, bytes overhead, sent, failure",
+ overhead,
+ GNUNET_NO);
}
}
@@ -2053,18 +1966,18 @@ udp_plugin_send (void *cls,
void *cont_cls)
{
struct Plugin *plugin = cls;
- size_t udpmlen = msgbuf_size + sizeof(struct UDPMessage);
+ size_t udpmlen = msgbuf_size + sizeof (struct UDPMessage);
struct UDP_FragmentationContext *frag_ctx;
struct UDP_MessageWrapper *udpw;
struct UDPMessage *udp;
char mbuf[udpmlen] GNUNET_ALIGN;
struct GNUNET_TIME_Relative latency;
- if ( (sizeof(struct IPv6UdpAddress) == s->address->address_length) &&
- (NULL == plugin->sockv6) )
+ if ((sizeof (struct IPv6UdpAddress) == s->address->address_length) &&
+ (NULL == plugin->sockv6))
return GNUNET_SYSERR;
- if ( (sizeof(struct IPv4UdpAddress) == s->address->address_length) &&
- (NULL == plugin->sockv4) )
+ if ((sizeof (struct IPv4UdpAddress) == s->address->address_length) &&
+ (NULL == plugin->sockv4))
return GNUNET_SYSERR;
if (udpmlen >= GNUNET_MAX_MESSAGE_SIZE)
{
@@ -2112,22 +2025,19 @@ udp_plugin_send (void *cls,
udpw->start_time = GNUNET_TIME_absolute_get ();
udpw->timeout = GNUNET_TIME_relative_to_absolute (to);
udpw->transmission_time = s->last_transmit_time;
- s->last_transmit_time
- = GNUNET_TIME_absolute_add (s->last_transmit_time,
- s->flow_delay_from_other_peer);
+ s->last_transmit_time =
+ GNUNET_TIME_absolute_add (s->last_transmit_time,
+ s->flow_delay_from_other_peer);
udpw->cont = cont;
udpw->cont_cls = cont_cls;
udpw->frag_ctx = NULL;
udpw->qc = &qc_message_sent;
udpw->qc_cls = plugin;
- GNUNET_memcpy (udpw->msg_buf,
- udp,
- sizeof (struct UDPMessage));
- GNUNET_memcpy (&udpw->msg_buf[sizeof(struct UDPMessage)],
- msgbuf,
- msgbuf_size);
- enqueue (plugin,
- udpw);
+ GNUNET_memcpy (udpw->msg_buf, udp, sizeof (struct UDPMessage));
+ GNUNET_memcpy (&udpw->msg_buf[sizeof (struct UDPMessage)],
+ msgbuf,
+ msgbuf_size);
+ enqueue (plugin, udpw);
GNUNET_STATISTICS_update (plugin->env->stats,
"# UDP, unfragmented messages queued total",
1,
@@ -2146,9 +2056,7 @@ udp_plugin_send (void *cls,
/* fragmented message */
if (NULL != s->frag_ctx)
return GNUNET_SYSERR;
- GNUNET_memcpy (&udp[1],
- msgbuf,
- msgbuf_size);
+ GNUNET_memcpy (&udp[1], msgbuf, msgbuf_size);
frag_ctx = GNUNET_new (struct UDP_FragmentationContext);
frag_ctx->plugin = plugin;
frag_ctx->session = s;
@@ -2156,12 +2064,12 @@ udp_plugin_send (void *cls,
frag_ctx->cont_cls = cont_cls;
frag_ctx->start_time = GNUNET_TIME_absolute_get ();
frag_ctx->next_frag_time = s->last_transmit_time;
- frag_ctx->flow_delay_from_other_peer
- = GNUNET_TIME_relative_divide (s->flow_delay_from_other_peer,
- 1 + (msgbuf_size /
- UDP_MTU));
+ frag_ctx->flow_delay_from_other_peer =
+ GNUNET_TIME_relative_divide (s->flow_delay_from_other_peer,
+ 1 + (msgbuf_size / UDP_MTU));
frag_ctx->timeout = GNUNET_TIME_relative_to_absolute (to);
- frag_ctx->payload_size = msgbuf_size; /* unfragmented message size without UDP overhead */
+ frag_ctx->payload_size =
+ msgbuf_size; /* unfragmented message size without UDP overhead */
frag_ctx->on_wire_size = 0; /* bytes with UDP and fragmentation overhead */
frag_ctx->frag = GNUNET_FRAGMENT_context_create (plugin->env->stats,
UDP_MTU,
@@ -2177,15 +2085,13 @@ udp_plugin_send (void *cls,
if (latency.rel_value_us > GNUNET_CONSTANTS_LATENCY_WARN.rel_value_us)
LOG (GNUNET_ERROR_TYPE_WARNING,
"Enqueued fragments will take %s for transmission to %s (queue size: %u)\n",
- GNUNET_STRINGS_relative_time_to_string (latency,
- GNUNET_YES),
+ GNUNET_STRINGS_relative_time_to_string (latency, GNUNET_YES),
GNUNET_i2s (&s->target),
(unsigned int) s->msgs_in_queue);
else
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Enqueued fragments will take %s for transmission to %s (queue size: %u)\n",
- GNUNET_STRINGS_relative_time_to_string (latency,
- GNUNET_YES),
+ GNUNET_STRINGS_relative_time_to_string (latency, GNUNET_YES),
GNUNET_i2s (&s->target),
(unsigned int) s->msgs_in_queue);
@@ -2202,9 +2108,7 @@ udp_plugin_send (void *cls,
frag_ctx->payload_size,
GNUNET_NO);
}
- notify_session_monitor (s->plugin,
- s,
- GNUNET_TRANSPORT_SS_UPDATE);
+ notify_session_monitor (s->plugin, s, GNUNET_TRANSPORT_SS_UPDATE);
return udpmlen;
}
@@ -2236,7 +2140,6 @@ struct FindReceiveContext
* Number of bytes in @e udp_addr.
*/
size_t udp_addr_len;
-
};
@@ -2259,10 +2162,8 @@ find_receive_context (void *cls,
struct FindReceiveContext *frc = cls;
struct DefragContext *e = element;
- if ( (frc->udp_addr_len == e->udp_addr_len) &&
- (0 == memcmp (frc->udp_addr,
- e->udp_addr,
- frc->udp_addr_len)) )
+ if ((frc->udp_addr_len == e->udp_addr_len) &&
+ (0 == memcmp (frc->udp_addr, e->udp_addr, frc->udp_addr_len)))
{
frc->rc = e;
return GNUNET_NO;
@@ -2280,8 +2181,7 @@ find_receive_context (void *cls,
* @return #GNUNET_OK on success
*/
static int
-udp_disconnect_session (void *cls,
- struct GNUNET_ATS_Session *s)
+udp_disconnect_session (void *cls, struct GNUNET_ATS_Session *s)
{
struct Plugin *plugin = cls;
struct UDP_MessageWrapper *udpw;
@@ -2304,13 +2204,11 @@ udp_disconnect_session (void *cls,
if (NULL != s->frag_ctx)
{
/* Remove fragmented message due to disconnect */
- fragmented_message_done (s->frag_ctx,
- GNUNET_SYSERR);
+ fragmented_message_done (s->frag_ctx, GNUNET_SYSERR);
}
- GNUNET_assert (GNUNET_YES ==
- GNUNET_CONTAINER_multipeermap_remove (plugin->sessions,
- &s->target,
- s));
+ GNUNET_assert (
+ GNUNET_YES ==
+ GNUNET_CONTAINER_multipeermap_remove (plugin->sessions, &s->target, s));
frc.rc = NULL;
frc.udp_addr = s->address->address;
frc.udp_addr_len = s->address->address_length;
@@ -2336,11 +2234,8 @@ udp_disconnect_session (void *cls,
next = udpw->next;
if (udpw->session == s)
{
- dequeue (plugin,
- udpw);
- udpw->qc (udpw->qc_cls,
- udpw,
- GNUNET_SYSERR);
+ dequeue (plugin, udpw);
+ udpw->qc (udpw->qc_cls, udpw, GNUNET_SYSERR);
GNUNET_free (udpw);
}
}
@@ -2350,16 +2245,12 @@ udp_disconnect_session (void *cls,
next = udpw->next;
if (udpw->session == s)
{
- dequeue (plugin,
- udpw);
- udpw->qc (udpw->qc_cls,
- udpw,
- GNUNET_SYSERR);
+ dequeue (plugin, udpw);
+ udpw->qc (udpw->qc_cls, udpw, GNUNET_SYSERR);
GNUNET_free (udpw);
}
}
- if ( (NULL != s->frag_ctx) &&
- (NULL != s->frag_ctx->cont) )
+ if ((NULL != s->frag_ctx) && (NULL != s->frag_ctx->cont))
{
/* The 'frag_ctx' itself will be freed in #free_session() a bit
later, as it might be in use right now */
@@ -2372,12 +2263,8 @@ udp_disconnect_session (void *cls,
s->frag_ctx->payload_size,
s->frag_ctx->on_wire_size);
}
- notify_session_monitor (s->plugin,
- s,
- GNUNET_TRANSPORT_SS_DONE);
- plugin->env->session_end (plugin->env->cls,
- s->address,
- s);
+ notify_session_monitor (s->plugin, s, GNUNET_TRANSPORT_SS_DONE);
+ plugin->env->session_end (plugin->env->cls, s->address, s);
GNUNET_STATISTICS_set (plugin->env->stats,
"# UDP sessions active",
GNUNET_CONTAINER_multipeermap_size (plugin->sessions),
@@ -2409,17 +2296,17 @@ read_process_ack (struct Plugin *plugin,
struct GNUNET_TIME_Relative flow_delay;
/* check message format */
- if (ntohs (msg->size)
- < sizeof(struct UDP_ACK_Message) + sizeof(struct GNUNET_MessageHeader))
+ if (ntohs (msg->size) <
+ sizeof (struct UDP_ACK_Message) + sizeof (struct GNUNET_MessageHeader))
{
GNUNET_break_op (0);
return;
}
udp_ack = (const struct UDP_ACK_Message *) msg;
ack = (const struct GNUNET_MessageHeader *) &udp_ack[1];
- if (ntohs (ack->size) != ntohs (msg->size) - sizeof(struct UDP_ACK_Message))
+ if (ntohs (ack->size) != ntohs (msg->size) - sizeof (struct UDP_ACK_Message))
{
- GNUNET_break_op(0);
+ GNUNET_break_op (0);
return;
}
@@ -2429,8 +2316,7 @@ read_process_ack (struct Plugin *plugin,
udp_addr,
udp_addr_len,
GNUNET_HELLO_ADDRESS_INFO_NONE);
- s = udp_plugin_lookup_session (plugin,
- address);
+ s = udp_plugin_lookup_session (plugin, address);
if (NULL == s)
{
LOG (GNUNET_ERROR_TYPE_WARNING,
@@ -2461,39 +2347,32 @@ read_process_ack (struct Plugin *plugin,
LOG (GNUNET_ERROR_TYPE_INFO,
"Asked to disconnect UDP session of %s\n",
GNUNET_i2s (&udp_ack->sender));
- udp_disconnect_session (plugin,
- s);
+ udp_disconnect_session (plugin, s);
return;
}
flow_delay.rel_value_us = (uint64_t) ntohl (udp_ack->delay);
if (flow_delay.rel_value_us > GNUNET_CONSTANTS_LATENCY_WARN.rel_value_us)
LOG (GNUNET_ERROR_TYPE_WARNING,
"We received a sending delay of %s for %s\n",
- GNUNET_STRINGS_relative_time_to_string (flow_delay,
- GNUNET_YES),
+ GNUNET_STRINGS_relative_time_to_string (flow_delay, GNUNET_YES),
GNUNET_i2s (&udp_ack->sender));
else
LOG (GNUNET_ERROR_TYPE_DEBUG,
"We received a sending delay of %s for %s\n",
- GNUNET_STRINGS_relative_time_to_string (flow_delay,
- GNUNET_YES),
+ GNUNET_STRINGS_relative_time_to_string (flow_delay, GNUNET_YES),
GNUNET_i2s (&udp_ack->sender));
/* Flow delay is for the reassembled packet, however, our delay
is per packet, so we need to adjust: */
s->flow_delay_from_other_peer = flow_delay;
/* Handle ACK */
- if (GNUNET_OK !=
- GNUNET_FRAGMENT_process_ack (s->frag_ctx->frag,
- ack))
+ if (GNUNET_OK != GNUNET_FRAGMENT_process_ack (s->frag_ctx->frag, ack))
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"UDP processes %u-byte acknowledgement from `%s' at `%s'\n",
(unsigned int) ntohs (msg->size),
GNUNET_i2s (&udp_ack->sender),
- udp_address_to_string (plugin,
- udp_addr,
- udp_addr_len));
+ udp_address_to_string (plugin, udp_addr, udp_addr_len));
/* Expect more ACKs to arrive */
return;
}
@@ -2502,11 +2381,8 @@ read_process_ack (struct Plugin *plugin,
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Message from %s at %s full ACK'ed\n",
GNUNET_i2s (&udp_ack->sender),
- udp_address_to_string (plugin,
- udp_addr,
- udp_addr_len));
- fragmented_message_done (s->frag_ctx,
- GNUNET_OK);
+ udp_address_to_string (plugin, udp_addr, udp_addr_len));
+ fragmented_message_done (s->frag_ctx, GNUNET_OK);
}
@@ -2528,11 +2404,8 @@ process_inbound_tokenized_messages (void *cls,
if (GNUNET_YES == session->in_destroy)
return GNUNET_OK;
reschedule_session_timeout (session);
- session->flow_delay_for_other_peer
- = plugin->env->receive (plugin->env->cls,
- session->address,
- session,
- hdr);
+ session->flow_delay_for_other_peer =
+ plugin->env->receive (plugin->env->cls, session->address, session, hdr);
return GNUNET_OK;
}
@@ -2552,8 +2425,7 @@ disconnect_and_free_it (void *cls,
{
struct Plugin *plugin = cls;
- udp_disconnect_session (plugin,
- value);
+ udp_disconnect_session (plugin, value);
return GNUNET_OK;
}
@@ -2567,8 +2439,7 @@ disconnect_and_free_it (void *cls,
* @return #GNUNET_OK on success, #GNUNET_SYSERR if the operation failed
*/
static void
-udp_disconnect (void *cls,
- const struct GNUNET_PeerIdentity *target)
+udp_disconnect (void *cls, const struct GNUNET_PeerIdentity *target)
{
struct Plugin *plugin = cls;
@@ -2600,12 +2471,8 @@ session_timeout (void *cls)
{
/* not actually our turn yet, but let's at least update
the monitor, it may think we're about to die ... */
- notify_session_monitor (s->plugin,
- s,
- GNUNET_TRANSPORT_SS_UPDATE);
- s->timeout_task = GNUNET_SCHEDULER_add_delayed (left,
- &session_timeout,
- s);
+ notify_session_monitor (s->plugin, s, GNUNET_TRANSPORT_SS_UPDATE);
+ s->timeout_task = GNUNET_SCHEDULER_add_delayed (left, &session_timeout, s);
return;
}
LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -2614,8 +2481,7 @@ session_timeout (void *cls)
GNUNET_STRINGS_relative_time_to_string (UDP_SESSION_TIME_OUT,
GNUNET_YES));
/* call session destroy function */
- udp_disconnect_session (plugin,
- s);
+ udp_disconnect_session (plugin, s);
}
@@ -2639,21 +2505,19 @@ udp_plugin_create_session (void *cls,
struct GNUNET_ATS_Session *s;
s = GNUNET_new (struct GNUNET_ATS_Session);
- s->mst = GNUNET_MST_create (&process_inbound_tokenized_messages,
- s);
+ s->mst = GNUNET_MST_create (&process_inbound_tokenized_messages, s);
s->plugin = plugin;
s->address = GNUNET_HELLO_address_copy (address);
s->target = address->peer;
s->last_transmit_time = GNUNET_TIME_absolute_get ();
- s->last_expected_ack_delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS,
- 250);
+ s->last_expected_ack_delay =
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 250);
s->last_expected_msg_delay = GNUNET_TIME_UNIT_MILLISECONDS;
s->flow_delay_from_other_peer = GNUNET_TIME_UNIT_ZERO;
s->flow_delay_for_other_peer = GNUNET_TIME_UNIT_ZERO;
s->timeout = GNUNET_TIME_relative_to_absolute (UDP_SESSION_TIME_OUT);
- s->timeout_task = GNUNET_SCHEDULER_add_delayed (UDP_SESSION_TIME_OUT,
- &session_timeout,
- s);
+ s->timeout_task =
+ GNUNET_SCHEDULER_add_delayed (UDP_SESSION_TIME_OUT, &session_timeout, s);
s->scope = network_type;
LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -2663,18 +2527,16 @@ udp_plugin_create_session (void *cls,
udp_address_to_string (plugin,
address->address,
address->address_length));
- GNUNET_assert (GNUNET_OK ==
- GNUNET_CONTAINER_multipeermap_put (plugin->sessions,
- &s->target,
- s,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE));
+ GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multipeermap_put (
+ plugin->sessions,
+ &s->target,
+ s,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE));
GNUNET_STATISTICS_set (plugin->env->stats,
"# UDP sessions active",
GNUNET_CONTAINER_multipeermap_size (plugin->sessions),
GNUNET_NO);
- notify_session_monitor (plugin,
- s,
- GNUNET_TRANSPORT_SS_INIT);
+ notify_session_monitor (plugin, s, GNUNET_TRANSPORT_SS_INIT);
return s;
}
@@ -2688,8 +2550,7 @@ udp_plugin_create_session (void *cls,
* @return the session or NULL of max connections exceeded
*/
static struct GNUNET_ATS_Session *
-udp_plugin_get_session (void *cls,
- const struct GNUNET_HELLO_Address *address)
+udp_plugin_get_session (void *cls, const struct GNUNET_HELLO_Address *address)
{
struct Plugin *plugin = cls;
struct GNUNET_ATS_Session *s;
@@ -2702,14 +2563,13 @@ udp_plugin_get_session (void *cls,
GNUNET_break (0);
return NULL;
}
- if ( (address->address_length != sizeof(struct IPv4UdpAddress)) &&
- (address->address_length != sizeof(struct IPv6UdpAddress)) )
+ if ((address->address_length != sizeof (struct IPv4UdpAddress)) &&
+ (address->address_length != sizeof (struct IPv6UdpAddress)))
{
GNUNET_break_op (0);
return NULL;
}
- if (NULL != (s = udp_plugin_lookup_session (cls,
- address)))
+ if (NULL != (s = udp_plugin_lookup_session (cls, address)))
return s;
/* need to create new session */
@@ -2746,9 +2606,7 @@ udp_plugin_get_session (void *cls,
sizeof (v6));
}
GNUNET_break (GNUNET_NT_UNSPECIFIED != network_type);
- return udp_plugin_create_session (cls,
- address,
- network_type);
+ return udp_plugin_create_session (cls, address, network_type);
}
@@ -2774,13 +2632,13 @@ process_udp_message (struct Plugin *plugin,
GNUNET_break (GNUNET_NT_UNSPECIFIED != network_type);
if (0 != ntohl (msg->reserved))
{
- GNUNET_break_op(0);
+ GNUNET_break_op (0);
return;
}
- if (ntohs (msg->header.size)
- < sizeof(struct GNUNET_MessageHeader) + sizeof(struct UDPMessage))
+ if (ntohs (msg->header.size) <
+ sizeof (struct GNUNET_MessageHeader) + sizeof (struct UDPMessage))
{
- GNUNET_break_op(0);
+ GNUNET_break_op (0);
return;
}
@@ -2789,32 +2647,22 @@ process_udp_message (struct Plugin *plugin,
udp_addr,
udp_addr_len,
GNUNET_HELLO_ADDRESS_INFO_NONE);
- if (NULL ==
- (s = udp_plugin_lookup_session (plugin,
- address)))
+ if (NULL == (s = udp_plugin_lookup_session (plugin, address)))
{
- s = udp_plugin_create_session (plugin,
- address,
- network_type);
- plugin->env->session_start (plugin->env->cls,
- address,
- s,
- s->scope);
- notify_session_monitor (plugin,
- s,
- GNUNET_TRANSPORT_SS_UP);
+ s = udp_plugin_create_session (plugin, address, network_type);
+ plugin->env->session_start (plugin->env->cls, address, s, s->scope);
+ notify_session_monitor (plugin, s, GNUNET_TRANSPORT_SS_UP);
}
GNUNET_free (address);
s->rc++;
GNUNET_MST_from_buffer (s->mst,
(const char *) &msg[1],
- ntohs (msg->header.size) - sizeof(struct UDPMessage),
+ ntohs (msg->header.size) - sizeof (struct UDPMessage),
GNUNET_YES,
GNUNET_NO);
s->rc--;
- if ( (0 == s->rc) &&
- (GNUNET_YES == s->in_destroy) )
+ if ((0 == s->rc) && (GNUNET_YES == s->in_destroy))
free_session (s);
}
@@ -2826,8 +2674,7 @@ process_udp_message (struct Plugin *plugin,
* @param msg the message
*/
static void
-fragment_msg_proc (void *cls,
- const struct GNUNET_MessageHeader *msg)
+fragment_msg_proc (void *cls, const struct GNUNET_MessageHeader *msg)
{
struct DefragContext *dc = cls;
const struct UDPMessage *um;
@@ -2837,7 +2684,7 @@ fragment_msg_proc (void *cls,
GNUNET_break_op (0);
return;
}
- if (ntohs (msg->size) < sizeof(struct UDPMessage))
+ if (ntohs (msg->size) < sizeof (struct UDPMessage))
{
GNUNET_break_op (0);
return;
@@ -2863,9 +2710,7 @@ fragment_msg_proc (void *cls,
* #GNUNET_SYSERR if we failed to send the ACK
*/
static void
-ack_message_sent (void *cls,
- struct UDP_MessageWrapper *udpw,
- int result)
+ack_message_sent (void *cls, struct UDP_MessageWrapper *udpw, int result)
{
struct Plugin *plugin = cls;
@@ -2894,13 +2739,11 @@ ack_message_sent (void *cls,
* @param msg ack to transmit
*/
static void
-ack_proc (void *cls,
- uint32_t id,
- const struct GNUNET_MessageHeader *msg)
+ack_proc (void *cls, uint32_t id, const struct GNUNET_MessageHeader *msg)
{
struct DefragContext *rc = cls;
struct Plugin *plugin = rc->plugin;
- size_t msize = sizeof(struct UDP_ACK_Message) + ntohs (msg->size);
+ size_t msize = sizeof (struct UDP_ACK_Message) + ntohs (msg->size);
struct UDP_ACK_Message *udp_ack;
uint32_t delay;
struct UDP_MessageWrapper *udpw;
@@ -2922,16 +2765,13 @@ ack_proc (void *cls,
rc->udp_addr,
rc->udp_addr_len,
GNUNET_HELLO_ADDRESS_INFO_NONE);
- s = udp_plugin_lookup_session (plugin,
- address);
+ s = udp_plugin_lookup_session (plugin, address);
GNUNET_HELLO_address_free (address);
if (NULL == s)
{
LOG (GNUNET_ERROR_TYPE_ERROR,
"Trying to transmit ACK to peer `%s' but no session found!\n",
- udp_address_to_string (plugin,
- rc->udp_addr,
- rc->udp_addr_len));
+ udp_address_to_string (plugin, rc->udp_addr, rc->udp_addr_len));
GNUNET_CONTAINER_heap_remove_node (rc->hnode);
GNUNET_DEFRAGMENT_context_destroy (rc->defrag);
GNUNET_free (rc);
@@ -2950,9 +2790,7 @@ ack_proc (void *cls,
delay = UINT32_MAX - 1; /* largest value we can communicate */
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Sending ACK to `%s' including delay of %s\n",
- udp_address_to_string (plugin,
- rc->udp_addr,
- rc->udp_addr_len),
+ udp_address_to_string (plugin, rc->udp_addr, rc->udp_addr_len),
GNUNET_STRINGS_relative_time_to_string (s->flow_delay_for_other_peer,
GNUNET_YES));
udpw = GNUNET_malloc (sizeof (struct UDP_MessageWrapper) + msize);
@@ -2969,14 +2807,9 @@ ack_proc (void *cls,
udp_ack->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_ACK);
udp_ack->delay = htonl (delay);
udp_ack->sender = *plugin->env->my_identity;
- GNUNET_memcpy (&udp_ack[1],
- msg,
- ntohs (msg->size));
- enqueue (plugin,
- udpw);
- notify_session_monitor (plugin,
- s,
- GNUNET_TRANSPORT_SS_UPDATE);
+ GNUNET_memcpy (&udp_ack[1], msg, ntohs (msg->size));
+ enqueue (plugin, udpw);
+ notify_session_monitor (plugin, s, GNUNET_TRANSPORT_SS_UPDATE);
if (s->address->address_length == sizeof (struct IPv4UdpAddress))
schedule_select_v4 (plugin);
else
@@ -3019,46 +2852,41 @@ read_process_fragment (struct Plugin *plugin,
{
/* Create a new defragmentation context */
d_ctx = GNUNET_malloc (sizeof (struct DefragContext) + udp_addr_len);
- GNUNET_memcpy (&d_ctx[1],
- udp_addr,
- udp_addr_len);
+ GNUNET_memcpy (&d_ctx[1], udp_addr, udp_addr_len);
d_ctx->udp_addr = (const union UdpAddress *) &d_ctx[1];
d_ctx->udp_addr_len = udp_addr_len;
d_ctx->network_type = network_type;
d_ctx->plugin = plugin;
- d_ctx->defrag = GNUNET_DEFRAGMENT_context_create (plugin->env->stats,
- UDP_MTU,
- UDP_MAX_MESSAGES_IN_DEFRAG,
- d_ctx,
- &fragment_msg_proc,
- &ack_proc);
+ d_ctx->defrag =
+ GNUNET_DEFRAGMENT_context_create (plugin->env->stats,
+ UDP_MTU,
+ UDP_MAX_MESSAGES_IN_DEFRAG,
+ d_ctx,
+ &fragment_msg_proc,
+ &ack_proc);
d_ctx->hnode = GNUNET_CONTAINER_heap_insert (plugin->defrag_ctxs,
d_ctx,
- (GNUNET_CONTAINER_HeapCostType) now.abs_value_us);
+ (GNUNET_CONTAINER_HeapCostType)
+ now.abs_value_us);
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Created new defragmentation context for %u-byte fragment from `%s'\n",
(unsigned int) ntohs (msg->size),
- udp_address_to_string (plugin,
- udp_addr,
- udp_addr_len));
+ udp_address_to_string (plugin, udp_addr, udp_addr_len));
}
else
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Found existing defragmentation context for %u-byte fragment from `%s'\n",
(unsigned int) ntohs (msg->size),
- udp_address_to_string (plugin,
- udp_addr,
- udp_addr_len));
+ udp_address_to_string (plugin, udp_addr, udp_addr_len));
}
- if (GNUNET_OK ==
- GNUNET_DEFRAGMENT_process_fragment (d_ctx->defrag,
- msg))
+ if (GNUNET_OK == GNUNET_DEFRAGMENT_process_fragment (d_ctx->defrag, msg))
{
/* keep this 'rc' from expiring */
GNUNET_CONTAINER_heap_update_cost (d_ctx->hnode,
- (GNUNET_CONTAINER_HeapCostType) now.abs_value_us);
+ (GNUNET_CONTAINER_HeapCostType)
+ now.abs_value_us);
}
if (GNUNET_CONTAINER_heap_get_size (plugin->defrag_ctxs) >
UDP_MAX_SENDER_ADDRESSES_WITH_DEFRAG)
@@ -3083,8 +2911,7 @@ read_process_fragment (struct Plugin *plugin,
* @param rsock socket to read from
*/
static void
-udp_select_read (struct Plugin *plugin,
- struct GNUNET_NETWORK_Handle *rsock)
+udp_select_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock)
{
socklen_t fromlen;
struct sockaddr_storage addr;
@@ -3101,9 +2928,7 @@ udp_select_read (struct Plugin *plugin,
enum GNUNET_NetworkType network_type;
fromlen = sizeof (addr);
- memset (&addr,
- 0,
- sizeof(addr));
+ memset (&addr, 0, sizeof (addr));
size = GNUNET_NETWORK_socket_recvfrom (rsock,
buf,
sizeof (buf),
@@ -3121,15 +2946,14 @@ udp_select_read (struct Plugin *plugin,
* error indicates a previous send operation resulted in an ICMP Port
* Unreachable message.
*/
- if ( (-1 == size) &&
- (ECONNRESET == errno) )
+ if ((-1 == size) && (ECONNRESET == errno))
return;
#endif
if (-1 == size)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"UDP failed to receive data: %s\n",
- STRERROR (errno));
+ strerror (errno));
/* Connection failure or something. Not a protocol violation. */
return;
}
@@ -3137,19 +2961,18 @@ udp_select_read (struct Plugin *plugin,
/* Check if this is a STUN packet */
if (GNUNET_NO !=
GNUNET_NAT_stun_handle_packet (plugin->nat,
- (const struct sockaddr *) &addr,
- fromlen,
- buf,
- size))
+ (const struct sockaddr *) &addr,
+ fromlen,
+ buf,
+ size))
return; /* was STUN, do not process further */
- if (size < sizeof(struct GNUNET_MessageHeader))
+ if (size < sizeof (struct GNUNET_MessageHeader))
{
LOG (GNUNET_ERROR_TYPE_WARNING,
"UDP got %u bytes from %s, which is not enough for a GNUnet message header\n",
- (unsigned int ) size,
- GNUNET_a2s (sa,
- fromlen));
+ (unsigned int) size,
+ GNUNET_a2s (sa, fromlen));
/* _MAY_ be a connection failure (got partial message) */
/* But it _MAY_ also be that the other side uses non-GNUnet protocol. */
GNUNET_break_op (0);
@@ -3160,16 +2983,14 @@ udp_select_read (struct Plugin *plugin,
LOG (GNUNET_ERROR_TYPE_DEBUG,
"UDP received %u-byte message from `%s' type %u\n",
(unsigned int) size,
- GNUNET_a2s (sa,
- fromlen),
+ GNUNET_a2s (sa, fromlen),
ntohs (msg->type));
if (size != ntohs (msg->size))
{
LOG (GNUNET_ERROR_TYPE_WARNING,
"UDP malformed message (size %u) header from %s\n",
(unsigned int) size,
- GNUNET_a2s (sa,
- fromlen));
+ GNUNET_a2s (sa, fromlen));
GNUNET_break_op (0);
return;
}
@@ -3177,9 +2998,7 @@ udp_select_read (struct Plugin *plugin,
"# UDP, total bytes received",
size,
GNUNET_NO);
- network_type = plugin->env->get_address_type (plugin->env->cls,
- sa,
- fromlen);
+ network_type = plugin->env->get_address_type (plugin->env->cls, sa, fromlen);
switch (sa->sa_family)
{
case AF_INET:
@@ -3215,9 +3034,9 @@ udp_select_read (struct Plugin *plugin,
network_type);
return;
case GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_MESSAGE:
- if (ntohs (msg->size) < sizeof(struct UDPMessage))
+ if (ntohs (msg->size) < sizeof (struct UDPMessage))
{
- GNUNET_break_op(0);
+ GNUNET_break_op (0);
return;
}
process_udp_message (plugin,
@@ -3227,20 +3046,13 @@ udp_select_read (struct Plugin *plugin,
network_type);
return;
case GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_ACK:
- read_process_ack (plugin,
- msg,
- int_addr,
- int_addr_len);
+ read_process_ack (plugin, msg, int_addr, int_addr_len);
return;
case GNUNET_MESSAGE_TYPE_FRAGMENT:
- read_process_fragment (plugin,
- msg,
- int_addr,
- int_addr_len,
- network_type);
+ read_process_fragment (plugin, msg, int_addr, int_addr_len, network_type);
return;
default:
- GNUNET_break_op(0);
+ GNUNET_break_op (0);
return;
}
}
@@ -3265,9 +3077,8 @@ remove_timeout_messages_and_select (struct Plugin *plugin,
int removed;
removed = GNUNET_NO;
- udpw = (sock == plugin->sockv4)
- ? plugin->ipv4_queue_head
- : plugin->ipv6_queue_head;
+ udpw = (sock == plugin->sockv4) ? plugin->ipv4_queue_head
+ : plugin->ipv6_queue_head;
while (NULL != udpw)
{
session = udpw->session;
@@ -3277,11 +3088,8 @@ remove_timeout_messages_and_select (struct Plugin *plugin,
{
/* Message timed out */
removed = GNUNET_YES;
- dequeue (plugin,
- udpw);
- udpw->qc (udpw->qc_cls,
- udpw,
- GNUNET_SYSERR);
+ dequeue (plugin, udpw);
+ udpw->qc (udpw->qc_cls, udpw, GNUNET_SYSERR);
GNUNET_free (udpw);
if (sock == plugin->sockv4)
@@ -3321,9 +3129,8 @@ remove_timeout_messages_and_select (struct Plugin *plugin,
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Message for peer `%s' (%u bytes) is delayed for %s\n",
GNUNET_i2s (&udpw->session->target),
- udpw->payload_size,
- GNUNET_STRINGS_relative_time_to_string (remaining,
- GNUNET_YES));
+ udpw->payload_size,
+ GNUNET_STRINGS_relative_time_to_string (remaining, GNUNET_YES));
udpw = udpw->next;
}
}
@@ -3353,13 +3160,9 @@ analyze_send_error (struct Plugin *plugin,
{
enum GNUNET_NetworkType type;
- type = plugin->env->get_address_type (plugin->env->cls,
- sa,
- slen);
- if ( ( (GNUNET_NT_LAN == type) ||
- (GNUNET_NT_WAN == type) ) &&
- ( (ENETUNREACH == errno) ||
- (ENETDOWN == errno) ) )
+ type = plugin->env->get_address_type (plugin->env->cls, sa, slen);
+ if (((GNUNET_NT_LAN == type) || (GNUNET_NT_WAN == type)) &&
+ ((ENETUNREACH == errno) || (ENETDOWN == errno)))
{
if (slen == sizeof (struct sockaddr_in))
{
@@ -3368,10 +3171,9 @@ analyze_send_error (struct Plugin *plugin,
* This indicates we do not have connectivity
*/
LOG (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK,
- _("UDP could not transmit message to `%s': "
- "Network seems down, please check your network configuration\n"),
- GNUNET_a2s (sa,
- slen));
+ _ ("UDP could not transmit message to `%s': "
+ "Network seems down, please check your network configuration\n"),
+ GNUNET_a2s (sa, slen));
}
if (slen == sizeof (struct sockaddr_in6))
{
@@ -3382,7 +3184,8 @@ analyze_send_error (struct Plugin *plugin,
* connectivity
*/
LOG (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK,
- _("UDP could not transmit IPv6 message! "
+ _ (
+ "UDP could not transmit IPv6 message! "
"Please check your network configuration and disable IPv6 if your "
"connection does not have a global IPv6 address\n"));
}
@@ -3391,9 +3194,8 @@ analyze_send_error (struct Plugin *plugin,
{
LOG (GNUNET_ERROR_TYPE_WARNING,
"UDP could not transmit message to `%s': `%s'\n",
- GNUNET_a2s (sa,
- slen),
- STRERROR (error));
+ GNUNET_a2s (sa, slen),
+ strerror (error));
}
}
@@ -3406,8 +3208,7 @@ analyze_send_error (struct Plugin *plugin,
* @param sock which socket (v4/v6) to send on
*/
static void
-udp_select_send (struct Plugin *plugin,
- struct GNUNET_NETWORK_Handle *sock)
+udp_select_send (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *sock)
{
ssize_t sent;
socklen_t slen;
@@ -3419,15 +3220,13 @@ udp_select_send (struct Plugin *plugin,
struct UDP_MessageWrapper *udpw;
/* Find message(s) to send */
- while (NULL != (udpw = remove_timeout_messages_and_select (plugin,
- sock)))
+ while (NULL != (udpw = remove_timeout_messages_and_select (plugin, sock)))
{
- if (sizeof (struct IPv4UdpAddress) == udpw->session->address->address_length)
+ if (sizeof (struct IPv4UdpAddress) ==
+ udpw->session->address->address_length)
{
u4 = udpw->session->address->address;
- memset (&a4,
- 0,
- sizeof(a4));
+ memset (&a4, 0, sizeof (a4));
a4.sin_family = AF_INET;
#if HAVE_SOCKADDR_IN_SIN_LEN
a4.sin_len = sizeof (a4);
@@ -3437,12 +3236,11 @@ udp_select_send (struct Plugin *plugin,
a = (const struct sockaddr *) &a4;
slen = sizeof (a4);
}
- else if (sizeof (struct IPv6UdpAddress) == udpw->session->address->address_length)
+ else if (sizeof (struct IPv6UdpAddress) ==
+ udpw->session->address->address_length)
{
u6 = udpw->session->address->address;
- memset (&a6,
- 0,
- sizeof(a6));
+ memset (&a6, 0, sizeof (a6));
a6.sin6_family = AF_INET6;
#if HAVE_SOCKADDR_IN_SIN_LEN
a6.sin6_len = sizeof (a6);
@@ -3455,11 +3253,8 @@ udp_select_send (struct Plugin *plugin,
else
{
GNUNET_break (0);
- dequeue (plugin,
- udpw);
- udpw->qc (udpw->qc_cls,
- udpw,
- GNUNET_SYSERR);
+ dequeue (plugin, udpw);
+ udpw->qc (udpw->qc_cls, udpw, GNUNET_SYSERR);
notify_session_monitor (plugin,
udpw->session,
GNUNET_TRANSPORT_SS_UPDATE);
@@ -3471,21 +3266,15 @@ udp_select_send (struct Plugin *plugin,
udpw->msg_size,
a,
slen);
- udpw->session->last_transmit_time
- = GNUNET_TIME_absolute_max (GNUNET_TIME_absolute_get (),
- udpw->session->last_transmit_time);
- dequeue (plugin,
- udpw);
+ udpw->session->last_transmit_time =
+ GNUNET_TIME_absolute_max (GNUNET_TIME_absolute_get (),
+ udpw->session->last_transmit_time);
+ dequeue (plugin, udpw);
if (GNUNET_SYSERR == sent)
{
/* Failure */
- analyze_send_error (plugin,
- a,
- slen,
- errno);
- udpw->qc (udpw->qc_cls,
- udpw,
- GNUNET_SYSERR);
+ analyze_send_error (plugin, a, slen, errno);
+ udpw->qc (udpw->qc_cls, udpw, GNUNET_SYSERR);
GNUNET_STATISTICS_update (plugin->env->stats,
"# UDP, total, bytes, sent, failure",
sent,
@@ -3502,10 +3291,9 @@ udp_select_send (struct Plugin *plugin,
"UDP transmitted %u-byte message to `%s' `%s' (%d: %s)\n",
(unsigned int) (udpw->msg_size),
GNUNET_i2s (&udpw->session->target),
- GNUNET_a2s (a,
- slen),
- (int ) sent,
- (sent < 0) ? STRERROR (errno) : "ok");
+ GNUNET_a2s (a, slen),
+ (int) sent,
+ (sent < 0) ? strerror (errno) : "ok");
GNUNET_STATISTICS_update (plugin->env->stats,
"# UDP, total, bytes, sent, success",
sent,
@@ -3516,13 +3304,9 @@ udp_select_send (struct Plugin *plugin,
GNUNET_NO);
if (NULL != udpw->frag_ctx)
udpw->frag_ctx->on_wire_size += udpw->msg_size;
- udpw->qc (udpw->qc_cls,
- udpw,
- GNUNET_OK);
+ udpw->qc (udpw->qc_cls, udpw, GNUNET_OK);
}
- notify_session_monitor (plugin,
- udpw->session,
- GNUNET_TRANSPORT_SS_UPDATE);
+ notify_session_monitor (plugin, udpw->session, GNUNET_TRANSPORT_SS_UPDATE);
GNUNET_free (udpw);
}
}
@@ -3549,12 +3333,9 @@ udp_plugin_select_v4 (void *cls)
return;
tc = GNUNET_SCHEDULER_get_task_context ();
if ((0 != (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY)) &&
- (GNUNET_NETWORK_fdset_isset (tc->read_ready,
- plugin->sockv4)))
- udp_select_read (plugin,
- plugin->sockv4);
- udp_select_send (plugin,
- plugin->sockv4);
+ (GNUNET_NETWORK_fdset_isset (tc->read_ready, plugin->sockv4)))
+ udp_select_read (plugin, plugin->sockv4);
+ udp_select_send (plugin, plugin->sockv4);
schedule_select_v4 (plugin);
}
@@ -3576,14 +3357,11 @@ udp_plugin_select_v6 (void *cls)
if (NULL == plugin->sockv6)
return;
tc = GNUNET_SCHEDULER_get_task_context ();
- if ( (0 != (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY)) &&
- (GNUNET_NETWORK_fdset_isset (tc->read_ready,
- plugin->sockv6)) )
- udp_select_read (plugin,
- plugin->sockv6);
-
- udp_select_send (plugin,
- plugin->sockv6);
+ if ((0 != (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY)) &&
+ (GNUNET_NETWORK_fdset_isset (tc->read_ready, plugin->sockv6)))
+ udp_select_read (plugin, plugin->sockv6);
+
+ udp_select_send (plugin, plugin->sockv6);
schedule_select_v6 (plugin);
}
@@ -3618,20 +3396,16 @@ setup_sockets (struct Plugin *plugin,
eno = EINVAL;
if (GNUNET_YES == plugin->enable_ipv6)
{
- plugin->sockv6 = GNUNET_NETWORK_socket_create (PF_INET6,
- SOCK_DGRAM,
- 0);
+ plugin->sockv6 = GNUNET_NETWORK_socket_create (PF_INET6, SOCK_DGRAM, 0);
if (NULL == plugin->sockv6)
{
LOG (GNUNET_ERROR_TYPE_INFO,
- _("Disabling IPv6 since it is not supported on this system!\n"));
+ _ ("Disabling IPv6 since it is not supported on this system!\n"));
plugin->enable_ipv6 = GNUNET_NO;
}
else
{
- memset (&server_addrv6,
- 0,
- sizeof(struct sockaddr_in6));
+ memset (&server_addrv6, 0, sizeof (struct sockaddr_in6));
#if HAVE_SOCKADDR_IN_SIN_LEN
server_addrv6.sin6_len = sizeof (struct sockaddr_in6);
#endif
@@ -3642,10 +3416,9 @@ setup_sockets (struct Plugin *plugin,
server_addrv6.sin6_addr = in6addr_any;
if (0 == plugin->port) /* autodetect */
- server_addrv6.sin6_port
- = htons (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG,
- 33537)
- + 32000);
+ server_addrv6.sin6_port = htons (
+ GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 33537) +
+ 32000);
else
server_addrv6.sin6_port = htons (plugin->port);
addrlen = sizeof (struct sockaddr_in6);
@@ -3654,15 +3427,12 @@ setup_sockets (struct Plugin *plugin,
tries = 0;
while (tries < 10)
{
- LOG(GNUNET_ERROR_TYPE_DEBUG,
- "Binding to IPv6 `%s'\n",
- GNUNET_a2s (server_addr,
- addrlen));
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Binding to IPv6 `%s'\n",
+ GNUNET_a2s (server_addr, addrlen));
/* binding */
if (GNUNET_OK ==
- GNUNET_NETWORK_socket_bind (plugin->sockv6,
- server_addr,
- addrlen))
+ GNUNET_NETWORK_socket_bind (plugin->sockv6, server_addr, addrlen))
break;
eno = errno;
if (0 != plugin->port)
@@ -3671,10 +3441,9 @@ setup_sockets (struct Plugin *plugin,
break; /* bind failed on specific port */
}
/* autodetect */
- server_addrv6.sin6_port
- = htons (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG,
- 33537)
- + 32000);
+ server_addrv6.sin6_port = htons (
+ GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 33537) +
+ 32000);
tries++;
}
if (tries >= 10)
@@ -3691,8 +3460,7 @@ setup_sockets (struct Plugin *plugin,
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"IPv6 UDP socket created listinging at %s\n",
- GNUNET_a2s (server_addr,
- addrlen));
+ GNUNET_a2s (server_addr, addrlen));
addrs[sockets_created] = server_addr;
addrlens[sockets_created] = addrlen;
sockets_created++;
@@ -3700,32 +3468,26 @@ setup_sockets (struct Plugin *plugin,
else
{
LOG (GNUNET_ERROR_TYPE_WARNING,
- _("Failed to bind UDP socket to %s: %s\n"),
- GNUNET_a2s (server_addr,
- addrlen),
- STRERROR (eno));
+ _ ("Failed to bind UDP socket to %s: %s\n"),
+ GNUNET_a2s (server_addr, addrlen),
+ strerror (eno));
}
}
}
/* Create IPv4 socket */
eno = EINVAL;
- plugin->sockv4 = GNUNET_NETWORK_socket_create (PF_INET,
- SOCK_DGRAM,
- 0);
+ plugin->sockv4 = GNUNET_NETWORK_socket_create (PF_INET, SOCK_DGRAM, 0);
if (NULL == plugin->sockv4)
{
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING,
- "socket");
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "socket");
LOG (GNUNET_ERROR_TYPE_INFO,
- _("Disabling IPv4 since it is not supported on this system!\n"));
+ _ ("Disabling IPv4 since it is not supported on this system!\n"));
plugin->enable_ipv4 = GNUNET_NO;
}
else
{
- memset (&server_addrv4,
- 0,
- sizeof(struct sockaddr_in));
+ memset (&server_addrv4, 0, sizeof (struct sockaddr_in));
#if HAVE_SOCKADDR_IN_SIN_LEN
server_addrv4.sin_len = sizeof (struct sockaddr_in);
#endif
@@ -3737,10 +3499,8 @@ setup_sockets (struct Plugin *plugin,
if (0 == plugin->port)
/* autodetect */
- server_addrv4.sin_port
- = htons (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG,
- 33537)
- + 32000);
+ server_addrv4.sin_port = htons (
+ GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000);
else
server_addrv4.sin_port = htons (plugin->port);
@@ -3752,14 +3512,11 @@ setup_sockets (struct Plugin *plugin,
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Binding to IPv4 `%s'\n",
- GNUNET_a2s (server_addr,
- addrlen));
+ GNUNET_a2s (server_addr, addrlen));
/* binding */
if (GNUNET_OK ==
- GNUNET_NETWORK_socket_bind (plugin->sockv4,
- server_addr,
- addrlen))
+ GNUNET_NETWORK_socket_bind (plugin->sockv4, server_addr, addrlen))
break;
eno = errno;
if (0 != plugin->port)
@@ -3769,10 +3526,8 @@ setup_sockets (struct Plugin *plugin,
}
/* autodetect */
- server_addrv4.sin_port
- = htons (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG,
- 33537)
- + 32000);
+ server_addrv4.sin_port = htons (
+ GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000);
tries++;
}
if (tries >= 10)
@@ -3790,8 +3545,7 @@ setup_sockets (struct Plugin *plugin,
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"IPv4 socket created on port %s\n",
- GNUNET_a2s (server_addr,
- addrlen));
+ GNUNET_a2s (server_addr, addrlen));
addrs[sockets_created] = server_addr;
addrlens[sockets_created] = addrlen;
sockets_created++;
@@ -3799,24 +3553,22 @@ setup_sockets (struct Plugin *plugin,
else
{
LOG (GNUNET_ERROR_TYPE_ERROR,
- _("Failed to bind UDP socket to %s: %s\n"),
- GNUNET_a2s (server_addr,
- addrlen),
- STRERROR (eno));
+ _ ("Failed to bind UDP socket to %s: %s\n"),
+ GNUNET_a2s (server_addr, addrlen),
+ strerror (eno));
}
}
if (0 == sockets_created)
{
- LOG (GNUNET_ERROR_TYPE_WARNING,
- _("Failed to open UDP sockets\n"));
+ LOG (GNUNET_ERROR_TYPE_WARNING, _ ("Failed to open UDP sockets\n"));
return 0; /* No sockets created, return */
}
schedule_select_v4 (plugin);
schedule_select_v6 (plugin);
plugin->nat = GNUNET_NAT_register (plugin->env->cfg,
- "transport-udp",
- IPPROTO_UDP,
+ "transport-udp",
+ IPPROTO_UDP,
sockets_created,
addrs,
addrlens,
@@ -3869,64 +3621,55 @@ libgnunet_plugin_transport_udp_init (void *cls)
/* Get port number: port == 0 : autodetect a port,
* > 0 : use this port, not given : 2086 default */
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_number (env->cfg,
- "transport-udp",
- "PORT",
- &port))
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (env->cfg,
+ "transport-udp",
+ "PORT",
+ &port))
port = 2086;
if (port > 65535)
{
GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
"transport-udp",
"PORT",
- _("must be in [0,65535]"));
+ _ ("must be in [0,65535]"));
return NULL;
}
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_number (env->cfg,
- "transport-udp",
- "ADVERTISED_PORT",
- &aport))
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (env->cfg,
+ "transport-udp",
+ "ADVERTISED_PORT",
+ &aport))
aport = port;
if (aport > 65535)
{
GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
"transport-udp",
"ADVERTISED_PORT",
- _("must be in [0,65535]"));
+ _ ("must be in [0,65535]"));
return NULL;
}
if (GNUNET_YES ==
- GNUNET_CONFIGURATION_get_value_yesno (env->cfg,
- "nat",
- "DISABLEV6"))
+ GNUNET_CONFIGURATION_get_value_yesno (env->cfg, "nat", "DISABLEV6"))
enable_v6 = GNUNET_NO;
else
enable_v6 = GNUNET_YES;
have_bind4 = GNUNET_NO;
- memset (&server_addrv4,
- 0,
- sizeof (server_addrv4));
- if (GNUNET_YES ==
- GNUNET_CONFIGURATION_get_value_string (env->cfg,
- "transport-udp",
- "BINDTO",
- &bind4_address))
+ memset (&server_addrv4, 0, sizeof (server_addrv4));
+ if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_string (env->cfg,
+ "transport-udp",
+ "BINDTO",
+ &bind4_address))
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Binding UDP plugin to specific address: `%s'\n",
bind4_address);
- if (1 != inet_pton (AF_INET,
- bind4_address,
- &server_addrv4.sin_addr))
+ if (1 != inet_pton (AF_INET, bind4_address, &server_addrv4.sin_addr))
{
GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
"transport-udp",
"BINDTO",
- _("must be valid IPv4 address"));
+ _ ("must be valid IPv4 address"));
GNUNET_free (bind4_address);
return NULL;
}
@@ -3934,26 +3677,21 @@ libgnunet_plugin_transport_udp_init (void *cls)
}
GNUNET_free_non_null (bind4_address);
have_bind6 = GNUNET_NO;
- memset (&server_addrv6,
- 0,
- sizeof (server_addrv6));
- if (GNUNET_YES ==
- GNUNET_CONFIGURATION_get_value_string (env->cfg,
- "transport-udp",
- "BINDTO6",
- &bind6_address))
+ memset (&server_addrv6, 0, sizeof (server_addrv6));
+ if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_string (env->cfg,
+ "transport-udp",
+ "BINDTO6",
+ &bind6_address))
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Binding udp plugin to specific address: `%s'\n",
bind6_address);
- if (1 != inet_pton (AF_INET6,
- bind6_address,
- &server_addrv6.sin6_addr))
+ if (1 != inet_pton (AF_INET6, bind6_address, &server_addrv6.sin6_addr))
{
GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
"transport-udp",
"BINDTO6",
- _("must be valid IPv6 address"));
+ _ ("must be valid IPv6 address"));
GNUNET_free (bind6_address);
return NULL;
}
@@ -3967,9 +3705,10 @@ libgnunet_plugin_transport_udp_init (void *cls)
if (enable_broadcasting == GNUNET_SYSERR)
enable_broadcasting = GNUNET_NO;
- enable_broadcasting_recv = GNUNET_CONFIGURATION_get_value_yesno (env->cfg,
- "transport-udp",
- "BROADCAST_RECEIVE");
+ enable_broadcasting_recv =
+ GNUNET_CONFIGURATION_get_value_yesno (env->cfg,
+ "transport-udp",
+ "BROADCAST_RECEIVE");
if (enable_broadcasting_recv == GNUNET_SYSERR)
enable_broadcasting_recv = GNUNET_YES;
@@ -3979,14 +3718,12 @@ libgnunet_plugin_transport_udp_init (void *cls)
"BROADCAST_INTERVAL",
&interval))
{
- interval = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
- 10);
+ interval = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10);
}
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_number (env->cfg,
- "transport-udp",
- "MAX_BPS",
- &udp_max_bps))
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (env->cfg,
+ "transport-udp",
+ "MAX_BPS",
+ &udp_max_bps))
{
/* 50 MB/s == infinity for practical purposes */
udp_max_bps = 1024 * 1024 * 50;
@@ -4001,23 +3738,21 @@ libgnunet_plugin_transport_udp_init (void *cls)
p->enable_broadcasting = enable_broadcasting;
p->enable_broadcasting_receiving = enable_broadcasting_recv;
p->env = env;
- p->sessions = GNUNET_CONTAINER_multipeermap_create (16,
- GNUNET_NO);
- p->defrag_ctxs = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
+ p->sessions = GNUNET_CONTAINER_multipeermap_create (16, GNUNET_NO);
+ p->defrag_ctxs =
+ GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN);
GNUNET_BANDWIDTH_tracker_init (&p->tracker,
NULL,
NULL,
- GNUNET_BANDWIDTH_value_init ((uint32_t) udp_max_bps),
+ GNUNET_BANDWIDTH_value_init (
+ (uint32_t) udp_max_bps),
30);
res = setup_sockets (p,
(GNUNET_YES == have_bind6) ? &server_addrv6 : NULL,
(GNUNET_YES == have_bind4) ? &server_addrv4 : NULL);
- if ( (0 == res) ||
- ( (NULL == p->sockv4) &&
- (NULL == p->sockv6) ) )
+ if ((0 == res) || ((NULL == p->sockv4) && (NULL == p->sockv6)))
{
- LOG (GNUNET_ERROR_TYPE_ERROR,
- _("Failed to create UDP network sockets\n"));
+ LOG (GNUNET_ERROR_TYPE_ERROR, _ ("Failed to create UDP network sockets\n"));
GNUNET_CONTAINER_multipeermap_destroy (p->sessions);
GNUNET_CONTAINER_heap_destroy (p->defrag_ctxs);
if (NULL != p->nat)
@@ -4027,9 +3762,7 @@ libgnunet_plugin_transport_udp_init (void *cls)
}
/* Setup broadcasting and receiving beacons */
- setup_broadcast (p,
- &server_addrv6,
- &server_addrv4);
+ setup_broadcast (p, &server_addrv6, &server_addrv4);
api = GNUNET_new (struct GNUNET_TRANSPORT_PluginFunctions);
api->cls = p;
@@ -4108,14 +3841,12 @@ libgnunet_plugin_transport_udp_done (void *cls)
}
if (NULL != plugin->sockv4)
{
- GNUNET_break (GNUNET_OK ==
- GNUNET_NETWORK_socket_close (plugin->sockv4));
+ GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (plugin->sockv4));
plugin->sockv4 = NULL;
}
if (NULL != plugin->sockv6)
{
- GNUNET_break (GNUNET_OK ==
- GNUNET_NETWORK_socket_close (plugin->sockv6));
+ GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (plugin->sockv6));
plugin->sockv6 = NULL;
}
if (NULL != plugin->nat)
@@ -4133,20 +3864,14 @@ libgnunet_plugin_transport_udp_done (void *cls)
}
while (NULL != (udpw = plugin->ipv4_queue_head))
{
- dequeue (plugin,
- udpw);
- udpw->qc (udpw->qc_cls,
- udpw,
- GNUNET_SYSERR);
+ dequeue (plugin, udpw);
+ udpw->qc (udpw->qc_cls, udpw, GNUNET_SYSERR);
GNUNET_free (udpw);
}
while (NULL != (udpw = plugin->ipv6_queue_head))
{
- dequeue (plugin,
- udpw);
- udpw->qc (udpw->qc_cls,
- udpw,
- GNUNET_SYSERR);
+ dequeue (plugin, udpw);
+ udpw->qc (udpw->qc_cls, udpw, GNUNET_SYSERR);
GNUNET_free (udpw);
}
GNUNET_CONTAINER_multipeermap_iterate (plugin->sessions,
diff --git a/src/transport/plugin_transport_unix.c b/src/transport/plugin_transport_unix.c
index 5d095236d..2c408ebf5 100644
--- a/src/transport/plugin_transport_unix.c
+++ b/src/transport/plugin_transport_unix.c
@@ -68,9 +68,10 @@ enum UNIX_ADDRESS_OPTIONS
/**
* How long until we give up on transmitting the welcome message?
*/
-#define HOSTNAME_RESOLVE_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
+#define HOSTNAME_RESOLVE_TIMEOUT \
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
-#define LOG(kind,...) GNUNET_log_from (kind, "transport-unix",__VA_ARGS__)
+#define LOG(kind, ...) GNUNET_log_from (kind, "transport-unix", __VA_ARGS__)
GNUNET_NETWORK_STRUCT_BEGIN
@@ -108,7 +109,6 @@ struct UNIXMessage
* What is the identity of the sender (GNUNET_hash of public key)
*/
struct GNUNET_PeerIdentity sender;
-
};
GNUNET_NETWORK_STRUCT_END
@@ -218,13 +218,12 @@ struct GNUNET_ATS_Session
/**
* Session timeout task.
*/
- struct GNUNET_SCHEDULER_Task * timeout_task;
+ struct GNUNET_SCHEDULER_Task *timeout_task;
/**
* Number of messages we currently have in our write queue.
*/
unsigned int msgs_in_queue;
-
};
@@ -255,17 +254,17 @@ struct Plugin
/**
* ID of task used to update our addresses when one expires.
*/
- struct GNUNET_SCHEDULER_Task * address_update_task;
+ struct GNUNET_SCHEDULER_Task *address_update_task;
/**
* ID of read task
*/
- struct GNUNET_SCHEDULER_Task * read_task;
+ struct GNUNET_SCHEDULER_Task *read_task;
/**
* ID of write task
*/
- struct GNUNET_SCHEDULER_Task * write_task;
+ struct GNUNET_SCHEDULER_Task *write_task;
/**
* Number of bytes we currently have in our write queues.
@@ -321,7 +320,6 @@ struct Plugin
* Are we using an abstract UNIX domain socket?
*/
int is_abstract;
-
};
@@ -352,9 +350,7 @@ notify_session_monitor (struct Plugin *plugin,
to receive from others) */
info.session_timeout = session->timeout;
info.address = session->address;
- plugin->sic (plugin->sic_cls,
- session,
- &info);
+ plugin->sic (plugin->sic_cls, session, &info);
}
@@ -370,9 +366,7 @@ notify_session_monitor (struct Plugin *plugin,
* @return string representing the same address
*/
static const char *
-unix_plugin_address_to_string (void *cls,
- const void *addr,
- size_t addrlen)
+unix_plugin_address_to_string (void *cls, const void *addr, size_t addrlen)
{
static char rbuf[1024];
struct UnixAddress *ua = (struct UnixAddress *) addr;
@@ -382,25 +376,25 @@ unix_plugin_address_to_string (void *cls,
if ((NULL == addr) || (sizeof (struct UnixAddress) > addrlen))
{
- GNUNET_break(0);
+ GNUNET_break (0);
return NULL;
}
addrstr = (char *) &ua[1];
addr_str_len = ntohl (ua->addrlen);
- if (addr_str_len != addrlen - sizeof(struct UnixAddress))
+ if (addr_str_len != addrlen - sizeof (struct UnixAddress))
{
- GNUNET_break(0);
+ GNUNET_break (0);
return NULL;
}
if ('\0' != addrstr[addr_str_len - 1])
{
- GNUNET_break(0);
+ GNUNET_break (0);
return NULL;
}
if (strlen (addrstr) + 1 != addr_str_len)
{
- GNUNET_break(0);
+ GNUNET_break (0);
return NULL;
}
@@ -430,8 +424,7 @@ unix_plugin_address_to_string (void *cls,
* @return #GNUNET_OK on success
*/
static int
-unix_plugin_session_disconnect (void *cls,
- struct GNUNET_ATS_Session *session)
+unix_plugin_session_disconnect (void *cls, struct GNUNET_ATS_Session *session)
{
struct Plugin *plugin = cls;
struct UNIXMessageWrapper *msgw;
@@ -443,9 +436,7 @@ unix_plugin_session_disconnect (void *cls,
unix_plugin_address_to_string (NULL,
session->address->address,
session->address->address_length));
- plugin->env->session_end (plugin->env->cls,
- session->address,
- session);
+ plugin->env->session_end (plugin->env->cls, session->address, session);
next = plugin->msg_head;
while (NULL != next)
{
@@ -453,9 +444,7 @@ unix_plugin_session_disconnect (void *cls,
next = msgw->next;
if (msgw->session != session)
continue;
- GNUNET_CONTAINER_DLL_remove (plugin->msg_head,
- plugin->msg_tail,
- msgw);
+ GNUNET_CONTAINER_DLL_remove (plugin->msg_head, plugin->msg_tail, msgw);
session->msgs_in_queue--;
GNUNET_assert (session->bytes_in_queue >= msgw->msgsize);
session->bytes_in_queue -= msgw->msgsize;
@@ -465,27 +454,27 @@ unix_plugin_session_disconnect (void *cls,
msgw->cont (msgw->cont_cls,
&msgw->session->target,
GNUNET_SYSERR,
- msgw->payload, 0);
+ msgw->payload,
+ 0);
GNUNET_free (msgw->msg);
GNUNET_free (msgw);
}
GNUNET_assert (GNUNET_YES ==
GNUNET_CONTAINER_multipeermap_remove (plugin->session_map,
- &session->target,
- session));
+ &session->target,
+ session));
GNUNET_STATISTICS_set (plugin->env->stats,
- "# UNIX sessions active",
- GNUNET_CONTAINER_multipeermap_size (plugin->session_map),
- GNUNET_NO);
+ "# UNIX sessions active",
+ GNUNET_CONTAINER_multipeermap_size (
+ plugin->session_map),
+ GNUNET_NO);
if (NULL != session->timeout_task)
{
GNUNET_SCHEDULER_cancel (session->timeout_task);
session->timeout_task = NULL;
session->timeout = GNUNET_TIME_UNIT_ZERO_ABS;
}
- notify_session_monitor (plugin,
- session,
- GNUNET_TRANSPORT_SS_DONE);
+ notify_session_monitor (plugin, session, GNUNET_TRANSPORT_SS_DONE);
GNUNET_HELLO_address_free (session->address);
GNUNET_break (0 == session->bytes_in_queue);
GNUNET_break (0 == session->msgs_in_queue);
@@ -514,16 +503,16 @@ session_timeout (void *cls)
notify_session_monitor (session->plugin,
session,
GNUNET_TRANSPORT_SS_UPDATE);
- session->timeout_task = GNUNET_SCHEDULER_add_delayed (left,
- &session_timeout,
- session);
+ session->timeout_task =
+ GNUNET_SCHEDULER_add_delayed (left, &session_timeout, session);
return;
}
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Session %p was idle for %s, disconnecting\n",
session,
- GNUNET_STRINGS_relative_time_to_string (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
- GNUNET_YES));
+ GNUNET_STRINGS_relative_time_to_string (
+ GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
+ GNUNET_YES));
unix_plugin_session_disconnect (session->plugin, session);
}
@@ -539,7 +528,8 @@ static void
reschedule_session_timeout (struct GNUNET_ATS_Session *session)
{
GNUNET_assert (NULL != session->timeout_task);
- session->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
+ session->timeout =
+ GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
}
@@ -551,13 +541,12 @@ reschedule_session_timeout (struct GNUNET_ATS_Session *session)
* @return converted unix path
*/
static struct sockaddr_un *
-unix_address_to_sockaddr (const char *unixpath,
- socklen_t *sock_len)
+unix_address_to_sockaddr (const char *unixpath, socklen_t *sock_len)
{
struct sockaddr_un *un;
size_t slen;
- GNUNET_assert (0 < strlen (unixpath)); /* sanity check */
+ GNUNET_assert (0 < strlen (unixpath)); /* sanity check */
un = GNUNET_new (struct sockaddr_un);
un->sun_family = AF_UNIX;
slen = strlen (unixpath);
@@ -601,14 +590,13 @@ struct LookupCtx
*/
static int
lookup_session_it (void *cls,
- const struct GNUNET_PeerIdentity * key,
- void *value)
+ const struct GNUNET_PeerIdentity *key,
+ void *value)
{
struct LookupCtx *lctx = cls;
struct GNUNET_ATS_Session *session = value;
- if (0 == GNUNET_HELLO_address_cmp (lctx->address,
- session->address))
+ if (0 == GNUNET_HELLO_address_cmp (lctx->address, session->address))
{
lctx->res = session;
return GNUNET_NO;
@@ -633,8 +621,9 @@ lookup_session (struct Plugin *plugin,
lctx.address = address;
lctx.res = NULL;
GNUNET_CONTAINER_multipeermap_get_multiple (plugin->session_map,
- &address->peer,
- &lookup_session_it, &lctx);
+ &address->peer,
+ &lookup_session_it,
+ &lctx);
return lctx.res;
}
@@ -707,16 +696,15 @@ unix_real_send (void *cls,
}
/* Prepare address */
- unixpath = (const char *) &addr[1];
- if (NULL == (un = unix_address_to_sockaddr (unixpath,
- &un_len)))
+ unixpath = (const char *) &addr[1];
+ if (NULL == (un = unix_address_to_sockaddr (unixpath, &un_len)))
{
GNUNET_break (0);
return -1;
}
if ((GNUNET_YES == plugin->is_abstract) &&
- (0 != (UNIX_OPTIONS_USE_ABSTRACT_SOCKETS & ntohl(addr->options) )) )
+ (0 != (UNIX_OPTIONS_USE_ABSTRACT_SOCKETS & ntohl (addr->options))))
{
un->sun_path[0] = '\0';
}
@@ -729,8 +717,7 @@ resend:
un_len);
if (GNUNET_SYSERR == sent)
{
- if ( (EAGAIN == errno) ||
- (ENOBUFS == errno) )
+ if ((EAGAIN == errno) || (ENOBUFS == errno))
{
GNUNET_free (un);
return RETRY; /* We have to retry later */
@@ -741,7 +728,10 @@ resend:
socklen_t len = sizeof (size);
GNUNET_NETWORK_socket_getsockopt ((struct GNUNET_NETWORK_Handle *)
- send_handle, SOL_SOCKET, SO_SNDBUF, &size,
+ send_handle,
+ SOL_SOCKET,
+ SO_SNDBUF,
+ &size,
&len);
if (size < msgbuf_size)
{
@@ -752,9 +742,12 @@ resend:
(unsigned int) msgbuf_size);
size = ((msgbuf_size / 1000) + 2) * 1000;
if (GNUNET_OK ==
- GNUNET_NETWORK_socket_setsockopt ((struct GNUNET_NETWORK_Handle *) send_handle,
- SOL_SOCKET, SO_SNDBUF,
- &size, sizeof (size)))
+ GNUNET_NETWORK_socket_setsockopt ((struct GNUNET_NETWORK_Handle *)
+ send_handle,
+ SOL_SOCKET,
+ SO_SNDBUF,
+ &size,
+ sizeof (size)))
goto resend; /* Increased buffer size, retry sending */
else
{
@@ -778,9 +771,9 @@ resend:
LOG (GNUNET_ERROR_TYPE_DEBUG,
"UNIX transmitted %u-byte message to %s (%d: %s)\n",
(unsigned int) msgbuf_size,
- GNUNET_a2s ((const struct sockaddr *)un, un_len),
+ GNUNET_a2s ((const struct sockaddr *) un, un_len),
(int) sent,
- (sent < 0) ? STRERROR (errno) : "ok");
+ (sent < 0) ? strerror (errno) : "ok");
GNUNET_free (un);
return sent;
}
@@ -794,8 +787,7 @@ resend:
* @return the network type in HBO or #GNUNET_SYSERR
*/
static enum GNUNET_NetworkType
-unix_plugin_get_network (void *cls,
- struct GNUNET_ATS_Session *session)
+unix_plugin_get_network (void *cls, struct GNUNET_ATS_Session *session)
{
GNUNET_assert (NULL != session);
return GNUNET_NT_LOOPBACK;
@@ -827,19 +819,18 @@ unix_plugin_get_network_for_address (void *cls,
* @return the session or NULL of max connections exceeded
*/
static struct GNUNET_ATS_Session *
-unix_plugin_get_session (void *cls,
- const struct GNUNET_HELLO_Address *address)
+unix_plugin_get_session (void *cls, const struct GNUNET_HELLO_Address *address)
{
struct Plugin *plugin = cls;
struct GNUNET_ATS_Session *session;
struct UnixAddress *ua;
- char * addrstr;
+ char *addrstr;
uint32_t addr_str_len;
uint32_t addr_option;
ua = (struct UnixAddress *) address->address;
if ((NULL == address->address) || (0 == address->address_length) ||
- (sizeof (struct UnixAddress) > address->address_length))
+ (sizeof (struct UnixAddress) > address->address_length))
{
GNUNET_break (0);
return NULL;
@@ -848,8 +839,8 @@ unix_plugin_get_session (void *cls,
addr_str_len = ntohl (ua->addrlen);
addr_option = ntohl (ua->options);
- if ( (0 != (UNIX_OPTIONS_USE_ABSTRACT_SOCKETS & addr_option)) &&
- (GNUNET_NO == plugin->is_abstract))
+ if ((0 != (UNIX_OPTIONS_USE_ABSTRACT_SOCKETS & addr_option)) &&
+ (GNUNET_NO == plugin->is_abstract))
{
return NULL;
}
@@ -871,13 +862,12 @@ unix_plugin_get_session (void *cls,
}
/* Check if a session for this address already exists */
- if (NULL != (session = lookup_session (plugin,
- address)))
- {
+ if (NULL != (session = lookup_session (plugin, address)))
+ {
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Found existing session %p for address `%s'\n",
- session,
- unix_plugin_address_to_string (NULL,
+ session,
+ unix_plugin_address_to_string (NULL,
address->address,
address->address_length));
return session;
@@ -888,29 +878,30 @@ unix_plugin_get_session (void *cls,
session->target = address->peer;
session->address = GNUNET_HELLO_address_copy (address);
session->plugin = plugin;
- session->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
- session->timeout_task = GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
- &session_timeout,
- session);
+ session->timeout =
+ GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
+ session->timeout_task =
+ GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT,
+ &session_timeout,
+ session);
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Creating a new session %p for address `%s'\n",
session,
unix_plugin_address_to_string (NULL,
address->address,
address->address_length));
- (void) GNUNET_CONTAINER_multipeermap_put (plugin->session_map,
- &address->peer, session,
- GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
+ (void) GNUNET_CONTAINER_multipeermap_put (
+ plugin->session_map,
+ &address->peer,
+ session,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
GNUNET_STATISTICS_set (plugin->env->stats,
- "# UNIX sessions active",
- GNUNET_CONTAINER_multipeermap_size (plugin->session_map),
- GNUNET_NO);
- notify_session_monitor (plugin,
- session,
- GNUNET_TRANSPORT_SS_INIT);
- notify_session_monitor (plugin,
- session,
- GNUNET_TRANSPORT_SS_UP);
+ "# UNIX sessions active",
+ GNUNET_CONTAINER_multipeermap_size (
+ plugin->session_map),
+ GNUNET_NO);
+ notify_session_monitor (plugin, session, GNUNET_TRANSPORT_SS_INIT);
+ notify_session_monitor (plugin, session, GNUNET_TRANSPORT_SS_UP);
return session;
}
@@ -967,15 +958,17 @@ unix_demultiplexer (struct Plugin *plugin,
"Received message from %s\n",
unix_plugin_address_to_string (NULL, ua, ua_len));
GNUNET_STATISTICS_update (plugin->env->stats,
- "# bytes received via UNIX",
- ntohs (currhdr->size),
- GNUNET_NO);
+ "# bytes received via UNIX",
+ ntohs (currhdr->size),
+ GNUNET_NO);
/* Look for existing session */
- address = GNUNET_HELLO_address_allocate (sender,
- PLUGIN_NAME,
- ua, ua_len,
- GNUNET_HELLO_ADDRESS_INFO_NONE); /* UNIX does not have "inbound" sessions */
+ address = GNUNET_HELLO_address_allocate (
+ sender,
+ PLUGIN_NAME,
+ ua,
+ ua_len,
+ GNUNET_HELLO_ADDRESS_INFO_NONE); /* UNIX does not have "inbound" sessions */
session = lookup_session (plugin, address);
if (NULL == session)
{
@@ -991,10 +984,7 @@ unix_demultiplexer (struct Plugin *plugin,
reschedule_session_timeout (session);
}
GNUNET_HELLO_address_free (address);
- plugin->env->receive (plugin->env->cls,
- session->address,
- session,
- currhdr);
+ plugin->env->receive (plugin->env->cls, session->address, session, currhdr);
}
@@ -1024,23 +1014,23 @@ unix_plugin_do_read (struct Plugin *plugin)
addrlen = sizeof (un);
memset (&un, 0, sizeof (un));
ret = GNUNET_NETWORK_socket_recvfrom (plugin->unix_sock.desc,
- buf, sizeof (buf),
+ buf,
+ sizeof (buf),
(struct sockaddr *) &un,
&addrlen);
if ((GNUNET_SYSERR == ret) && ((errno == EAGAIN) || (errno == ENOBUFS)))
return;
if (GNUNET_SYSERR == ret)
{
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING,
- "recvfrom");
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "recvfrom");
return;
}
else
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Read %d bytes from socket %s\n",
- (int) ret,
- un.sun_path);
+ "Read %d bytes from socket %s\n",
+ (int) ret,
+ un.sun_path);
}
GNUNET_assert (AF_UNIX == (un.sun_family));
@@ -1053,12 +1043,12 @@ unix_plugin_do_read (struct Plugin *plugin)
ua_len = sizeof (struct UnixAddress) + strlen (un.sun_path) + 1;
ua = GNUNET_malloc (ua_len);
- ua->addrlen = htonl (strlen (&un.sun_path[0]) +1);
+ ua->addrlen = htonl (strlen (&un.sun_path[0]) + 1);
GNUNET_memcpy (&ua[1], &un.sun_path[0], strlen (un.sun_path) + 1);
if (is_abstract)
- ua->options = htonl(UNIX_OPTIONS_USE_ABSTRACT_SOCKETS);
+ ua->options = htonl (UNIX_OPTIONS_USE_ABSTRACT_SOCKETS);
else
- ua->options = htonl(UNIX_OPTIONS_NONE);
+ ua->options = htonl (UNIX_OPTIONS_NONE);
msg = (struct UNIXMessage *) buf;
csize = ntohs (msg->header.size);
@@ -1069,9 +1059,7 @@ unix_plugin_do_read (struct Plugin *plugin)
return;
}
msgbuf = (char *) &msg[1];
- GNUNET_memcpy (&sender,
- &msg->sender,
- sizeof (struct GNUNET_PeerIdentity));
+ GNUNET_memcpy (&sender, &msg->sender, sizeof (struct GNUNET_PeerIdentity));
offset = 0;
tsize = csize - sizeof (struct UNIXMessage);
while (offset + sizeof (struct GNUNET_MessageHeader) <= tsize)
@@ -1113,11 +1101,9 @@ unix_plugin_do_write (struct Plugin *plugin)
/* Message has a timeout */
did_delete = GNUNET_YES;
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Timeout for message with %u bytes \n",
- (unsigned int) msgw->msgsize);
- GNUNET_CONTAINER_DLL_remove (plugin->msg_head,
- plugin->msg_tail,
- msgw);
+ "Timeout for message with %u bytes \n",
+ (unsigned int) msgw->msgsize);
+ GNUNET_CONTAINER_DLL_remove (plugin->msg_head, plugin->msg_tail, msgw);
session = msgw->session;
session->msgs_in_queue--;
GNUNET_assert (session->bytes_in_queue >= msgw->msgsize);
@@ -1125,28 +1111,26 @@ unix_plugin_do_write (struct Plugin *plugin)
GNUNET_assert (plugin->bytes_in_queue >= msgw->msgsize);
plugin->bytes_in_queue -= msgw->msgsize;
GNUNET_STATISTICS_set (plugin->env->stats,
- "# bytes currently in UNIX buffers",
- plugin->bytes_in_queue,
+ "# bytes currently in UNIX buffers",
+ plugin->bytes_in_queue,
GNUNET_NO);
GNUNET_STATISTICS_update (plugin->env->stats,
- "# UNIX bytes discarded",
- msgw->msgsize,
- GNUNET_NO);
+ "# UNIX bytes discarded",
+ msgw->msgsize,
+ GNUNET_NO);
if (NULL != msgw->cont)
msgw->cont (msgw->cont_cls,
- &msgw->session->target,
- GNUNET_SYSERR,
- msgw->payload,
- 0);
+ &msgw->session->target,
+ GNUNET_SYSERR,
+ msgw->payload,
+ 0);
GNUNET_free (msgw->msg);
GNUNET_free (msgw);
}
if (NULL == msgw)
{
if (GNUNET_YES == did_delete)
- notify_session_monitor (plugin,
- session,
- GNUNET_TRANSPORT_SS_UPDATE);
+ notify_session_monitor (plugin, session, GNUNET_TRANSPORT_SS_UPDATE);
return; /* Nothing to send at the moment */
}
session = msgw->session;
@@ -1160,20 +1144,18 @@ unix_plugin_do_write (struct Plugin *plugin)
msgw->session->address->address,
msgw->session->address->address_length,
msgw->payload,
- msgw->cont, msgw->cont_cls);
+ msgw->cont,
+ msgw->cont_cls);
if (RETRY == sent)
{
GNUNET_STATISTICS_update (plugin->env->stats,
- "# UNIX retry attempts",
- 1, GNUNET_NO);
- notify_session_monitor (plugin,
- session,
- GNUNET_TRANSPORT_SS_UPDATE);
+ "# UNIX retry attempts",
+ 1,
+ GNUNET_NO);
+ notify_session_monitor (plugin, session, GNUNET_TRANSPORT_SS_UPDATE);
return;
}
- GNUNET_CONTAINER_DLL_remove (plugin->msg_head,
- plugin->msg_tail,
- msgw);
+ GNUNET_CONTAINER_DLL_remove (plugin->msg_head, plugin->msg_tail, msgw);
session->msgs_in_queue--;
GNUNET_assert (session->bytes_in_queue >= msgw->msgsize);
session->bytes_in_queue -= msgw->msgsize;
@@ -1181,10 +1163,9 @@ unix_plugin_do_write (struct Plugin *plugin)
plugin->bytes_in_queue -= msgw->msgsize;
GNUNET_STATISTICS_set (plugin->env->stats,
"# bytes currently in UNIX buffers",
- plugin->bytes_in_queue, GNUNET_NO);
- notify_session_monitor (plugin,
- session,
- GNUNET_TRANSPORT_SS_UPDATE);
+ plugin->bytes_in_queue,
+ GNUNET_NO);
+ notify_session_monitor (plugin, session, GNUNET_TRANSPORT_SS_UPDATE);
if (GNUNET_SYSERR == sent)
{
/* failed and no retry */
@@ -1192,11 +1173,12 @@ unix_plugin_do_write (struct Plugin *plugin)
msgw->cont (msgw->cont_cls,
&msgw->session->target,
GNUNET_SYSERR,
- msgw->payload, 0);
+ msgw->payload,
+ 0);
GNUNET_STATISTICS_update (plugin->env->stats,
- "# UNIX bytes discarded",
- msgw->msgsize,
- GNUNET_NO);
+ "# UNIX bytes discarded",
+ msgw->msgsize,
+ GNUNET_NO);
GNUNET_free (msgw->msg);
GNUNET_free (msgw);
return;
@@ -1204,15 +1186,15 @@ unix_plugin_do_write (struct Plugin *plugin)
/* successfully sent bytes */
GNUNET_break (sent > 0);
GNUNET_STATISTICS_update (plugin->env->stats,
- "# bytes transmitted via UNIX",
- msgw->msgsize,
- GNUNET_NO);
+ "# bytes transmitted via UNIX",
+ msgw->msgsize,
+ GNUNET_NO);
if (NULL != msgw->cont)
msgw->cont (msgw->cont_cls,
&msgw->session->target,
- GNUNET_OK,
- msgw->payload,
- msgw->msgsize);
+ GNUNET_OK,
+ msgw->payload,
+ msgw->msgsize);
GNUNET_free (msgw->msg);
GNUNET_free (msgw);
}
@@ -1237,7 +1219,8 @@ unix_plugin_select_read (void *cls)
plugin->read_task =
GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
plugin->unix_sock.desc,
- &unix_plugin_select_read, plugin);
+ &unix_plugin_select_read,
+ plugin);
}
@@ -1262,7 +1245,8 @@ unix_plugin_select_write (void *cls)
plugin->write_task =
GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL,
plugin->unix_sock.desc,
- &unix_plugin_select_write, plugin);
+ &unix_plugin_select_write,
+ plugin);
}
@@ -1310,13 +1294,13 @@ unix_plugin_send (void *cls,
if (GNUNET_OK !=
GNUNET_CONTAINER_multipeermap_contains_value (plugin->session_map,
- &session->target,
- session))
+ &session->target,
+ session))
{
LOG (GNUNET_ERROR_TYPE_ERROR,
- "Invalid session for peer `%s' `%s'\n",
- GNUNET_i2s (&session->target),
- unix_plugin_address_to_string (NULL,
+ "Invalid session for peer `%s' `%s'\n",
+ GNUNET_i2s (&session->target),
+ unix_plugin_address_to_string (NULL,
session->address->address,
session->address->address_length));
GNUNET_break (0);
@@ -1333,16 +1317,16 @@ unix_plugin_send (void *cls,
message = GNUNET_malloc (sizeof (struct UNIXMessage) + msgbuf_size);
message->header.size = htons (ssize);
message->header.type = htons (0);
- GNUNET_memcpy (&message->sender, plugin->env->my_identity,
- sizeof (struct GNUNET_PeerIdentity));
+ GNUNET_memcpy (&message->sender,
+ plugin->env->my_identity,
+ sizeof (struct GNUNET_PeerIdentity));
GNUNET_memcpy (&message[1], msgbuf, msgbuf_size);
wrapper = GNUNET_new (struct UNIXMessageWrapper);
wrapper->msg = message;
wrapper->msgsize = ssize;
wrapper->payload = msgbuf_size;
wrapper->priority = priority;
- wrapper->timeout = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (),
- to);
+ wrapper->timeout = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), to);
wrapper->cont = cont;
wrapper->cont_cls = cont_cls;
wrapper->session = session;
@@ -1353,17 +1337,16 @@ unix_plugin_send (void *cls,
session->bytes_in_queue += ssize;
session->msgs_in_queue++;
GNUNET_STATISTICS_set (plugin->env->stats,
- "# bytes currently in UNIX buffers",
- plugin->bytes_in_queue,
- GNUNET_NO);
- notify_session_monitor (plugin,
- session,
- GNUNET_TRANSPORT_SS_UPDATE);
+ "# bytes currently in UNIX buffers",
+ plugin->bytes_in_queue,
+ GNUNET_NO);
+ notify_session_monitor (plugin, session, GNUNET_TRANSPORT_SS_UPDATE);
if (NULL == plugin->write_task)
plugin->write_task =
GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL,
plugin->unix_sock.desc,
- &unix_plugin_select_write, plugin);
+ &unix_plugin_select_write,
+ plugin);
return ssize;
}
@@ -1381,15 +1364,14 @@ unix_transport_server_start (void *cls)
struct sockaddr_un *un;
socklen_t un_len;
- un = unix_address_to_sockaddr (plugin->unix_socket_path,
- &un_len);
+ un = unix_address_to_sockaddr (plugin->unix_socket_path, &un_len);
if (GNUNET_YES == plugin->is_abstract)
{
plugin->unix_socket_path[0] = '@';
un->sun_path[0] = '\0';
}
plugin->unix_sock.desc =
- GNUNET_NETWORK_socket_create (AF_UNIX, SOCK_DGRAM, 0);
+ GNUNET_NETWORK_socket_create (AF_UNIX, SOCK_DGRAM, 0);
if (NULL == plugin->unix_sock.desc)
{
GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "socket");
@@ -1400,33 +1382,32 @@ unix_transport_server_start (void *cls)
{
if (GNUNET_OK != GNUNET_DISK_directory_create_for_file (un->sun_path))
{
- LOG (GNUNET_ERROR_TYPE_ERROR, _("Cannot create path to `%s'\n"),
- un->sun_path);
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ _ ("Cannot create path to `%s'\n"),
+ un->sun_path);
GNUNET_NETWORK_socket_close (plugin->unix_sock.desc);
plugin->unix_sock.desc = NULL;
GNUNET_free (un);
return GNUNET_SYSERR;
}
}
- if (GNUNET_OK !=
- GNUNET_NETWORK_socket_bind (plugin->unix_sock.desc,
- (const struct sockaddr *) un, un_len))
+ if (GNUNET_OK != GNUNET_NETWORK_socket_bind (plugin->unix_sock.desc,
+ (const struct sockaddr *) un,
+ un_len))
{
GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "bind");
- LOG (GNUNET_ERROR_TYPE_ERROR, _("Cannot bind to `%s'\n"),
- un->sun_path);
+ LOG (GNUNET_ERROR_TYPE_ERROR, _ ("Cannot bind to `%s'\n"), un->sun_path);
GNUNET_NETWORK_socket_close (plugin->unix_sock.desc);
plugin->unix_sock.desc = NULL;
GNUNET_free (un);
return GNUNET_SYSERR;
}
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Bound to `%s'\n",
- plugin->unix_socket_path);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Bound to `%s'\n", plugin->unix_socket_path);
plugin->read_task =
GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL,
plugin->unix_sock.desc,
- &unix_plugin_select_read, plugin);
+ &unix_plugin_select_read,
+ plugin);
GNUNET_free (un);
return 1;
}
@@ -1449,18 +1430,15 @@ unix_transport_server_start (void *cls)
*
*/
static int
-unix_plugin_check_address (void *cls,
- const void *addr,
- size_t addrlen)
+unix_plugin_check_address (void *cls, const void *addr, size_t addrlen)
{
- struct Plugin* plugin = cls;
+ struct Plugin *plugin = cls;
const struct UnixAddress *ua = addr;
char *addrstr;
size_t addr_str_len;
- if ( (NULL == addr) ||
- (0 == addrlen) ||
- (sizeof (struct UnixAddress) > addrlen) )
+ if ((NULL == addr) || (0 == addrlen) ||
+ (sizeof (struct UnixAddress) > addrlen))
{
GNUNET_break (0);
return GNUNET_SYSERR;
@@ -1479,7 +1457,7 @@ unix_plugin_check_address (void *cls,
}
if (0 == strcmp (plugin->unix_socket_path, addrstr))
- return GNUNET_OK;
+ return GNUNET_OK;
return GNUNET_SYSERR;
}
@@ -1499,7 +1477,8 @@ unix_plugin_check_address (void *cls,
* @param asc_cls closure for @a asc
*/
static void
-unix_plugin_address_pretty_printer (void *cls, const char *type,
+unix_plugin_address_pretty_printer (void *cls,
+ const char *type,
const void *addr,
size_t addrlen,
int numeric,
@@ -1509,15 +1488,11 @@ unix_plugin_address_pretty_printer (void *cls, const char *type,
{
const char *ret;
- if ( (NULL != addr) && (addrlen > 0))
- ret = unix_plugin_address_to_string (NULL,
- addr,
- addrlen);
+ if ((NULL != addr) && (addrlen > 0))
+ ret = unix_plugin_address_to_string (NULL, addr, addrlen);
else
ret = NULL;
- asc (asc_cls,
- ret,
- (NULL == ret) ? GNUNET_SYSERR : GNUNET_OK);
+ asc (asc_cls, ret, (NULL == ret) ? GNUNET_SYSERR : GNUNET_OK);
asc (asc_cls, NULL, GNUNET_OK);
}
@@ -1538,7 +1513,8 @@ static int
unix_plugin_string_to_address (void *cls,
const char *addr,
uint16_t addrlen,
- void **buf, size_t *added)
+ void **buf,
+ size_t *added)
{
struct UnixAddress *ua;
char *address;
@@ -1587,7 +1563,7 @@ unix_plugin_string_to_address (void *cls,
}
address[0] = '\0';
address++;
- if (0 != strcmp(plugin, PLUGIN_NAME))
+ if (0 != strcmp (plugin, PLUGIN_NAME))
{
GNUNET_break (0);
GNUNET_free (plugin);
@@ -1624,9 +1600,11 @@ address_notification (void *cls)
len = sizeof (struct UnixAddress) + strlen (plugin->unix_socket_path) + 1;
ua = GNUNET_malloc (len);
ua->options = htonl (plugin->myoptions);
- ua->addrlen = htonl(strlen (plugin->unix_socket_path) + 1);
+ ua->addrlen = htonl (strlen (plugin->unix_socket_path) + 1);
unix_path = (char *) &ua[1];
- GNUNET_memcpy (unix_path, plugin->unix_socket_path, strlen (plugin->unix_socket_path) + 1);
+ GNUNET_memcpy (unix_path,
+ plugin->unix_socket_path,
+ strlen (plugin->unix_socket_path) + 1);
plugin->address_update_task = NULL;
address = GNUNET_HELLO_address_allocate (plugin->env->my_identity,
@@ -1634,9 +1612,7 @@ address_notification (void *cls)
ua,
len,
GNUNET_HELLO_ADDRESS_INFO_NONE);
- plugin->env->notify_address (plugin->env->cls,
- GNUNET_YES,
- address);
+ plugin->env->notify_address (plugin->env->cls, GNUNET_YES, address);
GNUNET_free (ua);
GNUNET_free (address);
}
@@ -1652,8 +1628,8 @@ address_notification (void *cls)
*/
static int
get_session_delete_it (void *cls,
- const struct GNUNET_PeerIdentity *key,
- void *value)
+ const struct GNUNET_PeerIdentity *key,
+ void *value)
{
struct Plugin *plugin = cls;
struct GNUNET_ATS_Session *session = value;
@@ -1677,8 +1653,9 @@ unix_plugin_peer_disconnect (void *cls,
struct Plugin *plugin = cls;
GNUNET_CONTAINER_multipeermap_get_multiple (plugin->session_map,
- target,
- &get_session_delete_it, plugin);
+ target,
+ &get_session_delete_it,
+ plugin);
}
@@ -1699,12 +1676,8 @@ send_session_info_iter (void *cls,
struct Plugin *plugin = cls;
struct GNUNET_ATS_Session *session = value;
- notify_session_monitor (plugin,
- session,
- GNUNET_TRANSPORT_SS_INIT);
- notify_session_monitor (plugin,
- session,
- GNUNET_TRANSPORT_SS_UP);
+ notify_session_monitor (plugin, session, GNUNET_TRANSPORT_SS_INIT);
+ notify_session_monitor (plugin, session, GNUNET_TRANSPORT_SS_UP);
return GNUNET_OK;
}
@@ -1786,9 +1759,10 @@ libgnunet_plugin_transport_unix_init (void *cls)
/* Initialize my flags */
#ifdef LINUX
- plugin->is_abstract = GNUNET_CONFIGURATION_get_value_yesno (plugin->env->cfg,
- "testing",
- "USE_ABSTRACT_SOCKETS");
+ plugin->is_abstract =
+ GNUNET_CONFIGURATION_get_value_yesno (plugin->env->cfg,
+ "testing",
+ "USE_ABSTRACT_SOCKETS");
#endif
plugin->myoptions = UNIX_OPTIONS_NONE;
if (GNUNET_YES == plugin->is_abstract)
@@ -1812,16 +1786,15 @@ libgnunet_plugin_transport_unix_init (void *cls)
sockets_created = unix_transport_server_start (plugin);
if ((0 == sockets_created) || (GNUNET_SYSERR == sockets_created))
{
- LOG (GNUNET_ERROR_TYPE_WARNING,
- _("Failed to open UNIX listen socket\n"));
+ LOG (GNUNET_ERROR_TYPE_WARNING, _ ("Failed to open UNIX listen socket\n"));
GNUNET_free (api);
GNUNET_free (plugin->unix_socket_path);
GNUNET_free (plugin);
return NULL;
}
plugin->session_map = GNUNET_CONTAINER_multipeermap_create (10, GNUNET_NO);
- plugin->address_update_task = GNUNET_SCHEDULER_add_now (&address_notification,
- plugin);
+ plugin->address_update_task =
+ GNUNET_SCHEDULER_add_now (&address_notification, plugin);
return api;
}
@@ -1838,7 +1811,7 @@ libgnunet_plugin_transport_unix_done (void *cls)
struct GNUNET_TRANSPORT_PluginFunctions *api = cls;
struct Plugin *plugin = api->cls;
struct GNUNET_HELLO_Address *address;
- struct UNIXMessageWrapper * msgw;
+ struct UNIXMessageWrapper *msgw;
struct UnixAddress *ua;
size_t len;
struct GNUNET_ATS_Session *session;
@@ -1851,26 +1824,23 @@ libgnunet_plugin_transport_unix_done (void *cls)
len = sizeof (struct UnixAddress) + strlen (plugin->unix_socket_path) + 1;
ua = GNUNET_malloc (len);
ua->options = htonl (plugin->myoptions);
- ua->addrlen = htonl(strlen (plugin->unix_socket_path) + 1);
+ ua->addrlen = htonl (strlen (plugin->unix_socket_path) + 1);
GNUNET_memcpy (&ua[1],
- plugin->unix_socket_path,
- strlen (plugin->unix_socket_path) + 1);
+ plugin->unix_socket_path,
+ strlen (plugin->unix_socket_path) + 1);
address = GNUNET_HELLO_address_allocate (plugin->env->my_identity,
PLUGIN_NAME,
- ua, len,
+ ua,
+ len,
GNUNET_HELLO_ADDRESS_INFO_NONE);
- plugin->env->notify_address (plugin->env->cls,
- GNUNET_NO,
- address);
+ plugin->env->notify_address (plugin->env->cls, GNUNET_NO, address);
GNUNET_free (address);
GNUNET_free (ua);
while (NULL != (msgw = plugin->msg_head))
{
- GNUNET_CONTAINER_DLL_remove (plugin->msg_head,
- plugin->msg_tail,
- msgw);
+ GNUNET_CONTAINER_DLL_remove (plugin->msg_head, plugin->msg_tail, msgw);
session = msgw->session;
session->msgs_in_queue--;
GNUNET_assert (session->bytes_in_queue >= msgw->msgsize);
@@ -1881,7 +1851,8 @@ libgnunet_plugin_transport_unix_done (void *cls)
msgw->cont (msgw->cont_cls,
&msgw->session->target,
GNUNET_SYSERR,
- msgw->payload, 0);
+ msgw->payload,
+ 0);
GNUNET_free (msgw->msg);
GNUNET_free (msgw);
}
@@ -1908,7 +1879,7 @@ libgnunet_plugin_transport_unix_done (void *cls)
plugin->unix_sock.desc = NULL;
}
GNUNET_CONTAINER_multipeermap_iterate (plugin->session_map,
- &get_session_delete_it,
+ &get_session_delete_it,
plugin);
GNUNET_CONTAINER_multipeermap_destroy (plugin->session_map);
GNUNET_break (0 == plugin->bytes_in_queue);
diff --git a/src/transport/tcp_connection_legacy.c b/src/transport/tcp_connection_legacy.c
index cfb088361..999e8827a 100644
--- a/src/transport/tcp_connection_legacy.c
+++ b/src/transport/tcp_connection_legacy.c
@@ -41,11 +41,12 @@
* is this value divided by the number of address families.
* Default is 5s.
*/
-#define CONNECT_RETRY_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
+#define CONNECT_RETRY_TIMEOUT \
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
-
-#define LOG_STRERROR(kind,syscall) GNUNET_log_from_strerror (kind, "util-connection", syscall)
+#define LOG_STRERROR(kind, syscall) \
+ GNUNET_log_from_strerror (kind, "util-connection", syscall)
/**
@@ -78,14 +79,13 @@ struct GNUNET_CONNECTION_TransmitHandle
/**
* Task called on timeout.
*/
- struct GNUNET_SCHEDULER_Task * timeout_task;
+ struct GNUNET_SCHEDULER_Task *timeout_task;
/**
* At what number of bytes available in the
* write buffer should the notify method be called?
*/
size_t notify_size;
-
};
@@ -129,7 +129,7 @@ struct AddressProbe
/**
* Task waiting for the connection to finish connecting.
*/
- struct GNUNET_SCHEDULER_Task * task;
+ struct GNUNET_SCHEDULER_Task *task;
};
@@ -263,7 +263,6 @@ struct GNUNET_CONNECTION_Handle
* Handle to subsequent connection after proxy handshake completes,
*/
struct GNUNET_CONNECTION_Handle *proxy_handshake;
-
};
@@ -357,9 +356,7 @@ GNUNET_CONNECTION_create_from_accept (GNUNET_CONNECTION_AccessCheck access_cb,
addrlen = sizeof (addr);
sock =
- GNUNET_NETWORK_socket_accept (lsock,
- (struct sockaddr *) &addr,
- &addrlen);
+ GNUNET_NETWORK_socket_accept (lsock, (struct sockaddr *) &addr, &addrlen);
if (NULL == sock)
{
if (EAGAIN != errno)
@@ -375,8 +372,7 @@ GNUNET_CONNECTION_create_from_accept (GNUNET_CONNECTION_AccessCheck access_cb,
sa = (struct sockaddr *) addr;
v6 = (struct sockaddr_in6 *) addr;
- if ( (AF_INET6 == sa->sa_family) &&
- (IN6_IS_ADDR_V4MAPPED (&v6->sin6_addr)) )
+ if ((AF_INET6 == sa->sa_family) && (IN6_IS_ADDR_V4MAPPED (&v6->sin6_addr)))
{
/* convert to V4 address */
v4 = GNUNET_new (struct sockaddr_in);
@@ -386,9 +382,9 @@ GNUNET_CONNECTION_create_from_accept (GNUNET_CONNECTION_AccessCheck access_cb,
v4->sin_len = (u_char) sizeof (struct sockaddr_in);
#endif
GNUNET_memcpy (&v4->sin_addr,
- &((char *) &v6->sin6_addr)[sizeof (struct in6_addr) -
- sizeof (struct in_addr)],
- sizeof (struct in_addr));
+ &((char *) &v6->sin6_addr)[sizeof (struct in6_addr) -
+ sizeof (struct in_addr)],
+ sizeof (struct in_addr));
v4->sin_port = v6->sin6_port;
uaddr = v4;
addrlen = sizeof (struct sockaddr_in);
@@ -403,21 +399,18 @@ GNUNET_CONNECTION_create_from_accept (GNUNET_CONNECTION_AccessCheck access_cb,
{
#if HAVE_GETPEEREID
/* most BSDs */
- if (0 == getpeereid (GNUNET_NETWORK_get_fd (sock),
- &gc.uid,
- &gc.gid))
+ if (0 == getpeereid (GNUNET_NETWORK_get_fd (sock), &gc.uid, &gc.gid))
gcp = &gc;
#else
#ifdef SO_PEERCRED
/* largely traditional GNU/Linux */
olen = sizeof (uc);
- if ( (0 ==
- getsockopt (GNUNET_NETWORK_get_fd (sock),
- SOL_SOCKET,
- SO_PEERCRED,
- &uc,
- &olen)) &&
- (olen == sizeof (uc)) )
+ if ((0 == getsockopt (GNUNET_NETWORK_get_fd (sock),
+ SOL_SOCKET,
+ SO_PEERCRED,
+ &uc,
+ &olen)) &&
+ (olen == sizeof (uc)))
{
gc.uid = uc.uid;
gc.gid = uc.gid;
@@ -441,20 +434,15 @@ GNUNET_CONNECTION_create_from_accept (GNUNET_CONNECTION_AccessCheck access_cb,
#endif
}
- if ( (NULL != access_cb) &&
- (GNUNET_YES != (aret = access_cb (access_cb_cls,
- gcp,
- uaddr,
- addrlen))) )
+ if ((NULL != access_cb) &&
+ (GNUNET_YES != (aret = access_cb (access_cb_cls, gcp, uaddr, addrlen))))
{
if (GNUNET_NO == aret)
LOG (GNUNET_ERROR_TYPE_INFO,
- _("Access denied to `%s'\n"),
- GNUNET_a2s (uaddr,
- addrlen));
+ _ ("Access denied to `%s'\n"),
+ GNUNET_a2s (uaddr, addrlen));
GNUNET_break (GNUNET_OK ==
- GNUNET_NETWORK_socket_shutdown (sock,
- SHUT_RDWR));
+ GNUNET_NETWORK_socket_shutdown (sock, SHUT_RDWR));
GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (sock));
GNUNET_free (uaddr);
return NULL;
@@ -466,9 +454,8 @@ GNUNET_CONNECTION_create_from_accept (GNUNET_CONNECTION_AccessCheck access_cb,
connection->addrlen = addrlen;
connection->sock = sock;
LOG (GNUNET_ERROR_TYPE_INFO,
- _("Accepting connection from `%s': %p\n"),
- GNUNET_a2s (uaddr,
- addrlen),
+ _ ("Accepting connection from `%s': %p\n"),
+ GNUNET_a2s (uaddr, addrlen),
connection);
return connection;
}
@@ -503,14 +490,13 @@ GNUNET_CONNECTION_get_address (struct GNUNET_CONNECTION_Handle *connection,
* @param errcode error code to send
*/
static void
-signal_receive_error (struct GNUNET_CONNECTION_Handle *connection,
- int errcode)
+signal_receive_error (struct GNUNET_CONNECTION_Handle *connection, int errcode)
{
GNUNET_CONNECTION_Receiver receiver;
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Receive encounters error (%s), connection closed (%p)\n",
- STRERROR (errcode),
+ strerror (errcode),
connection);
GNUNET_assert (NULL != (receiver = connection->receiver));
connection->receiver = NULL;
@@ -549,21 +535,18 @@ signal_receive_timeout (struct GNUNET_CONNECTION_Handle *connection)
* @param ecode error code (errno)
*/
static void
-signal_transmit_error (struct GNUNET_CONNECTION_Handle *connection,
- int ecode)
+signal_transmit_error (struct GNUNET_CONNECTION_Handle *connection, int ecode)
{
GNUNET_CONNECTION_TransmitReadyNotify notify;
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Transmission encounterd error (%s), connection closed (%p)\n",
- STRERROR (ecode),
+ strerror (ecode),
connection);
if (NULL != connection->sock)
{
- (void) GNUNET_NETWORK_socket_shutdown (connection->sock,
- SHUT_RDWR);
- GNUNET_break (GNUNET_OK ==
- GNUNET_NETWORK_socket_close (connection->sock));
+ (void) GNUNET_NETWORK_socket_shutdown (connection->sock, SHUT_RDWR);
+ GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (connection->sock));
connection->sock = NULL;
GNUNET_assert (NULL == connection->write_task);
}
@@ -576,12 +559,10 @@ signal_transmit_error (struct GNUNET_CONNECTION_Handle *connection,
return;
}
if (NULL == connection->nth.notify_ready)
- return; /* nobody to tell about it */
+ return; /* nobody to tell about it */
notify = connection->nth.notify_ready;
connection->nth.notify_ready = NULL;
- notify (connection->nth.notify_ready_cls,
- 0,
- NULL);
+ notify (connection->nth.notify_ready_cls, 0, NULL);
}
@@ -597,7 +578,7 @@ connect_fail_continuation (struct GNUNET_CONNECTION_Handle *connection)
LOG (GNUNET_ERROR_TYPE_INFO,
"Failed to establish TCP connection to `%s:%u', no further addresses to try.\n",
connection->hostname,
- connection->port);
+ connection->port);
GNUNET_break (NULL == connection->ap_head);
GNUNET_break (NULL == connection->ap_tail);
GNUNET_break (GNUNET_NO == connection->dns_active);
@@ -608,15 +589,13 @@ connect_fail_continuation (struct GNUNET_CONNECTION_Handle *connection)
/* signal errors for jobs that used to wait on the connection */
connection->destroy_later = 1;
if (NULL != connection->receiver)
- signal_receive_error (connection,
- ECONNREFUSED);
+ signal_receive_error (connection, ECONNREFUSED);
if (NULL != connection->nth.notify_ready)
{
GNUNET_assert (NULL != connection->nth.timeout_task);
GNUNET_SCHEDULER_cancel (connection->nth.timeout_task);
connection->nth.timeout_task = NULL;
- signal_transmit_error (connection,
- ECONNREFUSED);
+ signal_transmit_error (connection, ECONNREFUSED);
}
if (-1 == connection->destroy_later)
{
@@ -658,21 +637,21 @@ connect_success_continuation (struct GNUNET_CONNECTION_Handle *connection)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Connection to `%s' succeeded! (%p)\n",
- GNUNET_a2s (connection->addr,
- connection->addrlen),
+ GNUNET_a2s (connection->addr, connection->addrlen),
connection);
/* trigger jobs that waited for the connection */
if (NULL != connection->receiver)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Connection succeeded, starting with receiving data (%p)\n",
- connection);
+ connection);
GNUNET_assert (NULL == connection->read_task);
connection->read_task =
- GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_absolute_get_remaining
- (connection->receive_timeout),
- connection->sock,
- &receive_ready, connection);
+ GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_absolute_get_remaining (
+ connection->receive_timeout),
+ connection->sock,
+ &receive_ready,
+ connection);
}
if (NULL != connection->nth.notify_ready)
{
@@ -684,9 +663,11 @@ connect_success_continuation (struct GNUNET_CONNECTION_Handle *connection)
connection->nth.timeout_task = NULL;
GNUNET_assert (connection->write_task == NULL);
connection->write_task =
- GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_absolute_get_remaining
- (connection->nth.transmit_timeout), connection->sock,
- &transmit_ready, connection);
+ GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_absolute_get_remaining (
+ connection->nth.transmit_timeout),
+ connection->sock,
+ &transmit_ready,
+ connection);
}
}
@@ -708,28 +689,24 @@ connect_probe_continuation (void *cls)
socklen_t len;
GNUNET_assert (NULL != ap->sock);
- GNUNET_CONTAINER_DLL_remove (connection->ap_head,
- connection->ap_tail,
- ap);
+ GNUNET_CONTAINER_DLL_remove (connection->ap_head, connection->ap_tail, ap);
len = sizeof (error);
errno = 0;
error = 0;
tc = GNUNET_SCHEDULER_get_task_context ();
- if ( (0 == (tc->reason & GNUNET_SCHEDULER_REASON_WRITE_READY)) ||
- (GNUNET_OK !=
- GNUNET_NETWORK_socket_getsockopt (ap->sock,
- SOL_SOCKET,
- SO_ERROR,
- &error,
- &len)) ||
- (0 != error) )
+ if ((0 == (tc->reason & GNUNET_SCHEDULER_REASON_WRITE_READY)) ||
+ (GNUNET_OK != GNUNET_NETWORK_socket_getsockopt (ap->sock,
+ SOL_SOCKET,
+ SO_ERROR,
+ &error,
+ &len)) ||
+ (0 != error))
{
- GNUNET_break (GNUNET_OK ==
- GNUNET_NETWORK_socket_close (ap->sock));
+ GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (ap->sock));
GNUNET_free (ap);
- if ( (NULL == connection->ap_head) &&
- (GNUNET_NO == connection->dns_active) &&
- (NULL == connection->proxy_handshake) )
+ if ((NULL == connection->ap_head) &&
+ (GNUNET_NO == connection->dns_active) &&
+ (NULL == connection->proxy_handshake))
connect_fail_continuation (connection);
return;
}
@@ -745,9 +722,7 @@ connect_probe_continuation (void *cls)
{
GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (pos->sock));
GNUNET_SCHEDULER_cancel (pos->task);
- GNUNET_CONTAINER_DLL_remove (connection->ap_head,
- connection->ap_tail,
- pos);
+ GNUNET_CONTAINER_DLL_remove (connection->ap_head, connection->ap_tail, pos);
GNUNET_free (pos);
}
connect_success_continuation (connection);
@@ -774,14 +749,13 @@ try_connect_using_address (void *cls,
if (NULL == addr)
{
connection->dns_active = NULL;
- if ((NULL == connection->ap_head) &&
- (NULL == connection->sock) &&
+ if ((NULL == connection->ap_head) && (NULL == connection->sock) &&
(NULL == connection->proxy_handshake))
connect_fail_continuation (connection);
return;
}
if (NULL != connection->sock)
- return; /* already connected */
+ return; /* already connected */
GNUNET_assert (NULL == connection->addr);
/* try to connect */
LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -807,23 +781,20 @@ try_connect_using_address (void *cls,
default:
GNUNET_break (0);
GNUNET_free (ap);
- return; /* not supported by us */
+ return; /* not supported by us */
}
- ap->sock = GNUNET_NETWORK_socket_create (ap->addr->sa_family,
- SOCK_STREAM, 0);
+ ap->sock = GNUNET_NETWORK_socket_create (ap->addr->sa_family, SOCK_STREAM, 0);
if (NULL == ap->sock)
{
GNUNET_free (ap);
- return; /* not supported by OS */
+ return; /* not supported by OS */
}
LOG (GNUNET_ERROR_TYPE_INFO,
"Trying to connect to `%s' (%p)\n",
GNUNET_a2s (ap->addr, ap->addrlen),
connection);
if ((GNUNET_OK !=
- GNUNET_NETWORK_socket_connect (ap->sock,
- ap->addr,
- ap->addrlen)) &&
+ GNUNET_NETWORK_socket_connect (ap->sock, ap->addr, ap->addrlen)) &&
(EINPROGRESS != errno))
{
/* maybe refused / unsupported address, try next */
@@ -836,14 +807,16 @@ try_connect_using_address (void *cls,
delay = CONNECT_RETRY_TIMEOUT;
if (NULL != connection->nth.notify_ready)
delay = GNUNET_TIME_relative_min (delay,
- GNUNET_TIME_absolute_get_remaining (connection->nth.transmit_timeout));
+ GNUNET_TIME_absolute_get_remaining (
+ connection->nth.transmit_timeout));
if (NULL != connection->receiver)
delay = GNUNET_TIME_relative_min (delay,
- GNUNET_TIME_absolute_get_remaining (connection->receive_timeout));
+ GNUNET_TIME_absolute_get_remaining (
+ connection->receive_timeout));
ap->task = GNUNET_SCHEDULER_add_write_net (delay,
- ap->sock,
- &connect_probe_continuation,
- ap);
+ ap->sock,
+ &connect_probe_continuation,
+ ap);
}
@@ -858,25 +831,25 @@ try_connect_using_address (void *cls,
* @return the connection handle
*/
struct GNUNET_CONNECTION_Handle *
-GNUNET_CONNECTION_create_from_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
- const char *hostname,
- uint16_t port)
+GNUNET_CONNECTION_create_from_connect (
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
+ const char *hostname,
+ uint16_t port)
{
struct GNUNET_CONNECTION_Handle *connection;
- GNUNET_assert (0 < strlen (hostname)); /* sanity check */
+ GNUNET_assert (0 < strlen (hostname)); /* sanity check */
connection = GNUNET_new (struct GNUNET_CONNECTION_Handle);
connection->cfg = cfg;
connection->write_buffer_size = GNUNET_MIN_MESSAGE_SIZE;
connection->write_buffer = GNUNET_malloc (connection->write_buffer_size);
connection->port = port;
connection->hostname = GNUNET_strdup (hostname);
- connection->dns_active =
- GNUNET_RESOLVER_ip_get (connection->hostname,
- AF_UNSPEC,
- CONNECT_RETRY_TIMEOUT,
- &try_connect_using_address,
- connection);
+ connection->dns_active = GNUNET_RESOLVER_ip_get (connection->hostname,
+ AF_UNSPEC,
+ CONNECT_RETRY_TIMEOUT,
+ &try_connect_using_address,
+ connection);
return connection;
}
@@ -891,14 +864,15 @@ GNUNET_CONNECTION_create_from_connect (const struct GNUNET_CONFIGURATION_Handle
* @return the connection handle, NULL on systems without UNIX support
*/
struct GNUNET_CONNECTION_Handle *
-GNUNET_CONNECTION_create_from_connect_to_unixpath (const struct GNUNET_CONFIGURATION_Handle *cfg,
- const char *unixpath)
+GNUNET_CONNECTION_create_from_connect_to_unixpath (
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
+ const char *unixpath)
{
#ifdef AF_UNIX
struct GNUNET_CONNECTION_Handle *connection;
struct sockaddr_un *un;
- GNUNET_assert (0 < strlen (unixpath)); /* sanity check */
+ GNUNET_assert (0 < strlen (unixpath)); /* sanity check */
un = GNUNET_new (struct sockaddr_un);
un->sun_family = AF_UNIX;
GNUNET_strlcpy (un->sun_path, unixpath, sizeof (un->sun_path));
@@ -907,7 +881,7 @@ GNUNET_CONNECTION_create_from_connect_to_unixpath (const struct GNUNET_CONFIGURA
int abstract;
abstract = GNUNET_CONFIGURATION_get_value_yesno (cfg,
- "TESTING",
+ "TESTING",
"USE_ABSTRACT_SOCKETS");
if (GNUNET_YES == abstract)
un->sun_path[0] = '\0';
@@ -924,9 +898,7 @@ GNUNET_CONNECTION_create_from_connect_to_unixpath (const struct GNUNET_CONFIGURA
connection->hostname = NULL;
connection->addr = (struct sockaddr *) un;
connection->addrlen = sizeof (struct sockaddr_un);
- connection->sock = GNUNET_NETWORK_socket_create (AF_UNIX,
- SOCK_STREAM,
- 0);
+ connection->sock = GNUNET_NETWORK_socket_create (AF_UNIX, SOCK_STREAM, 0);
if (NULL == connection->sock)
{
GNUNET_free (connection->addr);
@@ -934,15 +906,13 @@ GNUNET_CONNECTION_create_from_connect_to_unixpath (const struct GNUNET_CONFIGURA
GNUNET_free (connection);
return NULL;
}
- if ( (GNUNET_OK !=
- GNUNET_NETWORK_socket_connect (connection->sock,
- connection->addr,
- connection->addrlen)) &&
- (EINPROGRESS != errno) )
+ if ((GNUNET_OK != GNUNET_NETWORK_socket_connect (connection->sock,
+ connection->addr,
+ connection->addrlen)) &&
+ (EINPROGRESS != errno))
{
/* Just return; we expect everything to work eventually so don't fail HARD */
- GNUNET_break (GNUNET_OK ==
- GNUNET_NETWORK_socket_close (connection->sock));
+ GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (connection->sock));
connection->sock = NULL;
return connection;
}
@@ -971,17 +941,14 @@ GNUNET_CONNECTION_connect_socket (struct GNUNET_NETWORK_Handle *s,
{
struct GNUNET_CONNECTION_Handle *connection;
- if ( (GNUNET_OK !=
- GNUNET_NETWORK_socket_connect (s, serv_addr, addrlen)) &&
- (EINPROGRESS != errno) )
+ if ((GNUNET_OK != GNUNET_NETWORK_socket_connect (s, serv_addr, addrlen)) &&
+ (EINPROGRESS != errno))
{
/* maybe refused / unsupported address, try next */
- LOG_STRERROR (GNUNET_ERROR_TYPE_DEBUG,
- "connect");
+ LOG_STRERROR (GNUNET_ERROR_TYPE_DEBUG, "connect");
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Attempt to connect to `%s' failed\n",
- GNUNET_a2s (serv_addr,
- addrlen));
+ GNUNET_a2s (serv_addr, addrlen));
GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (s));
return NULL;
}
@@ -1018,13 +985,10 @@ GNUNET_CONNECTION_create_from_sockaddr (int af_family,
s = GNUNET_NETWORK_socket_create (af_family, SOCK_STREAM, 0);
if (NULL == s)
{
- LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK,
- "socket");
+ LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, "socket");
return NULL;
}
- return GNUNET_CONNECTION_connect_socket (s,
- serv_addr,
- addrlen);
+ return GNUNET_CONNECTION_connect_socket (s, serv_addr, addrlen);
}
@@ -1039,12 +1003,10 @@ GNUNET_CONNECTION_create_from_sockaddr (int af_family,
int
GNUNET_CONNECTION_check (struct GNUNET_CONNECTION_Handle *connection)
{
- if ((NULL != connection->ap_head) ||
- (NULL != connection->dns_active) ||
+ if ((NULL != connection->ap_head) || (NULL != connection->dns_active) ||
(NULL != connection->proxy_handshake))
- return GNUNET_YES; /* still trying to connect */
- if ( (0 != connection->destroy_later) ||
- (NULL == connection->sock) )
+ return GNUNET_YES; /* still trying to connect */
+ if ((0 != connection->destroy_later) || (NULL == connection->sock))
return GNUNET_NO;
return GNUNET_YES;
}
@@ -1067,9 +1029,7 @@ GNUNET_CONNECTION_destroy (struct GNUNET_CONNECTION_Handle *connection)
connection->destroy_later = -1;
return;
}
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Shutting down connection (%p)\n",
- connection);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Shutting down connection (%p)\n", connection);
GNUNET_assert (NULL == connection->nth.notify_ready);
GNUNET_assert (NULL == connection->receiver);
if (NULL != connection->write_task)
@@ -1098,27 +1058,21 @@ GNUNET_CONNECTION_destroy (struct GNUNET_CONNECTION_Handle *connection)
{
/* GNUNET_CONNECTION_destroy (connection->proxy_handshake); */
connection->proxy_handshake->destroy_later = -1;
- connection->proxy_handshake = NULL; /* Not leaked ??? */
+ connection->proxy_handshake = NULL; /* Not leaked ??? */
}
while (NULL != (pos = connection->ap_head))
{
GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (pos->sock));
GNUNET_SCHEDULER_cancel (pos->task);
- GNUNET_CONTAINER_DLL_remove (connection->ap_head,
- connection->ap_tail,
- pos);
+ GNUNET_CONTAINER_DLL_remove (connection->ap_head, connection->ap_tail, pos);
GNUNET_free (pos);
}
- if ( (NULL != connection->sock) &&
- (GNUNET_YES != connection->persist) )
+ if ((NULL != connection->sock) && (GNUNET_YES != connection->persist))
{
if ((GNUNET_OK !=
- GNUNET_NETWORK_socket_shutdown (connection->sock,
- SHUT_RDWR)) &&
- (ENOTCONN != errno) &&
- (ECONNRESET != errno) )
- LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING,
- "shutdown");
+ GNUNET_NETWORK_socket_shutdown (connection->sock, SHUT_RDWR)) &&
+ (ENOTCONN != errno) && (ECONNRESET != errno))
+ LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, "shutdown");
}
if (NULL != connection->sock)
{
@@ -1129,7 +1083,8 @@ GNUNET_CONNECTION_destroy (struct GNUNET_CONNECTION_Handle *connection)
}
else
{
- GNUNET_NETWORK_socket_free_memory_only_ (connection->sock); /* at least no memory leak (we deliberately
+ GNUNET_NETWORK_socket_free_memory_only_ (
+ connection->sock); /* at least no memory leak (we deliberately
* leak the socket in this special case) ... */
}
}
@@ -1160,12 +1115,12 @@ receive_ready (void *cls)
if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT))
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Receive from `%s' encounters error: timeout (%s, %p)\n",
- GNUNET_a2s (connection->addr,
- connection->addrlen),
- GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (connection->receive_timeout),
- GNUNET_YES),
- connection);
+ "Receive from `%s' encounters error: timeout (%s, %p)\n",
+ GNUNET_a2s (connection->addr, connection->addrlen),
+ GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (
+ connection->receive_timeout),
+ GNUNET_YES),
+ connection);
signal_receive_timeout (connection);
return;
}
@@ -1175,12 +1130,9 @@ receive_ready (void *cls)
signal_receive_error (connection, ECONNREFUSED);
return;
}
- GNUNET_assert (GNUNET_NETWORK_fdset_isset (tc->read_ready,
- connection->sock));
+ GNUNET_assert (GNUNET_NETWORK_fdset_isset (tc->read_ready, connection->sock));
RETRY:
- ret = GNUNET_NETWORK_socket_recv (connection->sock,
- buffer,
- connection->max);
+ ret = GNUNET_NETWORK_socket_recv (connection->sock, buffer, connection->max);
if (-1 == ret)
{
if (EINTR == errno)
@@ -1192,8 +1144,7 @@ RETRY:
"receive_ready read %u/%u bytes from `%s' (%p)!\n",
(unsigned int) ret,
connection->max,
- GNUNET_a2s (connection->addr,
- connection->addrlen),
+ GNUNET_a2s (connection->addr, connection->addrlen),
connection);
GNUNET_assert (NULL != (receiver = connection->receiver));
connection->receiver = NULL;
@@ -1238,22 +1189,18 @@ GNUNET_CONNECTION_receive (struct GNUNET_CONNECTION_Handle *connection,
if (NULL != connection->sock)
{
connection->read_task =
- GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_absolute_get_remaining
- (connection->receive_timeout),
+ GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_absolute_get_remaining (
+ connection->receive_timeout),
connection->sock,
&receive_ready,
connection);
return GNUNET_OK;
}
- if ((NULL == connection->dns_active) &&
- (NULL == connection->ap_head) &&
+ if ((NULL == connection->dns_active) && (NULL == connection->ap_head) &&
(NULL == connection->proxy_handshake))
{
connection->receiver = NULL;
- receiver (receiver_cls,
- NULL, 0,
- NULL, 0,
- ETIMEDOUT);
+ receiver (receiver_cls, NULL, 0, NULL, 0, ETIMEDOUT);
return GNUNET_SYSERR;
}
return GNUNET_OK;
@@ -1297,13 +1244,11 @@ process_notify (struct GNUNET_CONNECTION_Handle *connection)
size_t size;
GNUNET_CONNECTION_TransmitReadyNotify notify;
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "process_notify is running\n");
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "process_notify is running\n");
GNUNET_assert (NULL == connection->write_task);
if (NULL == (notify = connection->nth.notify_ready))
{
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "No one to notify\n");
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "No one to notify\n");
return GNUNET_NO;
}
used = connection->write_buffer_off - connection->write_buffer_pos;
@@ -1311,8 +1256,7 @@ process_notify (struct GNUNET_CONNECTION_Handle *connection)
size = connection->nth.notify_size;
if (size > avail)
{
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Not enough buffer\n");
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Not enough buffer\n");
return GNUNET_NO;
}
connection->nth.notify_ready = NULL;
@@ -1327,9 +1271,9 @@ process_notify (struct GNUNET_CONNECTION_Handle *connection)
}
avail = connection->write_buffer_size - connection->write_buffer_off;
GNUNET_assert (avail >= size);
- size =
- notify (connection->nth.notify_ready_cls, avail,
- &connection->write_buffer[connection->write_buffer_off]);
+ size = notify (connection->nth.notify_ready_cls,
+ avail,
+ &connection->write_buffer[connection->write_buffer_off]);
GNUNET_assert (size <= avail);
if (0 != size)
connection->write_buffer_off += size;
@@ -1358,15 +1302,12 @@ transmit_timeout (void *cls)
"Transmit to `%s:%u/%s' fails, time out reached (%p).\n",
connection->hostname,
connection->port,
- GNUNET_a2s (connection->addr,
- connection->addrlen),
+ GNUNET_a2s (connection->addr, connection->addrlen),
connection);
notify = connection->nth.notify_ready;
GNUNET_assert (NULL != notify);
connection->nth.notify_ready = NULL;
- notify (connection->nth.notify_ready_cls,
- 0,
- NULL);
+ notify (connection->nth.notify_ready_cls, 0, NULL);
}
@@ -1393,9 +1334,7 @@ connect_error (void *cls)
connection->write_task = NULL;
notify = connection->nth.notify_ready;
connection->nth.notify_ready = NULL;
- notify (connection->nth.notify_ready_cls,
- 0,
- NULL);
+ notify (connection->nth.notify_ready_cls, 0, NULL);
}
@@ -1413,9 +1352,7 @@ transmit_ready (void *cls)
ssize_t ret;
size_t have;
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "transmit_ready running (%p).\n",
- connection);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "transmit_ready running (%p).\n", connection);
GNUNET_assert (NULL != connection->write_task);
connection->write_task = NULL;
GNUNET_assert (NULL == connection->nth.timeout_task);
@@ -1424,8 +1361,7 @@ transmit_ready (void *cls)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Transmit to `%s' fails, time out reached (%p).\n",
- GNUNET_a2s (connection->addr,
- connection->addrlen),
+ GNUNET_a2s (connection->addr, connection->addrlen),
connection);
notify = connection->nth.notify_ready;
GNUNET_assert (NULL != notify);
@@ -1441,8 +1377,7 @@ transmit_ready (void *cls)
* Hence retry. */
goto SCHEDULE_WRITE;
}
- if (! GNUNET_NETWORK_fdset_isset (tc->write_ready,
- connection->sock))
+ if (! GNUNET_NETWORK_fdset_isset (tc->write_ready, connection->sock))
{
GNUNET_assert (NULL == connection->write_task);
/* special circumstances (in particular, shutdown): not yet ready
@@ -1454,7 +1389,7 @@ transmit_ready (void *cls)
(connection->write_buffer_size < connection->nth.notify_size))
{
connection->write_buffer =
- GNUNET_realloc (connection->write_buffer, connection->nth.notify_size);
+ GNUNET_realloc (connection->write_buffer, connection->nth.notify_size);
connection->write_buffer_size = connection->nth.notify_size;
}
process_notify (connection);
@@ -1465,13 +1400,15 @@ transmit_ready (void *cls)
return;
}
GNUNET_assert (have <= connection->write_buffer_size);
- GNUNET_assert (have + connection->write_buffer_pos <= connection->write_buffer_size);
+ GNUNET_assert (have + connection->write_buffer_pos <=
+ connection->write_buffer_size);
GNUNET_assert (connection->write_buffer_pos <= connection->write_buffer_size);
RETRY:
ret =
- GNUNET_NETWORK_socket_send (connection->sock,
- &connection->write_buffer[connection->write_buffer_pos],
- have);
+ GNUNET_NETWORK_socket_send (connection->sock,
+ &connection
+ ->write_buffer[connection->write_buffer_pos],
+ have);
if (-1 == ret)
{
if (EINTR == errno)
@@ -1488,8 +1425,7 @@ RETRY:
"Connection transmitted %u/%u bytes to `%s' (%p)\n",
(unsigned int) ret,
have,
- GNUNET_a2s (connection->addr,
- connection->addrlen),
+ GNUNET_a2s (connection->addr, connection->addrlen),
connection);
connection->write_buffer_pos += ret;
if (connection->write_buffer_pos == connection->write_buffer_off)
@@ -1498,25 +1434,25 @@ RETRY:
connection->write_buffer_pos = 0;
connection->write_buffer_off = 0;
}
- if ( (0 == connection->write_buffer_off) &&
- (NULL == connection->nth.notify_ready) )
- return; /* all data sent! */
+ if ((0 == connection->write_buffer_off) &&
+ (NULL == connection->nth.notify_ready))
+ return; /* all data sent! */
/* not done writing, schedule more */
SCHEDULE_WRITE:
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Re-scheduling transmit_ready (more to do) (%p).\n",
connection);
have = connection->write_buffer_off - connection->write_buffer_pos;
- GNUNET_assert ( (NULL != connection->nth.notify_ready) ||
- (have > 0) );
+ GNUNET_assert ((NULL != connection->nth.notify_ready) || (have > 0));
if (NULL == connection->write_task)
connection->write_task =
- GNUNET_SCHEDULER_add_write_net ((connection->nth.notify_ready ==
- NULL) ? GNUNET_TIME_UNIT_FOREVER_REL :
- GNUNET_TIME_absolute_get_remaining
- (connection->nth.transmit_timeout),
- connection->sock,
- &transmit_ready, connection);
+ GNUNET_SCHEDULER_add_write_net ((connection->nth.notify_ready == NULL)
+ ? GNUNET_TIME_UNIT_FOREVER_REL
+ : GNUNET_TIME_absolute_get_remaining (
+ connection->nth.transmit_timeout),
+ connection->sock,
+ &transmit_ready,
+ connection);
}
@@ -1535,11 +1471,12 @@ SCHEDULE_WRITE:
* NULL if we are already going to notify someone else (busy)
*/
struct GNUNET_CONNECTION_TransmitHandle *
-GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle *connection,
- size_t size,
- struct GNUNET_TIME_Relative timeout,
- GNUNET_CONNECTION_TransmitReadyNotify notify,
- void *notify_cls)
+GNUNET_CONNECTION_notify_transmit_ready (
+ struct GNUNET_CONNECTION_Handle *connection,
+ size_t size,
+ struct GNUNET_TIME_Relative timeout,
+ GNUNET_CONNECTION_TransmitReadyNotify notify,
+ void *notify_cls)
{
if (NULL != connection->nth.notify_ready)
{
@@ -1557,15 +1494,13 @@ GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle *connec
connection->nth.notify_size = size;
connection->nth.transmit_timeout = GNUNET_TIME_relative_to_absolute (timeout);
GNUNET_assert (NULL == connection->nth.timeout_task);
- if ((NULL == connection->sock) &&
- (NULL == connection->ap_head) &&
- (NULL == connection->dns_active) &&
- (NULL == connection->proxy_handshake))
+ if ((NULL == connection->sock) && (NULL == connection->ap_head) &&
+ (NULL == connection->dns_active) && (NULL == connection->proxy_handshake))
{
if (NULL != connection->write_task)
GNUNET_SCHEDULER_cancel (connection->write_task);
- connection->write_task = GNUNET_SCHEDULER_add_now (&connect_error,
- connection);
+ connection->write_task =
+ GNUNET_SCHEDULER_add_now (&connect_error, connection);
return &connection->nth;
}
if (NULL != connection->write_task)
@@ -1577,10 +1512,11 @@ GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle *connec
"Scheduling transmission (%p).\n",
connection);
connection->write_task =
- GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_absolute_get_remaining
- (connection->nth.transmit_timeout),
- connection->sock,
- &transmit_ready, connection);
+ GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_absolute_get_remaining (
+ connection->nth.transmit_timeout),
+ connection->sock,
+ &transmit_ready,
+ connection);
return &connection->nth;
}
/* not yet connected, wait for connection */
@@ -1588,9 +1524,7 @@ GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle *connec
"Need to wait to schedule transmission for connection, adding timeout task (%p).\n",
connection);
connection->nth.timeout_task =
- GNUNET_SCHEDULER_add_delayed (timeout,
- &transmit_timeout,
- connection);
+ GNUNET_SCHEDULER_add_delayed (timeout, &transmit_timeout, connection);
return &connection->nth;
}
@@ -1601,7 +1535,8 @@ GNUNET_CONNECTION_notify_transmit_ready (struct GNUNET_CONNECTION_Handle *connec
* @param th notification to cancel
*/
void
-GNUNET_CONNECTION_notify_transmit_ready_cancel (struct GNUNET_CONNECTION_TransmitHandle *th)
+GNUNET_CONNECTION_notify_transmit_ready_cancel (
+ struct GNUNET_CONNECTION_TransmitHandle *th)
{
GNUNET_assert (NULL != th->notify_ready);
th->notify_ready = NULL;
@@ -1625,9 +1560,11 @@ GNUNET_CONNECTION_notify_transmit_ready_cancel (struct GNUNET_CONNECTION_Transmi
* @return connection to be proxied
*/
struct GNUNET_CONNECTION_Handle *
-GNUNET_CONNECTION_create_proxied_from_handshake (struct GNUNET_CONNECTION_Handle *cph)
+GNUNET_CONNECTION_create_proxied_from_handshake (
+ struct GNUNET_CONNECTION_Handle *cph)
{
- struct GNUNET_CONNECTION_Handle *proxied = GNUNET_CONNECTION_create_from_existing (NULL);
+ struct GNUNET_CONNECTION_Handle *proxied =
+ GNUNET_CONNECTION_create_from_existing (NULL);
proxied->proxy_handshake = cph;
return proxied;
diff --git a/src/transport/tcp_service_legacy.c b/src/transport/tcp_service_legacy.c
index 19508a39f..e59fa4a1c 100644
--- a/src/transport/tcp_service_legacy.c
+++ b/src/transport/tcp_service_legacy.c
@@ -224,7 +224,6 @@ struct LEGACY_SERVICE_Context
* Our options.
*/
enum LEGACY_SERVICE_Options options;
-
};
@@ -247,7 +246,7 @@ write_test (void *cls, size_t size, void *buf)
if (size < sizeof (struct GNUNET_MessageHeader))
{
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
- return 0; /* client disconnected */
+ return 0; /* client disconnected */
}
msg = (struct GNUNET_MessageHeader *) buf;
msg->type = htons (GNUNET_MESSAGE_TYPE_TEST);
@@ -265,7 +264,8 @@ write_test (void *cls, size_t size, void *buf)
* @param message the actual message
*/
static void
-handle_test (void *cls, struct GNUNET_SERVER_Client *client,
+handle_test (void *cls,
+ struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *message)
{
/* simply bounce message back to acknowledge */
@@ -273,7 +273,8 @@ handle_test (void *cls, struct GNUNET_SERVER_Client *client,
GNUNET_SERVER_notify_transmit_ready (client,
sizeof (struct GNUNET_MessageHeader),
GNUNET_TIME_UNIT_FOREVER_REL,
- &write_test, client))
+ &write_test,
+ client))
GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
}
@@ -283,11 +284,12 @@ handle_test (void *cls, struct GNUNET_SERVER_Client *client,
* "callback_cls" fields will be replaced with the specific service
* struct.
*/
-static const struct GNUNET_SERVER_MessageHandler defhandlers[] = {
- {&handle_test, NULL, GNUNET_MESSAGE_TYPE_TEST,
- sizeof (struct GNUNET_MessageHeader)},
- {NULL, NULL, 0, 0}
-};
+static const struct GNUNET_SERVER_MessageHandler defhandlers[] =
+ {{&handle_test,
+ NULL,
+ GNUNET_MESSAGE_TYPE_TEST,
+ sizeof (struct GNUNET_MessageHeader)},
+ {NULL, NULL, 0, 0}};
/* ****************** service core routines ************** */
@@ -304,8 +306,10 @@ static const struct GNUNET_SERVER_MessageHandler defhandlers[] = {
* for unknown address family (will be denied).
*/
static int
-check_access (void *cls, const struct GNUNET_CONNECTION_Credentials *uc,
- const struct sockaddr *addr, socklen_t addrlen)
+check_access (void *cls,
+ const struct GNUNET_CONNECTION_Credentials *uc,
+ const struct sockaddr *addr,
+ socklen_t addrlen)
{
struct LEGACY_SERVICE_Context *sctx = cls;
const struct sockaddr_in *i4;
@@ -319,32 +323,33 @@ check_access (void *cls, const struct GNUNET_CONNECTION_Credentials *uc,
i4 = (const struct sockaddr_in *) addr;
ret = ((NULL == sctx->v4_allowed) ||
(check_ipv4_listed (sctx->v4_allowed, &i4->sin_addr))) &&
- ((NULL == sctx->v4_denied) ||
- (!check_ipv4_listed (sctx->v4_denied, &i4->sin_addr)));
+ ((NULL == sctx->v4_denied) ||
+ (! check_ipv4_listed (sctx->v4_denied, &i4->sin_addr)));
break;
case AF_INET6:
GNUNET_assert (addrlen == sizeof (struct sockaddr_in6));
i6 = (const struct sockaddr_in6 *) addr;
ret = ((NULL == sctx->v6_allowed) ||
(check_ipv6_listed (sctx->v6_allowed, &i6->sin6_addr))) &&
- ((NULL == sctx->v6_denied) ||
- (!check_ipv6_listed (sctx->v6_denied, &i6->sin6_addr)));
+ ((NULL == sctx->v6_denied) ||
+ (! check_ipv6_listed (sctx->v6_denied, &i6->sin6_addr)));
break;
#ifndef WINDOWS
case AF_UNIX:
- ret = GNUNET_OK; /* controlled using file-system ACL now */
+ ret = GNUNET_OK; /* controlled using file-system ACL now */
break;
#endif
default:
- LOG (GNUNET_ERROR_TYPE_WARNING, _("Unknown address family %d\n"),
+ LOG (GNUNET_ERROR_TYPE_WARNING,
+ _ ("Unknown address family %d\n"),
addr->sa_family);
return GNUNET_SYSERR;
}
if (GNUNET_OK != ret)
{
LOG (GNUNET_ERROR_TYPE_WARNING,
- _("Access from `%s' denied to service `%s'\n"),
- GNUNET_a2s (addr, addrlen),
+ _ ("Access from `%s' denied to service `%s'\n"),
+ GNUNET_a2s (addr, addrlen),
sctx->service_name);
}
return ret;
@@ -363,9 +368,10 @@ get_pid_file_name (struct LEGACY_SERVICE_Context *sctx)
{
char *pif;
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_filename (sctx->cfg, sctx->service_name,
- "PIDFILE", &pif))
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (sctx->cfg,
+ sctx->service_name,
+ "PIDFILE",
+ &pif))
return NULL;
return pif;
}
@@ -387,7 +393,7 @@ process_acl4 (struct GNUNET_STRINGS_IPv4NetworkPolicy **ret,
{
char *opt;
- if (!GNUNET_CONFIGURATION_have_value (sctx->cfg, sctx->service_name, option))
+ if (! GNUNET_CONFIGURATION_have_value (sctx->cfg, sctx->service_name, option))
{
*ret = NULL;
return GNUNET_OK;
@@ -395,12 +401,15 @@ process_acl4 (struct GNUNET_STRINGS_IPv4NetworkPolicy **ret,
GNUNET_break (GNUNET_OK ==
GNUNET_CONFIGURATION_get_value_string (sctx->cfg,
sctx->service_name,
- option, &opt));
+ option,
+ &opt));
if (NULL == (*ret = GNUNET_STRINGS_parse_ipv4_policy (opt)))
{
LOG (GNUNET_ERROR_TYPE_WARNING,
- _("Could not parse IPv4 network specification `%s' for `%s:%s'\n"),
- opt, sctx->service_name, option);
+ _ ("Could not parse IPv4 network specification `%s' for `%s:%s'\n"),
+ opt,
+ sctx->service_name,
+ option);
GNUNET_free (opt);
return GNUNET_SYSERR;
}
@@ -425,7 +434,7 @@ process_acl6 (struct GNUNET_STRINGS_IPv6NetworkPolicy **ret,
{
char *opt;
- if (!GNUNET_CONFIGURATION_have_value (sctx->cfg, sctx->service_name, option))
+ if (! GNUNET_CONFIGURATION_have_value (sctx->cfg, sctx->service_name, option))
{
*ret = NULL;
return GNUNET_OK;
@@ -433,12 +442,15 @@ process_acl6 (struct GNUNET_STRINGS_IPv6NetworkPolicy **ret,
GNUNET_break (GNUNET_OK ==
GNUNET_CONFIGURATION_get_value_string (sctx->cfg,
sctx->service_name,
- option, &opt));
+ option,
+ &opt));
if (NULL == (*ret = GNUNET_STRINGS_parse_ipv6_policy (opt)))
{
LOG (GNUNET_ERROR_TYPE_WARNING,
- _("Could not parse IPv6 network specification `%s' for `%s:%s'\n"),
- opt, sctx->service_name, option);
+ _ ("Could not parse IPv6 network specification `%s' for `%s:%s'\n"),
+ opt,
+ sctx->service_name,
+ option);
GNUNET_free (opt);
return GNUNET_SYSERR;
}
@@ -507,10 +519,11 @@ add_unixpath (struct sockaddr **saddrs,
* set to NULL).
*/
int
-LEGACY_SERVICE_get_server_addresses (const char *service_name,
- const struct GNUNET_CONFIGURATION_Handle *cfg,
- struct sockaddr ***addrs,
- socklen_t ** addr_lens)
+LEGACY_SERVICE_get_server_addresses (
+ const char *service_name,
+ const struct GNUNET_CONFIGURATION_Handle *cfg,
+ struct sockaddr ***addrs,
+ socklen_t **addr_lens)
{
int disablev6;
struct GNUNET_NETWORK_Handle *desc;
@@ -534,8 +547,9 @@ LEGACY_SERVICE_get_server_addresses (const char *service_name,
if (GNUNET_CONFIGURATION_have_value (cfg, service_name, "DISABLEV6"))
{
if (GNUNET_SYSERR ==
- (disablev6 =
- GNUNET_CONFIGURATION_get_value_yesno (cfg, service_name, "DISABLEV6")))
+ (disablev6 = GNUNET_CONFIGURATION_get_value_yesno (cfg,
+ service_name,
+ "DISABLEV6")))
return GNUNET_SYSERR;
}
else
@@ -554,8 +568,10 @@ LEGACY_SERVICE_get_server_addresses (const char *service_name,
return GNUNET_SYSERR;
}
LOG (GNUNET_ERROR_TYPE_INFO,
- _("Disabling IPv6 support for service `%s', failed to create IPv6 socket: %s\n"),
- service_name, STRERROR (errno));
+ _ (
+ "Disabling IPv6 support for service `%s', failed to create IPv6 socket: %s\n"),
+ service_name,
+ strerror (errno));
disablev6 = GNUNET_YES;
}
else
@@ -568,18 +584,19 @@ LEGACY_SERVICE_get_server_addresses (const char *service_name,
port = 0;
if (GNUNET_CONFIGURATION_have_value (cfg, service_name, "PORT"))
{
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_number (cfg, service_name,
- "PORT", &port))
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg,
+ service_name,
+ "PORT",
+ &port))
{
LOG (GNUNET_ERROR_TYPE_ERROR,
- _("Require valid port number for service `%s' in configuration!\n"),
+ _ ("Require valid port number for service `%s' in configuration!\n"),
service_name);
}
if (port > 65535)
{
LOG (GNUNET_ERROR_TYPE_ERROR,
- _("Require valid port number for service `%s' in configuration!\n"),
+ _ ("Require valid port number for service `%s' in configuration!\n"),
service_name);
return GNUNET_SYSERR;
}
@@ -588,8 +605,10 @@ LEGACY_SERVICE_get_server_addresses (const char *service_name,
if (GNUNET_CONFIGURATION_have_value (cfg, service_name, "BINDTO"))
{
GNUNET_break (GNUNET_OK ==
- GNUNET_CONFIGURATION_get_value_string (cfg, service_name,
- "BINDTO", &hostname));
+ GNUNET_CONFIGURATION_get_value_string (cfg,
+ service_name,
+ "BINDTO",
+ &hostname));
}
else
hostname = NULL;
@@ -599,9 +618,10 @@ LEGACY_SERVICE_get_server_addresses (const char *service_name,
#ifdef AF_UNIX
if ((GNUNET_YES ==
GNUNET_CONFIGURATION_have_value (cfg, service_name, "UNIXPATH")) &&
- (GNUNET_OK ==
- GNUNET_CONFIGURATION_get_value_filename (cfg, service_name, "UNIXPATH",
- &unixpath)) &&
+ (GNUNET_OK == GNUNET_CONFIGURATION_get_value_filename (cfg,
+ service_name,
+ "UNIXPATH",
+ &unixpath)) &&
(0 < strlen (unixpath)))
{
/* probe UNIX support */
@@ -610,12 +630,11 @@ LEGACY_SERVICE_get_server_addresses (const char *service_name,
if (strlen (unixpath) >= sizeof (s_un.sun_path))
{
LOG (GNUNET_ERROR_TYPE_WARNING,
- _("UNIXPATH `%s' too long, maximum length is %llu\n"), unixpath,
+ _ ("UNIXPATH `%s' too long, maximum length is %llu\n"),
+ unixpath,
(unsigned long long) sizeof (s_un.sun_path));
unixpath = GNUNET_NETWORK_shorten_unixpath (unixpath);
- LOG (GNUNET_ERROR_TYPE_INFO,
- _("Using `%s' instead\n"),
- unixpath);
+ LOG (GNUNET_ERROR_TYPE_INFO, _ ("Using `%s' instead\n"), unixpath);
}
#ifdef LINUX
abstract = GNUNET_CONFIGURATION_get_value_yesno (cfg,
@@ -624,12 +643,9 @@ LEGACY_SERVICE_get_server_addresses (const char *service_name,
if (GNUNET_SYSERR == abstract)
abstract = GNUNET_NO;
#endif
- if ((GNUNET_YES != abstract)
- && (GNUNET_OK !=
- GNUNET_DISK_directory_create_for_file (unixpath)))
- GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
- "mkdir",
- unixpath);
+ if ((GNUNET_YES != abstract) &&
+ (GNUNET_OK != GNUNET_DISK_directory_create_for_file (unixpath)))
+ GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "mkdir", unixpath);
}
if (NULL != unixpath)
{
@@ -645,9 +661,10 @@ LEGACY_SERVICE_get_server_addresses (const char *service_name,
return GNUNET_SYSERR;
}
LOG (GNUNET_ERROR_TYPE_INFO,
- _("Disabling UNIX domain socket support for service `%s', failed to create UNIX domain socket: %s\n"),
+ _ (
+ "Disabling UNIX domain socket support for service `%s', failed to create UNIX domain socket: %s\n"),
service_name,
- STRERROR (errno));
+ strerror (errno));
GNUNET_free (unixpath);
unixpath = NULL;
}
@@ -662,7 +679,8 @@ LEGACY_SERVICE_get_server_addresses (const char *service_name,
if ((0 == port) && (NULL == unixpath))
{
LOG (GNUNET_ERROR_TYPE_ERROR,
- _("Have neither PORT nor UNIXPATH for service `%s', but one is required\n"),
+ _ (
+ "Have neither PORT nor UNIXPATH for service `%s', but one is required\n"),
service_name);
GNUNET_free_non_null (hostname);
return GNUNET_SYSERR;
@@ -693,7 +711,7 @@ LEGACY_SERVICE_get_server_addresses (const char *service_name,
(NULL == res))
{
LOG (GNUNET_ERROR_TYPE_ERROR,
- _("Failed to resolve `%s': %s\n"),
+ _ ("Failed to resolve `%s': %s\n"),
hostname,
gai_strerror (ret));
GNUNET_free (hostname);
@@ -712,7 +730,7 @@ LEGACY_SERVICE_get_server_addresses (const char *service_name,
if (0 == i)
{
LOG (GNUNET_ERROR_TYPE_ERROR,
- _("Failed to find %saddress for `%s'.\n"),
+ _ ("Failed to find %saddress for `%s'.\n"),
disablev6 ? "IPv4 " : "",
hostname);
freeaddrinfo (res);
@@ -738,11 +756,13 @@ LEGACY_SERVICE_get_server_addresses (const char *service_name,
if ((disablev6) && (AF_INET6 == pos->ai_family))
continue;
if ((IPPROTO_TCP != pos->ai_protocol) && (0 != pos->ai_protocol))
- continue; /* not TCP */
+ continue; /* not TCP */
if ((SOCK_STREAM != pos->ai_socktype) && (0 != pos->ai_socktype))
- continue; /* huh? */
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Service `%s' will bind to `%s'\n",
- service_name, GNUNET_a2s (pos->ai_addr, pos->ai_addrlen));
+ continue; /* huh? */
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Service `%s' will bind to `%s'\n",
+ service_name,
+ GNUNET_a2s (pos->ai_addr, pos->ai_addrlen));
if (AF_INET == pos->ai_family)
{
GNUNET_assert (sizeof (struct sockaddr_in) == pos->ai_addrlen);
@@ -854,7 +874,7 @@ receive_sockets_from_parent (struct LEGACY_SERVICE_Context *sctx)
* to create a GNUnet API that boxes a HANDLE (the way it is done with socks)
*/
lsocks_pipe = (HANDLE) strtoul (env_buf, NULL, 10);
- if ( (0 == lsocks_pipe) || (INVALID_HANDLE_VALUE == lsocks_pipe))
+ if ((0 == lsocks_pipe) || (INVALID_HANDLE_VALUE == lsocks_pipe))
return GNUNET_NO;
fail = 1;
do
@@ -867,7 +887,7 @@ receive_sockets_from_parent (struct LEGACY_SERVICE_Context *sctx)
if ((0 == ret) || (sizeof (count) != rd) || (0 == count))
break;
sctx->lsocks =
- GNUNET_malloc (sizeof (struct GNUNET_NETWORK_Handle *) * (count + 1));
+ GNUNET_malloc (sizeof (struct GNUNET_NETWORK_Handle *) * (count + 1));
fail2 = 1;
for (i = 0; i < count; i++)
@@ -877,12 +897,17 @@ receive_sockets_from_parent (struct LEGACY_SERVICE_Context *sctx)
SOCKET s;
ret = ReadFile (lsocks_pipe, &size, sizeof (size), &rd, NULL);
- if ( (0 == ret) || (sizeof (size) != rd) || (sizeof (pi) != size) )
+ if ((0 == ret) || (sizeof (size) != rd) || (sizeof (pi) != size))
break;
ret = ReadFile (lsocks_pipe, &pi, sizeof (pi), &rd, NULL);
- if ( (0 == ret) || (sizeof (pi) != rd))
+ if ((0 == ret) || (sizeof (pi) != rd))
break;
- s = WSASocketA (pi.iAddressFamily, pi.iSocketType, pi.iProtocol, &pi, 0, WSA_FLAG_OVERLAPPED);
+ s = WSASocketA (pi.iAddressFamily,
+ pi.iSocketType,
+ pi.iProtocol,
+ &pi,
+ 0,
+ WSA_FLAG_OVERLAPPED);
sctx->lsocks[i] = GNUNET_NETWORK_socket_box_native (s);
if (NULL == sctx->lsocks[i])
break;
@@ -893,15 +918,14 @@ receive_sockets_from_parent (struct LEGACY_SERVICE_Context *sctx)
break;
sctx->lsocks[count] = NULL;
fail = 0;
- }
- while (fail);
+ } while (fail);
CloseHandle (lsocks_pipe);
if (fail)
{
LOG (GNUNET_ERROR_TYPE_ERROR,
- _("Could not access a pre-bound socket, will try to bind myself\n"));
+ _ ("Could not access a pre-bound socket, will try to bind myself\n"));
for (i = 0; (i < count) && (NULL != sctx->lsocks[i]); i++)
GNUNET_break (0 == GNUNET_NETWORK_socket_close (sctx->lsocks[i]));
GNUNET_free_non_null (sctx->lsocks);
@@ -943,15 +967,19 @@ setup_service (struct LEGACY_SERVICE_Context *sctx)
int flags;
#endif
- if (GNUNET_CONFIGURATION_have_value (sctx->cfg, sctx->service_name, "TIMEOUT"))
+ if (GNUNET_CONFIGURATION_have_value (sctx->cfg,
+ sctx->service_name,
+ "TIMEOUT"))
{
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_time (sctx->cfg, sctx->service_name,
- "TIMEOUT", &idleout))
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time (sctx->cfg,
+ sctx->service_name,
+ "TIMEOUT",
+ &idleout))
{
LOG (GNUNET_ERROR_TYPE_ERROR,
- _("Specified value for `%s' of service `%s' is invalid\n"),
- "TIMEOUT", sctx->service_name);
+ _ ("Specified value for `%s' of service `%s' is invalid\n"),
+ "TIMEOUT",
+ sctx->service_name);
return GNUNET_SYSERR;
}
sctx->timeout = idleout;
@@ -959,17 +987,19 @@ setup_service (struct LEGACY_SERVICE_Context *sctx)
else
sctx->timeout = GNUNET_TIME_UNIT_FOREVER_REL;
- if (GNUNET_CONFIGURATION_have_value
- (sctx->cfg, sctx->service_name, "TOLERANT"))
+ if (GNUNET_CONFIGURATION_have_value (sctx->cfg,
+ sctx->service_name,
+ "TOLERANT"))
{
if (GNUNET_SYSERR ==
- (tolerant =
- GNUNET_CONFIGURATION_get_value_yesno (sctx->cfg, sctx->service_name,
- "TOLERANT")))
+ (tolerant = GNUNET_CONFIGURATION_get_value_yesno (sctx->cfg,
+ sctx->service_name,
+ "TOLERANT")))
{
LOG (GNUNET_ERROR_TYPE_ERROR,
- _("Specified value for `%s' of service `%s' is invalid\n"),
- "TOLERANT", sctx->service_name);
+ _ ("Specified value for `%s' of service `%s' is invalid\n"),
+ "TOLERANT",
+ sctx->service_name);
return GNUNET_SYSERR;
}
}
@@ -979,11 +1009,11 @@ setup_service (struct LEGACY_SERVICE_Context *sctx)
#ifndef MINGW
errno = 0;
if ((NULL != (nfds = getenv ("LISTEN_FDS"))) &&
- (1 == SSCANF (nfds, "%u", &cnt)) && (cnt > 0) && (cnt < FD_SETSIZE) &&
+ (1 == sscanf (nfds, "%u", &cnt)) && (cnt > 0) && (cnt < FD_SETSIZE) &&
(cnt + 4 < FD_SETSIZE))
{
sctx->lsocks =
- GNUNET_malloc (sizeof (struct GNUNET_NETWORK_Handle *) * (cnt + 1));
+ GNUNET_malloc (sizeof (struct GNUNET_NETWORK_Handle *) * (cnt + 1));
while (0 < cnt--)
{
flags = fcntl (3 + cnt, F_GETFD);
@@ -992,8 +1022,8 @@ setup_service (struct LEGACY_SERVICE_Context *sctx)
(sctx->lsocks[cnt] = GNUNET_NETWORK_socket_box_native (3 + cnt))))
{
LOG (GNUNET_ERROR_TYPE_ERROR,
- _
- ("Could not access pre-bound socket %u, will try to bind myself\n"),
+ _ (
+ "Could not access pre-bound socket %u, will try to bind myself\n"),
(unsigned int) 3 + cnt);
cnt++;
while (sctx->lsocks[cnt] != NULL)
@@ -1014,17 +1044,18 @@ setup_service (struct LEGACY_SERVICE_Context *sctx)
#endif
if ((NULL == sctx->lsocks) &&
- (GNUNET_SYSERR ==
- LEGACY_SERVICE_get_server_addresses (sctx->service_name, sctx->cfg,
- &sctx->addrs, &sctx->addrlens)))
+ (GNUNET_SYSERR == LEGACY_SERVICE_get_server_addresses (sctx->service_name,
+ sctx->cfg,
+ &sctx->addrs,
+ &sctx->addrlens)))
return GNUNET_SYSERR;
sctx->require_found = tolerant ? GNUNET_NO : GNUNET_YES;
- sctx->match_uid =
- GNUNET_CONFIGURATION_get_value_yesno (sctx->cfg, sctx->service_name,
- "UNIX_MATCH_UID");
- sctx->match_gid =
- GNUNET_CONFIGURATION_get_value_yesno (sctx->cfg, sctx->service_name,
- "UNIX_MATCH_GID");
+ sctx->match_uid = GNUNET_CONFIGURATION_get_value_yesno (sctx->cfg,
+ sctx->service_name,
+ "UNIX_MATCH_UID");
+ sctx->match_gid = GNUNET_CONFIGURATION_get_value_yesno (sctx->cfg,
+ sctx->service_name,
+ "UNIX_MATCH_GID");
process_acl4 (&sctx->v4_denied, sctx, "REJECT_FROM");
process_acl4 (&sctx->v4_allowed, sctx, "ACCEPT_FROM");
process_acl6 (&sctx->v6_denied, sctx, "REJECT_FROM6");
@@ -1046,9 +1077,10 @@ get_user_name (struct LEGACY_SERVICE_Context *sctx)
{
char *un;
- if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_filename (sctx->cfg, sctx->service_name,
- "USERNAME", &un))
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (sctx->cfg,
+ sctx->service_name,
+ "USERNAME",
+ &un))
return NULL;
return un;
}
@@ -1071,14 +1103,14 @@ write_pid_file (struct LEGACY_SERVICE_Context *sctx, pid_t pid)
int len;
if (NULL == (pif = get_pid_file_name (sctx)))
- return GNUNET_OK; /* no file desired */
+ return GNUNET_OK; /* no file desired */
user = get_user_name (sctx);
rdir = GNUNET_strdup (pif);
len = strlen (rdir);
while ((len > 0) && (rdir[len] != DIR_SEPARATOR))
len--;
rdir[len] = '\0';
- if (0 != ACCESS (rdir, F_OK))
+ if (0 != access (rdir, F_OK))
{
/* we get to create a directory -- and claim it
* as ours! */
@@ -1086,7 +1118,7 @@ write_pid_file (struct LEGACY_SERVICE_Context *sctx, pid_t pid)
if ((NULL != user) && (0 < strlen (user)))
GNUNET_DISK_file_change_owner (rdir, user);
}
- if (0 != ACCESS (rdir, W_OK | X_OK))
+ if (0 != access (rdir, W_OK | X_OK))
{
LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "access", rdir);
GNUNET_free (rdir);
@@ -1095,7 +1127,7 @@ write_pid_file (struct LEGACY_SERVICE_Context *sctx, pid_t pid)
return GNUNET_SYSERR;
}
GNUNET_free (rdir);
- pidfd = FOPEN (pif, "w");
+ pidfd = fopen (pif, "w");
if (NULL == pidfd)
{
LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "fopen", pif);
@@ -1103,9 +1135,9 @@ write_pid_file (struct LEGACY_SERVICE_Context *sctx, pid_t pid)
GNUNET_free_non_null (user);
return GNUNET_SYSERR;
}
- if (0 > FPRINTF (pidfd, "%u", pid))
+ if (0 > fprintf (pidfd, "%u", pid))
LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "fprintf", pif);
- GNUNET_break (0 == FCLOSE (pidfd));
+ GNUNET_break (0 == fclose (pidfd));
if ((NULL != user) && (0 < strlen (user)))
GNUNET_DISK_file_change_owner (pif, user);
GNUNET_free_non_null (user);
@@ -1146,29 +1178,37 @@ service_task (void *cls)
GNUNET_RESOLVER_connect (sctx->cfg);
if (NULL != sctx->lsocks)
- sctx->server
- = GNUNET_SERVER_create_with_sockets (&check_access, sctx, sctx->lsocks,
- sctx->timeout, sctx->require_found);
+ sctx->server = GNUNET_SERVER_create_with_sockets (&check_access,
+ sctx,
+ sctx->lsocks,
+ sctx->timeout,
+ sctx->require_found);
else
- sctx->server
- = GNUNET_SERVER_create (&check_access, sctx, sctx->addrs, sctx->addrlens,
- sctx->timeout, sctx->require_found);
+ sctx->server = GNUNET_SERVER_create (&check_access,
+ sctx,
+ sctx->addrs,
+ sctx->addrlens,
+ sctx->timeout,
+ sctx->require_found);
if (NULL == sctx->server)
{
if (NULL != sctx->addrs)
for (i = 0; NULL != sctx->addrs[i]; i++)
LOG (GNUNET_ERROR_TYPE_INFO,
- _("Failed to start `%s' at `%s'\n"),
- sctx->service_name, GNUNET_a2s (sctx->addrs[i], sctx->addrlens[i]));
+ _ ("Failed to start `%s' at `%s'\n"),
+ sctx->service_name,
+ GNUNET_a2s (sctx->addrs[i], sctx->addrlens[i]));
sctx->ret = GNUNET_SYSERR;
return;
}
#ifndef WINDOWS
if (NULL != sctx->addrs)
for (i = 0; NULL != sctx->addrs[i]; i++)
- if ((AF_UNIX == sctx->addrs[i]->sa_family)
- && ('\0' != ((const struct sockaddr_un *)sctx->addrs[i])->sun_path[0]))
- GNUNET_DISK_fix_permissions (((const struct sockaddr_un *)sctx->addrs[i])->sun_path,
+ if ((AF_UNIX == sctx->addrs[i]->sa_family) &&
+ ('\0' != ((const struct sockaddr_un *) sctx->addrs[i])->sun_path[0]))
+ GNUNET_DISK_fix_permissions (((const struct sockaddr_un *)
+ sctx->addrs[i])
+ ->sun_path,
sctx->match_uid,
sctx->match_gid);
#endif
@@ -1178,8 +1218,7 @@ service_task (void *cls)
{
/* install a task that will kill the server
* process if the scheduler ever gets a shutdown signal */
- sctx->shutdown_task = GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
- sctx);
+ sctx->shutdown_task = GNUNET_SCHEDULER_add_shutdown (&shutdown_task, sctx);
}
sctx->my_handlers = GNUNET_malloc (sizeof (defhandlers));
GNUNET_memcpy (sctx->my_handlers, defhandlers, sizeof (defhandlers));
@@ -1189,8 +1228,8 @@ service_task (void *cls)
GNUNET_SERVER_add_handlers (sctx->server, sctx->my_handlers);
if (-1 != sctx->ready_confirm_fd)
{
- GNUNET_break (1 == WRITE (sctx->ready_confirm_fd, ".", 1));
- GNUNET_break (0 == CLOSE (sctx->ready_confirm_fd));
+ GNUNET_break (1 == write (sctx->ready_confirm_fd, ".", 1));
+ GNUNET_break (0 == close (sctx->ready_confirm_fd));
sctx->ready_confirm_fd = -1;
write_pid_file (sctx, getpid ());
}
@@ -1199,8 +1238,10 @@ service_task (void *cls)
i = 0;
while (NULL != sctx->addrs[i])
{
- LOG (GNUNET_ERROR_TYPE_INFO, _("Service `%s' runs at %s\n"),
- sctx->service_name, GNUNET_a2s (sctx->addrs[i], sctx->addrlens[i]));
+ LOG (GNUNET_ERROR_TYPE_INFO,
+ _ ("Service `%s' runs at %s\n"),
+ sctx->service_name,
+ GNUNET_a2s (sctx->addrs[i], sctx->addrlens[i]));
i++;
}
}
@@ -1222,7 +1263,7 @@ detach_terminal (struct LEGACY_SERVICE_Context *sctx)
int nullfd;
int filedes[2];
- if (0 != PIPE (filedes))
+ if (0 != pipe (filedes))
{
LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "pipe");
return GNUNET_SYSERR;
@@ -1238,9 +1279,9 @@ detach_terminal (struct LEGACY_SERVICE_Context *sctx)
/* Parent */
char c;
- GNUNET_break (0 == CLOSE (filedes[1]));
+ GNUNET_break (0 == close (filedes[1]));
c = 'X';
- if (1 != READ (filedes[0], &c, sizeof (char)))
+ if (1 != read (filedes[0], &c, sizeof (char)))
LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, "read");
fflush (stdout);
switch (c)
@@ -1248,33 +1289,34 @@ detach_terminal (struct LEGACY_SERVICE_Context *sctx)
case '.':
exit (0);
case 'I':
- LOG (GNUNET_ERROR_TYPE_INFO, _("Service process failed to initialize\n"));
+ LOG (GNUNET_ERROR_TYPE_INFO,
+ _ ("Service process failed to initialize\n"));
break;
case 'S':
LOG (GNUNET_ERROR_TYPE_INFO,
- _("Service process could not initialize server function\n"));
+ _ ("Service process could not initialize server function\n"));
break;
case 'X':
LOG (GNUNET_ERROR_TYPE_INFO,
- _("Service process failed to report status\n"));
+ _ ("Service process failed to report status\n"));
break;
}
- exit (1); /* child reported error */
+ exit (1); /* child reported error */
}
- GNUNET_break (0 == CLOSE (0));
- GNUNET_break (0 == CLOSE (1));
- GNUNET_break (0 == CLOSE (filedes[0]));
- nullfd = OPEN ("/dev/null", O_RDWR | O_APPEND);
+ GNUNET_break (0 == close (0));
+ GNUNET_break (0 == close (1));
+ GNUNET_break (0 == close (filedes[0]));
+ nullfd = open ("/dev/null", O_RDWR | O_APPEND);
if (nullfd < 0)
return GNUNET_SYSERR;
/* set stdin/stdout to /dev/null */
if ((dup2 (nullfd, 0) < 0) || (dup2 (nullfd, 1) < 0))
{
LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "dup2");
- (void) CLOSE (nullfd);
+ (void) close (nullfd);
return GNUNET_SYSERR;
}
- (void) CLOSE (nullfd);
+ (void) close (nullfd);
/* Detach from controlling terminal */
pid = setsid ();
if (-1 == pid)
@@ -1301,7 +1343,7 @@ set_user_id (struct LEGACY_SERVICE_Context *sctx)
char *user;
if (NULL == (user = get_user_name (sctx)))
- return GNUNET_OK; /* keep */
+ return GNUNET_OK; /* keep */
#ifndef MINGW
struct passwd *pws;
@@ -1310,8 +1352,9 @@ set_user_id (struct LEGACY_SERVICE_Context *sctx)
if (NULL == pws)
{
LOG (GNUNET_ERROR_TYPE_ERROR,
- _("Cannot obtain information about user `%s': %s\n"), user,
- errno == 0 ? _("No such user") : STRERROR (errno));
+ _ ("Cannot obtain information about user `%s': %s\n"),
+ user,
+ errno == 0 ? _ ("No such user") : strerror (errno));
GNUNET_free (user);
return GNUNET_SYSERR;
}
@@ -1324,8 +1367,10 @@ set_user_id (struct LEGACY_SERVICE_Context *sctx)
if ((0 != setregid (pws->pw_gid, pws->pw_gid)) ||
(0 != setreuid (pws->pw_uid, pws->pw_uid)))
{
- LOG (GNUNET_ERROR_TYPE_ERROR, _("Cannot change user/group to `%s': %s\n"),
- user, STRERROR (errno));
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ _ ("Cannot change user/group to `%s': %s\n"),
+ user,
+ strerror (errno));
GNUNET_free (user);
return GNUNET_SYSERR;
}
@@ -1347,8 +1392,8 @@ pid_file_delete (struct LEGACY_SERVICE_Context *sctx)
char *pif = get_pid_file_name (sctx);
if (NULL == pif)
- return; /* no PID file */
- if (0 != UNLINK (pif))
+ return; /* no PID file */
+ if (0 != unlink (pif))
LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "unlink", pif);
GNUNET_free (pif);
}
@@ -1368,13 +1413,19 @@ pid_file_delete (struct LEGACY_SERVICE_Context *sctx)
* if we shutdown nicely
*/
int
-LEGACY_SERVICE_run (int argc, char *const *argv,
+LEGACY_SERVICE_run (int argc,
+ char *const *argv,
const char *service_name,
enum LEGACY_SERVICE_Options options,
LEGACY_SERVICE_Main task,
void *task_cls)
{
-#define HANDLE_ERROR do { GNUNET_break (0); goto shutdown; } while (0)
+#define HANDLE_ERROR \
+ do \
+ { \
+ GNUNET_break (0); \
+ goto shutdown; \
+ } while (0)
int err;
int ret;
@@ -1391,18 +1442,18 @@ LEGACY_SERVICE_run (int argc, char *const *argv,
struct GNUNET_CONFIGURATION_Handle *cfg;
const char *xdg;
- struct GNUNET_GETOPT_CommandLineOption service_options[] = {
- GNUNET_GETOPT_option_cfgfile (&opt_cfg_fn),
- GNUNET_GETOPT_option_flag ('d',
- "daemonize",
- gettext_noop ("do daemonize (detach from terminal)"),
- &do_daemonize),
- GNUNET_GETOPT_option_help (NULL),
- GNUNET_GETOPT_option_loglevel (&loglev),
- GNUNET_GETOPT_option_logfile (&logfile),
- GNUNET_GETOPT_option_version (PACKAGE_VERSION " " VCS_VERSION),
- GNUNET_GETOPT_OPTION_END
- };
+ struct GNUNET_GETOPT_CommandLineOption service_options[] =
+ {GNUNET_GETOPT_option_cfgfile (&opt_cfg_fn),
+ GNUNET_GETOPT_option_flag ('d',
+ "daemonize",
+ gettext_noop (
+ "do daemonize (detach from terminal)"),
+ &do_daemonize),
+ GNUNET_GETOPT_option_help (NULL),
+ GNUNET_GETOPT_option_loglevel (&loglev),
+ GNUNET_GETOPT_option_logfile (&logfile),
+ GNUNET_GETOPT_option_version (PACKAGE_VERSION " " VCS_VERSION),
+ GNUNET_GETOPT_OPTION_END};
err = 1;
do_daemonize = 0;
logfile = NULL;
@@ -1445,7 +1496,7 @@ LEGACY_SERVICE_run (int argc, char *const *argv,
if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, opt_cfg_fn))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("Malformed configuration file `%s', exit ...\n"),
+ _ ("Malformed configuration file `%s', exit ...\n"),
opt_cfg_fn);
goto shutdown;
}
@@ -1455,13 +1506,13 @@ LEGACY_SERVICE_run (int argc, char *const *argv,
if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, NULL))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("Malformed configuration, exit ...\n"));
+ _ ("Malformed configuration, exit ...\n"));
goto shutdown;
}
if (0 != strcmp (opt_cfg_fn, cfg_fn))
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("Could not access configuration file `%s'\n"),
- opt_cfg_fn);
+ _ ("Could not access configuration file `%s'\n"),
+ opt_cfg_fn);
}
if (GNUNET_OK != setup_service (&sctx))
goto shutdown;
@@ -1473,12 +1524,14 @@ LEGACY_SERVICE_run (int argc, char *const *argv,
"Service `%s' runs with configuration from `%s'\n",
service_name,
opt_cfg_fn);
- if ((GNUNET_OK ==
- GNUNET_CONFIGURATION_get_value_number (sctx.cfg, "TESTING",
- "SKEW_OFFSET", &skew_offset)) &&
- (GNUNET_OK ==
- GNUNET_CONFIGURATION_get_value_number (sctx.cfg, "TESTING",
- "SKEW_VARIANCE", &skew_variance)))
+ if ((GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (sctx.cfg,
+ "TESTING",
+ "SKEW_OFFSET",
+ &skew_offset)) &&
+ (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (sctx.cfg,
+ "TESTING",
+ "SKEW_VARIANCE",
+ &skew_variance)))
{
clock_offset = skew_offset - skew_variance;
GNUNET_TIME_set_offset (clock_offset);
@@ -1495,21 +1548,21 @@ LEGACY_SERVICE_run (int argc, char *const *argv,
shutdown:
if (-1 != sctx.ready_confirm_fd)
{
- if (1 != WRITE (sctx.ready_confirm_fd, err ? "I" : "S", 1))
+ if (1 != write (sctx.ready_confirm_fd, err ? "I" : "S", 1))
LOG_STRERROR (GNUNET_ERROR_TYPE_WARNING, "write");
- GNUNET_break (0 == CLOSE (sctx.ready_confirm_fd));
+ GNUNET_break (0 == close (sctx.ready_confirm_fd));
}
#if HAVE_MALLINFO
{
char *counter;
- if ( (GNUNET_YES ==
- GNUNET_CONFIGURATION_have_value (sctx.cfg, service_name,
- "GAUGER_HEAP")) &&
- (GNUNET_OK ==
- GNUNET_CONFIGURATION_get_value_string (sctx.cfg, service_name,
- "GAUGER_HEAP",
- &counter)) )
+ if ((GNUNET_YES == GNUNET_CONFIGURATION_have_value (sctx.cfg,
+ service_name,
+ "GAUGER_HEAP")) &&
+ (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (sctx.cfg,
+ service_name,
+ "GAUGER_HEAP",
+ &counter)))
{
struct mallinfo mi;
@@ -1551,13 +1604,13 @@ shutdown:
struct LEGACY_SERVICE_Context *
LEGACY_SERVICE_start (const char *service_name,
const struct GNUNET_CONFIGURATION_Handle *cfg,
- enum LEGACY_SERVICE_Options options)
+ enum LEGACY_SERVICE_Options options)
{
int i;
struct LEGACY_SERVICE_Context *sctx;
sctx = GNUNET_new (struct LEGACY_SERVICE_Context);
- sctx->ready_confirm_fd = -1; /* no daemonizing */
+ sctx->ready_confirm_fd = -1; /* no daemonizing */
sctx->ret = GNUNET_OK;
sctx->timeout = GNUNET_TIME_UNIT_FOREVER_REL;
sctx->service_name = service_name;
@@ -1571,13 +1624,18 @@ LEGACY_SERVICE_start (const char *service_name,
return NULL;
}
if (NULL != sctx->lsocks)
- sctx->server =
- GNUNET_SERVER_create_with_sockets (&check_access, sctx, sctx->lsocks,
- sctx->timeout, sctx->require_found);
+ sctx->server = GNUNET_SERVER_create_with_sockets (&check_access,
+ sctx,
+ sctx->lsocks,
+ sctx->timeout,
+ sctx->require_found);
else
- sctx->server =
- GNUNET_SERVER_create (&check_access, sctx, sctx->addrs, sctx->addrlens,
- sctx->timeout, sctx->require_found);
+ sctx->server = GNUNET_SERVER_create (&check_access,
+ sctx,
+ sctx->addrs,
+ sctx->addrlens,
+ sctx->timeout,
+ sctx->require_found);
if (NULL == sctx->server)
{
@@ -1587,9 +1645,11 @@ LEGACY_SERVICE_start (const char *service_name,
#ifndef WINDOWS
if (NULL != sctx->addrs)
for (i = 0; NULL != sctx->addrs[i]; i++)
- if ((AF_UNIX == sctx->addrs[i]->sa_family)
- && ('\0' != ((const struct sockaddr_un *)sctx->addrs[i])->sun_path[0]))
- GNUNET_DISK_fix_permissions (((const struct sockaddr_un *)sctx->addrs[i])->sun_path,
+ if ((AF_UNIX == sctx->addrs[i]->sa_family) &&
+ ('\0' != ((const struct sockaddr_un *) sctx->addrs[i])->sun_path[0]))
+ GNUNET_DISK_fix_permissions (((const struct sockaddr_un *)
+ sctx->addrs[i])
+ ->sun_path,
sctx->match_uid,
sctx->match_gid);
#endif
@@ -1624,7 +1684,7 @@ LEGACY_SERVICE_get_server (struct LEGACY_SERVICE_Context *ctx)
* @return NULL if there are no listen sockets, otherwise NULL-terminated
* array of listen sockets.
*/
-struct GNUNET_NETWORK_Handle *const*
+struct GNUNET_NETWORK_Handle *const *
LEGACY_SERVICE_get_listen_sockets (struct LEGACY_SERVICE_Context *ctx)
{
return ctx->lsocks;
@@ -1645,13 +1705,13 @@ LEGACY_SERVICE_stop (struct LEGACY_SERVICE_Context *sctx)
{
char *counter;
- if ( (GNUNET_YES ==
- GNUNET_CONFIGURATION_have_value (sctx->cfg, sctx->service_name,
- "GAUGER_HEAP")) &&
- (GNUNET_OK ==
- GNUNET_CONFIGURATION_get_value_string (sctx->cfg, sctx->service_name,
- "GAUGER_HEAP",
- &counter)) )
+ if ((GNUNET_YES == GNUNET_CONFIGURATION_have_value (sctx->cfg,
+ sctx->service_name,
+ "GAUGER_HEAP")) &&
+ (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (sctx->cfg,
+ sctx->service_name,
+ "GAUGER_HEAP",
+ &counter)))
{
struct mallinfo mi;
diff --git a/src/transport/test_plugin_hostkey b/src/transport/test_plugin_hostkey
index 13f1dc9b3..e7b1ad012 100644
--- a/src/transport/test_plugin_hostkey
+++ b/src/transport/test_plugin_hostkey
Binary files differ
diff --git a/src/transport/test_quota_compliance.c b/src/transport/test_quota_compliance.c
index 0c94fa5c9..2c6ce8e5f 100644
--- a/src/transport/test_quota_compliance.c
+++ b/src/transport/test_quota_compliance.c
@@ -71,7 +71,7 @@ report ()
delta = 1;
datarate = (total_bytes_recv * 1000 * 1000) / delta;
- FPRINTF (stderr,
+ fprintf (stderr,
"Throughput was %llu b/s\n",
datarate);
ccc->global_ret = GNUNET_OK;
@@ -160,11 +160,11 @@ measure (void *cls)
counter++;
if ((DURATION.rel_value_us / 1000 / 1000LL) < counter)
{
- FPRINTF (stderr, "%s", ".\n");
+ fprintf (stderr, "%s", ".\n");
GNUNET_SCHEDULER_shutdown ();
return;
}
- FPRINTF (stderr, "%s", ".");
+ fprintf (stderr, "%s", ".");
measure_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
&measure,
NULL);
diff --git a/src/transport/test_transport_address_switch.c b/src/transport/test_transport_address_switch.c
index 98f1170ff..4cc63766e 100644
--- a/src/transport/test_transport_address_switch.c
+++ b/src/transport/test_transport_address_switch.c
@@ -217,10 +217,10 @@ custom_shutdown (void *cls)
}
result = 0;
- FPRINTF (stderr, "\n");
+ fprintf (stderr, "\n");
if (stats[0].switch_attempts > 0)
{
- FPRINTF (
+ fprintf (
stderr,
"Peer 1 tried %u times to switch and succeeded %u times, failed %u times\n",
stats[0].switch_attempts,
@@ -234,13 +234,13 @@ custom_shutdown (void *cls)
}
else if (stats[0].addresses_avail > 1)
{
- FPRINTF (stderr,
+ fprintf (stderr,
"Peer 1 had %u addresses available, but did not try to switch\n",
stats[0].addresses_avail);
}
if (stats[1].switch_attempts > 0)
{
- FPRINTF (
+ fprintf (
stderr,
"Peer 2 tried %u times to switch and succeeded %u times, failed %u times\n",
stats[1].switch_attempts,
@@ -254,7 +254,7 @@ custom_shutdown (void *cls)
}
else if (stats[1].addresses_avail > 1)
{
- FPRINTF (stderr,
+ fprintf (stderr,
"Peer 2 had %u addresses available, but did not try to switch\n",
stats[1].addresses_avail);
}
@@ -262,14 +262,14 @@ custom_shutdown (void *cls)
if (((stats[0].switch_attempts > 0) || (stats[1].switch_attempts > 0)) &&
(bytes_sent_after_switch == 0))
{
- FPRINTF (stderr, "No data sent after switching!\n");
+ fprintf (stderr, "No data sent after switching!\n");
GNUNET_break (0);
result++;
}
if (((stats[0].switch_attempts > 0) || (stats[1].switch_attempts > 0)) &&
(bytes_recv_after_switch == 0))
{
- FPRINTF (stderr, "No data received after switching!\n");
+ fprintf (stderr, "No data received after switching!\n");
GNUNET_break (0);
result++;
}
@@ -353,11 +353,11 @@ progress_indicator (void *cls)
counter++;
if ((TIMEOUT.rel_value_us / 1000 / 1000LL) < counter)
{
- FPRINTF (stderr, "%s", ".\n");
+ fprintf (stderr, "%s", ".\n");
}
else
{
- FPRINTF (stderr, "%s", ".");
+ fprintf (stderr, "%s", ".");
measure_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
&progress_indicator,
NULL);
diff --git a/src/transport/test_transport_api_reliability.c b/src/transport/test_transport_api_reliability.c
index 8442b92e8..a26a92880 100644
--- a/src/transport/test_transport_api_reliability.c
+++ b/src/transport/test_transport_api_reliability.c
@@ -179,7 +179,7 @@ custom_shutdown (void *cls)
if (0 == delta)
delta = 1;
rate = (1000LL* 1000ll * total_bytes) / (1024 * delta);
- FPRINTF (stderr,
+ fprintf (stderr,
"\nThroughput was %llu KiBytes/s\n",
rate);
{
@@ -274,7 +274,7 @@ notify_receive (void *cls,
}
if (0 == (n % (TOTAL_MSGS / xhdr / 100)))
{
- FPRINTF (stderr, "%s", ".");
+ fprintf (stderr, "%s", ".");
}
if (n == TOTAL_MSGS / xhdr)
{
diff --git a/src/transport/test_transport_api_timeout.c b/src/transport/test_transport_api_timeout.c
index a00e0aeb6..f562dd196 100644
--- a/src/transport/test_transport_api_timeout.c
+++ b/src/transport/test_transport_api_timeout.c
@@ -120,13 +120,13 @@ timer (void *cls)
if (time_running.rel_value_us ==
GNUNET_TIME_relative_max (time_running, WAIT).rel_value_us)
{
- FPRINTF (stderr, "%s", "100%%\n");
+ fprintf (stderr, "%s", "100%%\n");
shutdown_flag = GNUNET_YES;
GNUNET_SCHEDULER_shutdown ();
}
else
{
- FPRINTF (stderr,
+ fprintf (stderr,
"%u%%..",
percentage);
timer_task =
diff --git a/src/transport/test_transport_blacklisting.c b/src/transport/test_transport_blacklisting.c
index 1cd244115..0ecd6fda1 100644
--- a/src/transport/test_transport_blacklisting.c
+++ b/src/transport/test_transport_blacklisting.c
@@ -80,7 +80,7 @@ static struct GNUNET_SCHEDULER_Task * timeout_task;
static struct GNUNET_SCHEDULER_Task * stage_task;
#if VERBOSE
-#define OKPP do { ok++; FPRINTF (stderr, "Now at stage %u at %s:%u\n", ok, __FILE__, __LINE__); } while (0)
+#define OKPP do { ok++; fprintf (stderr, "Now at stage %u at %s:%u\n", ok, __FILE__, __LINE__); } while (0)
#else
#define OKPP do { ok++; } while (0)
#endif