diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-11-16 17:20:01 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-11-16 17:20:01 +0000 |
commit | 49d203ce0e6ec078457504f1cae4687944f1e09b (patch) | |
tree | 590fcd95cf0b22f1b5d0c3d68fab12927b73a5e2 /src/transport/gnunet-transport-wlan-sender.c | |
parent | cacbe3e0a796c7e477a9d168bc8d257ac2d4b4cf (diff) | |
download | gnunet-49d203ce0e6ec078457504f1cae4687944f1e09b.tar.gz gnunet-49d203ce0e6ec078457504f1cae4687944f1e09b.zip |
-fix
Diffstat (limited to 'src/transport/gnunet-transport-wlan-sender.c')
-rw-r--r-- | src/transport/gnunet-transport-wlan-sender.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/transport/gnunet-transport-wlan-sender.c b/src/transport/gnunet-transport-wlan-sender.c index e845d4862..ba09d0b6a 100644 --- a/src/transport/gnunet-transport-wlan-sender.c +++ b/src/transport/gnunet-transport-wlan-sender.c | |||
@@ -101,6 +101,7 @@ main (int argc, char *argv[]) | |||
101 | unsigned int temp[6]; | 101 | unsigned int temp[6]; |
102 | struct GNUNET_TRANSPORT_WLAN_MacAddress inmac; | 102 | struct GNUNET_TRANSPORT_WLAN_MacAddress inmac; |
103 | struct GNUNET_TRANSPORT_WLAN_MacAddress outmac; | 103 | struct GNUNET_TRANSPORT_WLAN_MacAddress outmac; |
104 | struct GNUNET_TRANSPORT_WLAN_MacAddress mac; | ||
104 | unsigned long long count; | 105 | unsigned long long count; |
105 | double bytes_per_s; | 106 | double bytes_per_s; |
106 | time_t start; | 107 | time_t start; |
@@ -142,6 +143,7 @@ main (int argc, char *argv[]) | |||
142 | 143 | ||
143 | pid_t pid; | 144 | pid_t pid; |
144 | int commpipe[2]; /* This holds the fd for the input & output of the pipe */ | 145 | int commpipe[2]; /* This holds the fd for the input & output of the pipe */ |
146 | int macpipe[2]; /* This holds the fd for the input & output of the pipe */ | ||
145 | 147 | ||
146 | /* Setup communication pipeline first */ | 148 | /* Setup communication pipeline first */ |
147 | if (pipe (commpipe)) | 149 | if (pipe (commpipe)) |
@@ -151,6 +153,13 @@ main (int argc, char *argv[]) | |||
151 | STRERROR (errno)); | 153 | STRERROR (errno)); |
152 | exit (1); | 154 | exit (1); |
153 | } | 155 | } |
156 | if (pipe (macpipe)) | ||
157 | { | ||
158 | fprintf (stderr, | ||
159 | "Failed to create pipe: %s\n", | ||
160 | STRERROR (errno)); | ||
161 | exit (1); | ||
162 | } | ||
154 | 163 | ||
155 | /* Attempt to fork and check for errors */ | 164 | /* Attempt to fork and check for errors */ |
156 | if ((pid = fork ()) == -1) | 165 | if ((pid = fork ()) == -1) |
@@ -169,7 +178,17 @@ main (int argc, char *argv[]) | |||
169 | strerror (errno)); | 178 | strerror (errno)); |
170 | setvbuf (stdout, (char *) NULL, _IONBF, 0); /* Set non-buffered output on stdout */ | 179 | setvbuf (stdout, (char *) NULL, _IONBF, 0); /* Set non-buffered output on stdout */ |
171 | 180 | ||
172 | 181 | if (0 != close (macpipe[1])) | |
182 | fprintf (stderr, | ||
183 | "Failed to close fd: %s\n", | ||
184 | strerror (errno)); | ||
185 | if (sizeof (mac) != read (macpipe[0], &mac, sizeof (mac))) | ||
186 | fprintf (stderr, | ||
187 | "Failed to read mac...\n"); | ||
188 | fprintf (stderr, | ||
189 | "Got mac %.2X:%.2X:%.2X:%.2X:%.2X:%.2X\n", | ||
190 | mac.mac[0], mac.mac[1], | ||
191 | mac.mac[2], mac.mac[3], mac.mac[4], mac.mac[5]); | ||
173 | radiotap = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *) msg_buf; | 192 | radiotap = (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage *) msg_buf; |
174 | getRadiotapHeader (radiotap, WLAN_MTU); | 193 | getRadiotapHeader (radiotap, WLAN_MTU); |
175 | getWlanHeader (&radiotap->frame, &outmac, &inmac, | 194 | getWlanHeader (&radiotap->frame, &outmac, &inmac, |
@@ -200,9 +219,13 @@ main (int argc, char *argv[]) | |||
200 | { | 219 | { |
201 | /* A zero PID indicates that this is the child process */ | 220 | /* A zero PID indicates that this is the child process */ |
202 | (void) close (0); | 221 | (void) close (0); |
222 | (void) close (1); | ||
203 | if (-1 == dup2 (commpipe[0], 0)) /* Replace stdin with the in side of the pipe */ | 223 | if (-1 == dup2 (commpipe[0], 0)) /* Replace stdin with the in side of the pipe */ |
204 | fprintf (stderr, "dup2 failed: %s\n", strerror (errno)); | 224 | fprintf (stderr, "dup2 failed: %s\n", strerror (errno)); |
225 | if (-1 == dup2 (macpipe[1], 1)) /* Replace stdout with the out side of the pipe */ | ||
226 | fprintf (stderr, "dup2 failed: %s\n", strerror (errno)); | ||
205 | (void) close (commpipe[1]); /* Close unused side of pipe (out side) */ | 227 | (void) close (commpipe[1]); /* Close unused side of pipe (out side) */ |
228 | (void) close (macpipe[0]); /* Close unused side of pipe (in side) */ | ||
206 | /* Replace the child fork with a new process */ | 229 | /* Replace the child fork with a new process */ |
207 | if (execlp | 230 | if (execlp |
208 | ("gnunet-helper-transport-wlan", "gnunet-helper-transport-wlan", | 231 | ("gnunet-helper-transport-wlan", "gnunet-helper-transport-wlan", |