summaryrefslogtreecommitdiff
path: root/src/transport/gnunet-helper-transport-wlan-dummy.c
diff options
context:
space:
mode:
authorng0 <ng0@n0.is>2019-09-06 23:01:06 +0000
committerng0 <ng0@n0.is>2019-09-06 23:01:06 +0000
commitd0051cb6683c712cce3473d6b667208e4f61b75a (patch)
tree99f642c0e8f8c888a2bb3daa5280325dd8707d6d /src/transport/gnunet-helper-transport-wlan-dummy.c
parent6e599264ad13e8fc105493d74d7c11d46f8739ed (diff)
plibc, commit 2
Diffstat (limited to 'src/transport/gnunet-helper-transport-wlan-dummy.c')
-rw-r--r--src/transport/gnunet-helper-transport-wlan-dummy.c128
1 files changed, 68 insertions, 60 deletions
diff --git a/src/transport/gnunet-helper-transport-wlan-dummy.c b/src/transport/gnunet-helper-transport-wlan-dummy.c
index c7ed1b903..0adf8f6a5 100644
--- a/src/transport/gnunet-helper-transport-wlan-dummy.c
+++ b/src/transport/gnunet-helper-transport-wlan-dummy.c
@@ -104,13 +104,14 @@ send_mac_to_plugin (char *buffer, struct GNUNET_TRANSPORT_WLAN_MacAddress *mac)
struct GNUNET_TRANSPORT_WLAN_HelperControlMessage macmsg;
GNUNET_memcpy (&macmsg.mac,
- (char *) mac,
- sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress));
- macmsg.hdr.size = htons (sizeof (struct GNUNET_TRANSPORT_WLAN_HelperControlMessage));
+ (char *) mac,
+ sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress));
+ macmsg.hdr.size =
+ htons (sizeof (struct GNUNET_TRANSPORT_WLAN_HelperControlMessage));
macmsg.hdr.type = htons (GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL);
GNUNET_memcpy (buffer,
- &macmsg,
- sizeof (struct GNUNET_TRANSPORT_WLAN_HelperControlMessage));
+ &macmsg,
+ sizeof (struct GNUNET_TRANSPORT_WLAN_HelperControlMessage));
return sizeof (struct GNUNET_TRANSPORT_WLAN_HelperControlMessage);
}
@@ -126,8 +127,7 @@ send_mac_to_plugin (char *buffer, struct GNUNET_TRANSPORT_WLAN_MacAddress *mac)
* #GNUNET_SYSERR to stop further processing with error
*/
static int
-stdin_send (void *cls,
- const struct GNUNET_MessageHeader *hdr)
+stdin_send (void *cls, const struct GNUNET_MessageHeader *hdr)
{
struct SendBuffer *write_pout = cls;
const struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *in;
@@ -137,16 +137,19 @@ stdin_send (void *cls,
sendsize = ntohs (hdr->size);
in = (const struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *) hdr;
- if ( (GNUNET_MESSAGE_TYPE_WLAN_DATA_TO_HELPER != ntohs (hdr->type)) ||
- (sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage) > sendsize) )
+ 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");
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)
+ 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));
@@ -154,12 +157,10 @@ stdin_send (void *cls,
newheader.header.type = htons (GNUNET_MESSAGE_TYPE_WLAN_DATA_FROM_HELPER);
newheader.frame = in->frame;
GNUNET_memcpy (write_pout->buf + write_pout->size,
- &newheader,
- sizeof (newheader));
+ &newheader,
+ sizeof (newheader));
write_pout->size += sizeof (newheader);
- GNUNET_memcpy (write_pout->buf + write_pout->size,
- &in[1],
- payload_size);
+ GNUNET_memcpy (write_pout->buf + write_pout->size, &in[1], payload_size);
write_pout->size += payload_size;
return GNUNET_OK;
}
@@ -175,8 +176,7 @@ stdin_send (void *cls,
* #GNUNET_SYSERR to stop further processing with error
*/
static int
-file_in_send (void *cls,
- const struct GNUNET_MessageHeader *hdr)
+file_in_send (void *cls, const struct GNUNET_MessageHeader *hdr)
{
struct SendBuffer *write_std = cls;
uint16_t sendsize;
@@ -224,45 +224,46 @@ main (int argc, char *argv[])
struct GNUNET_TRANSPORT_WLAN_MacAddress macaddr;
int first;
- if ( (2 != argc) ||
- ((0 != strcmp (argv[1], "1")) && (0 != strcmp (argv[1], "2"))) )
+ if ((2 != argc) ||
+ ((0 != strcmp (argv[1], "1")) && (0 != strcmp (argv[1], "2"))))
{
- fprintf (stderr,
- "%s",
- "This program must be started with the operating mode (1 or 2) as the only argument.\n");
+ fprintf (
+ stderr,
+ "%s",
+ "This program must be started with the operating mode (1 or 2) as the only argument.\n");
return 1;
}
/* make the fifos if needed */
umask (0);
- if ( (GNUNET_OK != GNUNET_DISK_directory_create_for_file (FIFO_FILE1)) ||
- (GNUNET_OK != GNUNET_DISK_directory_create_for_file (FIFO_FILE2)) )
+ if ((GNUNET_OK != GNUNET_DISK_directory_create_for_file (FIFO_FILE1)) ||
+ (GNUNET_OK != GNUNET_DISK_directory_create_for_file (FIFO_FILE2)))
{
- fprintf (stderr,
- "Failed to create directory for file `%s'\n",
- FIFO_FILE1);
+ fprintf (stderr, "Failed to create directory for file `%s'\n", FIFO_FILE1);
return 1;
}
- if (0 == strcmp (argv[1], "1") )
+ if (0 == strcmp (argv[1], "1"))
{
if (0 != stat (FIFO_FILE1, &st))
{
erg = mkfifo (FIFO_FILE1, 0666);
- if ( (0 != erg) && (EEXIST != errno) )
- fprintf (stderr, "Error in mkfifo(%s): %s\n", FIFO_FILE1,
- strerror (errno));
+ if ((0 != erg) && (EEXIST != errno))
+ fprintf (stderr,
+ "Error in mkfifo(%s): %s\n",
+ FIFO_FILE1,
+ strerror (errno));
}
}
else
{
if (0 != stat (FIFO_FILE2, &st))
{
- GNUNET_break (0 == (erg = mkfifo (FIFO_FILE2, 0666)));
- if ( (0 != erg) && (EEXIST != errno) )
- fprintf (stderr,
+ GNUNET_break (0 == (erg = mkfifo (FIFO_FILE2, 0666)));
+ if ((0 != erg) && (EEXIST != errno))
+ fprintf (stderr,
"Error in mkfifo(%s): %s\n",
FIFO_FILE2,
- strerror (errno));
+ strerror (errno));
}
}
@@ -274,7 +275,7 @@ main (int argc, char *argv[])
{
fprintf (stderr,
"fopen of read FIFO_FILE1 failed: %s\n",
- STRERROR (errno));
+ strerror (errno));
goto end;
}
if (NULL == (fpout = fopen (FIFO_FILE2, "w")))
@@ -286,7 +287,7 @@ main (int argc, char *argv[])
{
fprintf (stderr,
"fopen of write FIFO_FILE2 failed: %s\n",
- STRERROR (errno));
+ strerror (errno));
goto end;
}
}
@@ -295,14 +296,14 @@ main (int argc, char *argv[])
first = 0;
if (NULL == (fpout = fopen (FIFO_FILE1, "w")))
{
- GNUNET_break (0 == mkfifo (FIFO_FILE1, 0666));
+ GNUNET_break (0 == mkfifo (FIFO_FILE1, 0666));
fpout = fopen (FIFO_FILE1, "w");
}
if (NULL == fpout)
{
fprintf (stderr,
"fopen of write FIFO_FILE1 failed: %s\n",
- STRERROR (errno));
+ strerror (errno));
goto end;
}
fpin = fopen (FIFO_FILE2, "r");
@@ -310,7 +311,7 @@ main (int argc, char *argv[])
{
fprintf (stderr,
"fopen of read FIFO_FILE2 failed: %s\n",
- STRERROR (errno));
+ strerror (errno));
goto end;
}
}
@@ -395,21 +396,22 @@ 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;
}
if (FD_ISSET (STDOUT_FILENO, &wfds))
{
- ret =
- write (STDOUT_FILENO, write_std.buf + write_std.pos,
- write_std.size - write_std.pos);
+ ret = write (STDOUT_FILENO,
+ write_std.buf + write_std.pos,
+ write_std.size - write_std.pos);
if (0 > ret)
{
closeprog = 1;
- fprintf (stderr, "Write ERROR to STDOUT_FILENO: %s\n",
- STRERROR (errno));
+ fprintf (stderr,
+ "Write ERROR to STDOUT_FILENO: %s\n",
+ strerror (errno));
break;
}
else
@@ -426,14 +428,16 @@ main (int argc, char *argv[])
if (FD_ISSET (fdpout, &wfds))
{
- ret =
- write (fdpout, write_pout.buf + write_pout.pos,
- write_pout.size - write_pout.pos);
+ ret = write (fdpout,
+ write_pout.buf + write_pout.pos,
+ write_pout.size - write_pout.pos);
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,15 +458,17 @@ main (int argc, char *argv[])
if (0 > readsize)
{
closeprog = 1;
- fprintf (stderr, "Error reading from STDIN_FILENO: %s\n",
- STRERROR (errno));
+ fprintf (stderr,
+ "Error reading from STDIN_FILENO: %s\n",
+ strerror (errno));
}
else if (0 < readsize)
{
GNUNET_MST_from_buffer (stdin_mst,
- readbuf, readsize,
- GNUNET_NO, GNUNET_NO);
-
+ readbuf,
+ readsize,
+ GNUNET_NO,
+ GNUNET_NO);
}
else
{
@@ -477,14 +483,16 @@ 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)
{
GNUNET_MST_from_buffer (file_in_mst,
- readbuf, readsize,
- GNUNET_NO, GNUNET_NO);
+ readbuf,
+ readsize,
+ GNUNET_NO,
+ GNUNET_NO);
}
else
{