diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-07-27 08:28:59 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-07-27 08:28:59 +0000 |
commit | 64653fc0a7a092c8edff5c7c5bb770f0ae4bca61 (patch) | |
tree | 24629d3708344c3ed7beb5bdd4e246aa8d654ffb /src/transport/test_plugin_transport_wlan_dummy.c | |
parent | adc9d89e46ab3f331fbba30298b2c569a5de14e4 (diff) | |
download | gnunet-64653fc0a7a092c8edff5c7c5bb770f0ae4bca61.tar.gz gnunet-64653fc0a7a092c8edff5c7c5bb770f0ae4bca61.zip |
init to zero
Diffstat (limited to 'src/transport/test_plugin_transport_wlan_dummy.c')
-rw-r--r-- | src/transport/test_plugin_transport_wlan_dummy.c | 46 |
1 files changed, 21 insertions, 25 deletions
diff --git a/src/transport/test_plugin_transport_wlan_dummy.c b/src/transport/test_plugin_transport_wlan_dummy.c index 71fcd29cf..173d22bba 100644 --- a/src/transport/test_plugin_transport_wlan_dummy.c +++ b/src/transport/test_plugin_transport_wlan_dummy.c | |||
@@ -52,7 +52,7 @@ | |||
52 | #include "wlan/loopback_helper.h" | 52 | #include "wlan/loopback_helper.h" |
53 | #include "wlan/helper_common.h" | 53 | #include "wlan/helper_common.h" |
54 | 54 | ||
55 | int first; | 55 | static int first; |
56 | 56 | ||
57 | static void | 57 | static void |
58 | sigfunc(int sig) | 58 | sigfunc(int sig) |
@@ -63,17 +63,15 @@ sigfunc(int sig) | |||
63 | } | 63 | } |
64 | 64 | ||
65 | static void | 65 | static void |
66 | stdin_send(void *cls, void *client, const struct GNUNET_MessageHeader *hdr) | 66 | stdin_send(void *cls, void *client, |
67 | const struct GNUNET_MessageHeader *hdr) | ||
67 | { | 68 | { |
68 | struct sendbuf *write_pout = cls; | 69 | struct sendbuf *write_pout = cls; |
69 | int sendsize; | 70 | int sendsize; |
70 | struct GNUNET_MessageHeader newheader; | 71 | struct GNUNET_MessageHeader newheader; |
71 | unsigned char * from_data; | 72 | char * to_data; |
72 | unsigned char * to_data; | 73 | char * to_radiotap; |
73 | //unsigned char * from_radiotap; | 74 | char * to_start; |
74 | unsigned char * to_radiotap; | ||
75 | //unsigned char * from_start; | ||
76 | unsigned char * to_start; | ||
77 | 75 | ||
78 | sendsize = ntohs(hdr->size) - sizeof(struct Radiotap_Send) | 76 | sendsize = ntohs(hdr->size) - sizeof(struct Radiotap_Send) |
79 | + sizeof(struct Radiotap_rx); | 77 | + sizeof(struct Radiotap_rx); |
@@ -93,21 +91,18 @@ stdin_send(void *cls, void *client, const struct GNUNET_MessageHeader *hdr) | |||
93 | newheader.type = htons(GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA); | 91 | newheader.type = htons(GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA); |
94 | 92 | ||
95 | to_start = write_pout->buf + write_pout->size; | 93 | to_start = write_pout->buf + write_pout->size; |
96 | to_radiotap = to_start + sizeof(struct GNUNET_MessageHeader); | ||
97 | to_data = to_radiotap + sizeof(struct Radiotap_rx); | ||
98 | |||
99 | from_data = ((unsigned char *) hdr) + sizeof(struct Radiotap_Send) | ||
100 | + sizeof(struct GNUNET_MessageHeader); | ||
101 | |||
102 | memcpy(to_start, &newheader, sizeof(struct GNUNET_MessageHeader)); | 94 | memcpy(to_start, &newheader, sizeof(struct GNUNET_MessageHeader)); |
103 | write_pout->size += sizeof(struct GNUNET_MessageHeader); | 95 | write_pout->size += sizeof(struct GNUNET_MessageHeader); |
104 | 96 | ||
97 | to_radiotap = to_start + sizeof(struct GNUNET_MessageHeader); | ||
98 | memset(to_radiotap, 0, sizeof (struct Radiotap_rx)); | ||
105 | write_pout->size += sizeof(struct Radiotap_rx); | 99 | write_pout->size += sizeof(struct Radiotap_rx); |
106 | 100 | ||
107 | memcpy(to_data, from_data, ntohs(hdr->size) - sizeof(struct Radiotap_Send) | 101 | to_data = to_radiotap + sizeof(struct Radiotap_rx); |
108 | - sizeof(struct GNUNET_MessageHeader)); | 102 | memcpy(to_data, |
109 | write_pout->size += ntohs(hdr->size) - sizeof(struct Radiotap_Send) | 103 | ((char *) hdr) + sizeof(struct Radiotap_Send) + sizeof(struct GNUNET_MessageHeader), |
110 | - sizeof(struct GNUNET_MessageHeader); | 104 | ntohs(hdr->size) - sizeof(struct Radiotap_Send) - sizeof(struct GNUNET_MessageHeader)); |
105 | write_pout->size += ntohs(hdr->size) - sizeof(struct Radiotap_Send) - sizeof(struct GNUNET_MessageHeader); | ||
111 | } | 106 | } |
112 | 107 | ||
113 | static void | 108 | static void |
@@ -283,7 +278,7 @@ testmode(int argc, char *argv[]) | |||
283 | macaddr.mac[4] = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_STRONG, 256); | 278 | macaddr.mac[4] = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_STRONG, 256); |
284 | macaddr.mac[5] = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_NONCE, 256); | 279 | macaddr.mac[5] = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_NONCE, 256); |
285 | 280 | ||
286 | write_std.size = send_mac_to_plugin((char *) write_std.buf, macaddr.mac); | 281 | write_std.size = send_mac_to_plugin(write_std.buf, macaddr.mac); |
287 | 282 | ||
288 | while (0 == closeprog) | 283 | while (0 == closeprog) |
289 | { | 284 | { |
@@ -335,9 +330,9 @@ testmode(int argc, char *argv[]) | |||
335 | 330 | ||
336 | if (FD_ISSET(STDOUT_FILENO, &wfds)) | 331 | if (FD_ISSET(STDOUT_FILENO, &wfds)) |
337 | { | 332 | { |
338 | ret = write(STDOUT_FILENO, write_std.buf + write_std.pos, | 333 | ret = write(STDOUT_FILENO, |
339 | write_std.size - write_std.pos); | 334 | write_std.buf + write_std.pos, |
340 | 335 | write_std.size - write_std.pos); | |
341 | if (0 > ret) | 336 | if (0 > ret) |
342 | { | 337 | { |
343 | closeprog = 1; | 338 | closeprog = 1; |
@@ -358,9 +353,10 @@ testmode(int argc, char *argv[]) | |||
358 | 353 | ||
359 | if (FD_ISSET(fdpout, &wfds)) | 354 | if (FD_ISSET(fdpout, &wfds)) |
360 | { | 355 | { |
361 | ret = write(fdpout, write_pout.buf + write_pout.pos, write_pout.size | 356 | ret = write(fdpout, |
362 | - write_pout.pos); | 357 | write_pout.buf + write_pout.pos, |
363 | 358 | write_pout.size - write_pout.pos); | |
359 | |||
364 | if (0 > ret) | 360 | if (0 > ret) |
365 | { | 361 | { |
366 | closeprog = 1; | 362 | closeprog = 1; |