diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-11-25 09:18:53 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-11-25 09:18:53 +0000 |
commit | bd4822b448a18c28b07754efff1d962630a0da31 (patch) | |
tree | acc3f6657d374038bee5aac68c731487925a6d1a /src/transport/gnunet-transport-wlan-helper-dummy.c | |
parent | a26f62fb03c3570f7792d3a94c177cb40ade9297 (diff) | |
download | gnunet-bd4822b448a18c28b07754efff1d962630a0da31.tar.gz gnunet-bd4822b448a18c28b07754efff1d962630a0da31.zip |
inlining files from wlan, preparing to obsolete wlan subdirectory
Diffstat (limited to 'src/transport/gnunet-transport-wlan-helper-dummy.c')
-rw-r--r-- | src/transport/gnunet-transport-wlan-helper-dummy.c | 59 |
1 files changed, 36 insertions, 23 deletions
diff --git a/src/transport/gnunet-transport-wlan-helper-dummy.c b/src/transport/gnunet-transport-wlan-helper-dummy.c index d4c300d25..6a884efc1 100644 --- a/src/transport/gnunet-transport-wlan-helper-dummy.c +++ b/src/transport/gnunet-transport-wlan-helper-dummy.c | |||
@@ -18,27 +18,10 @@ | |||
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @file transport/test_transport_wlan_dummy.c | 21 | * @file transport/gnunet-transport-wlan-helper-dummy.c |
22 | * @brief helper for the testcases for plugin_transport_wlan.c | 22 | * @brief helper for the testcases for plugin_transport_wlan.c |
23 | * @author David Brodski | 23 | * @author David Brodski |
24 | */ | 24 | */ |
25 | |||
26 | #include <sys/socket.h> | ||
27 | #include <sys/ioctl.h> | ||
28 | #include <sys/types.h> | ||
29 | #include <sys/wait.h> | ||
30 | #include <sys/time.h> | ||
31 | #include <sys/stat.h> | ||
32 | #include <stdio.h> | ||
33 | #include <stdlib.h> | ||
34 | |||
35 | #include <errno.h> | ||
36 | #include <resolv.h> | ||
37 | #include <string.h> | ||
38 | #include <utime.h> | ||
39 | #include <unistd.h> | ||
40 | #include <getopt.h> | ||
41 | |||
42 | #include "platform.h" | 25 | #include "platform.h" |
43 | #include "gnunet_constants.h" | 26 | #include "gnunet_constants.h" |
44 | #include "gnunet_os_lib.h" | 27 | #include "gnunet_os_lib.h" |
@@ -47,13 +30,24 @@ | |||
47 | #include "gnunet_util_lib.h" | 30 | #include "gnunet_util_lib.h" |
48 | #include "plugin_transport_wlan.h" | 31 | #include "plugin_transport_wlan.h" |
49 | #include "gnunet_common.h" | 32 | #include "gnunet_common.h" |
50 | //#include "gnunet-transport-wlan-helper.h" | ||
51 | #include "gnunet_crypto_lib.h" | 33 | #include "gnunet_crypto_lib.h" |
52 | #include "wlan/loopback_helper.h" | 34 | |
53 | #include "wlan/helper_common.h" | 35 | #define FIFO_FILE1 "/tmp/test-transport/api-wlan-p1/WLAN_FIFO_in" |
36 | #define FIFO_FILE2 "/tmp/test-transport/api-wlan-p1/WLAN_FIFO_out" | ||
37 | |||
38 | #define MAXLINE 4096 | ||
39 | |||
40 | struct sendbuf | ||
41 | { | ||
42 | unsigned int pos; | ||
43 | unsigned int size; | ||
44 | char buf[MAXLINE * 2]; | ||
45 | }; | ||
54 | 46 | ||
55 | static int first; | 47 | static int first; |
56 | 48 | ||
49 | static int closeprog; | ||
50 | |||
57 | static void | 51 | static void |
58 | sigfunc (int sig) | 52 | sigfunc (int sig) |
59 | { | 53 | { |
@@ -62,6 +56,26 @@ sigfunc (int sig) | |||
62 | (void) unlink (FIFO_FILE2); | 56 | (void) unlink (FIFO_FILE2); |
63 | } | 57 | } |
64 | 58 | ||
59 | /** | ||
60 | * function to create GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL message for plugin | ||
61 | * @param buffer pointer to buffer for the message | ||
62 | * @param mac pointer to the mac address | ||
63 | * @return number of bytes written | ||
64 | */ | ||
65 | int | ||
66 | send_mac_to_plugin (char *buffer, struct MacAddress *mac) | ||
67 | { | ||
68 | |||
69 | struct Wlan_Helper_Control_Message macmsg; | ||
70 | |||
71 | memcpy (&macmsg.mac, (char *) mac, sizeof (struct MacAddress)); | ||
72 | macmsg.hdr.size = htons (sizeof (struct Wlan_Helper_Control_Message)); | ||
73 | macmsg.hdr.type = htons (GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL); | ||
74 | |||
75 | memcpy (buffer, &macmsg, sizeof (struct Wlan_Helper_Control_Message)); | ||
76 | return sizeof (struct Wlan_Helper_Control_Message); | ||
77 | } | ||
78 | |||
65 | static void | 79 | static void |
66 | stdin_send (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) | 80 | stdin_send (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) |
67 | { | 81 | { |
@@ -132,7 +146,6 @@ file_in_send (void *cls, void *client, const struct GNUNET_MessageHeader *hdr) | |||
132 | write_std->size += sendsize; | 146 | write_std->size += sendsize; |
133 | } | 147 | } |
134 | 148 | ||
135 | int closeprog; | ||
136 | 149 | ||
137 | 150 | ||
138 | int | 151 | int |
@@ -284,7 +297,7 @@ testmode (int argc, char *argv[]) | |||
284 | macaddr.mac[4] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 256); | 297 | macaddr.mac[4] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 256); |
285 | macaddr.mac[5] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, 256); | 298 | macaddr.mac[5] = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, 256); |
286 | 299 | ||
287 | write_std.size = send_mac_to_plugin (write_std.buf, macaddr.mac); | 300 | write_std.size = send_mac_to_plugin (write_std.buf, &macaddr); |
288 | 301 | ||
289 | while (0 == closeprog) | 302 | while (0 == closeprog) |
290 | { | 303 | { |