aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-helper-transport-wlan.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/gnunet-helper-transport-wlan.c')
-rw-r--r--src/transport/gnunet-helper-transport-wlan.c146
1 files changed, 73 insertions, 73 deletions
diff --git a/src/transport/gnunet-helper-transport-wlan.c b/src/transport/gnunet-helper-transport-wlan.c
index 7f472b3be..ce385b45b 100644
--- a/src/transport/gnunet-helper-transport-wlan.c
+++ b/src/transport/gnunet-helper-transport-wlan.c
@@ -140,15 +140,15 @@
140#include "plugin_transport_wlan.h" 140#include "plugin_transport_wlan.h"
141 141
142/** 142/**
143 * Packet format type for the messages we receive from 143 * Packet format type for the messages we receive from
144 * the kernel. This is for Ethernet 10Mbps format (no 144 * the kernel. This is for Ethernet 10Mbps format (no
145 * performance information included). 145 * performance information included).
146 */ 146 */
147#define ARPHRD_ETHER 1 147#define ARPHRD_ETHER 1
148 148
149 149
150/** 150/**
151 * Packet format type for the messages we receive from 151 * Packet format type for the messages we receive from
152 * the kernel. This is for plain messages (with no 152 * the kernel. This is for plain messages (with no
153 * performance information included). 153 * performance information included).
154 */ 154 */
@@ -156,13 +156,13 @@
156 156
157 157
158/** 158/**
159 * Packet format type for the messages we receive from 159 * Packet format type for the messages we receive from
160 * the kernel. This is for the PRISM format. 160 * the kernel. This is for the PRISM format.
161 */ 161 */
162#define ARPHRD_IEEE80211_PRISM 802 162#define ARPHRD_IEEE80211_PRISM 802
163 163
164/** 164/**
165 * Packet format type for the messages we receive from 165 * Packet format type for the messages we receive from
166 * the kernel. This is for messages with a 166 * the kernel. This is for messages with a
167 * 'struct Ieee80211RadiotapHeader' (see below). 167 * 'struct Ieee80211RadiotapHeader' (see below).
168 */ 168 */
@@ -195,35 +195,35 @@
195 * Drivers appear to use a 64bit counter to hold mactime internal 195 * Drivers appear to use a 64bit counter to hold mactime internal
196 * the then fill the prism header with the lower 32 bits 196 * the then fill the prism header with the lower 32 bits
197 */ 197 */
198#define PRISM_DID_MACTIME 0x2041 198#define PRISM_DID_MACTIME 0x2041
199 199
200/** 200/**
201 * Channel element 201 * Channel element
202 */ 202 */
203#define PRISM_DID_CHANNEL 0x3041 203#define PRISM_DID_CHANNEL 0x3041
204 204
205/** 205/**
206 * Signal element. Should be the signal strength in dbm, some people 206 * Signal element. Should be the signal strength in dbm, some people
207 * suggest that instead "100 - (strength in dbm)" is used (to make this 207 * suggest that instead "100 - (strength in dbm)" is used (to make this
208 * a positive integer). 208 * a positive integer).
209 */ 209 */
210#define PRISM_DID_SIGNAL 0x6041 210#define PRISM_DID_SIGNAL 0x6041
211 211
212/** 212/**
213 * Noise element 213 * Noise element
214 */ 214 */
215#define PRISM_DID_NOISE 0x7041 215#define PRISM_DID_NOISE 0x7041
216 216
217/** 217/**
218 * Rate element, in units/multiples of 500Khz 218 * Rate element, in units/multiples of 500Khz
219 */ 219 */
220#define PRISM_DID_RATE 0x8041 220#define PRISM_DID_RATE 0x8041
221 221
222 222
223/** 223/**
224 * Value is set (supplied) 224 * Value is set (supplied)
225 */ 225 */
226#define PRISM_STATUS_OK 0 226#define PRISM_STATUS_OK 0
227 227
228/** 228/**
229 * Value not supplied. 229 * Value not supplied.
@@ -240,24 +240,24 @@ struct PrismValue
240 * This has a different ID for each parameter, see 240 * This has a different ID for each parameter, see
241 * PRISM_DID_* constants. 241 * PRISM_DID_* constants.
242 */ 242 */
243 uint32_t did; 243 uint32_t did;
244 244
245 /** 245 /**
246 * See PRISM_STATUS_*-constants. Note that they are unusual: 0 = set; 1 = not set 246 * See PRISM_STATUS_*-constants. Note that they are unusual: 0 = set; 1 = not set
247 */ 247 */
248 uint16_t status; 248 uint16_t status;
249 249
250 /** 250 /**
251 * length of data (which is always a uint32_t, but presumably this can be used 251 * length of data (which is always a uint32_t, but presumably this can be used
252 * to specify that fewer bytes are used (with values in 'len' from 0-4). We 252 * to specify that fewer bytes are used (with values in 'len' from 0-4). We
253 * ignore this field. 253 * ignore this field.
254 */ 254 */
255 uint16_t len; 255 uint16_t len;
256 256
257 /** 257 /**
258 * The data value 258 * The data value
259 */ 259 */
260 uint32_t data; 260 uint32_t data;
261 261
262} __attribute__ ((packed)); 262} __attribute__ ((packed));
263 263
@@ -271,11 +271,11 @@ struct PrismHeader
271 * We expect this to be a PRISM_MSGCODE_*. 271 * We expect this to be a PRISM_MSGCODE_*.
272 */ 272 */
273 uint32_t msgcode; 273 uint32_t msgcode;
274 274
275 /** 275 /**
276 * The length of the entire header. 276 * The length of the entire header.
277 */ 277 */
278 uint32_t msglen; 278 uint32_t msglen;
279 279
280 /** 280 /**
281 * Name of the device that captured the packet. 281 * Name of the device that captured the packet.
@@ -402,7 +402,7 @@ enum RadiotapType
402 */ 402 */
403 IEEE80211_RADIOTAP_DBM_TX_POWER = 10, 403 IEEE80211_RADIOTAP_DBM_TX_POWER = 10,
404 404
405 /** 405 /**
406 * IEEE80211_RADIOTAP_ANTENNA uint8_t antenna index 406 * IEEE80211_RADIOTAP_ANTENNA uint8_t antenna index
407 * 407 *
408 * Unitless indication of the Rx/Tx antenna for this packet. 408 * Unitless indication of the Rx/Tx antenna for this packet.
@@ -433,10 +433,10 @@ enum RadiotapType
433 */ 433 */
434 IEEE80211_RADIOTAP_RX_FLAGS = 14, 434 IEEE80211_RADIOTAP_RX_FLAGS = 14,
435 435
436 /** 436 /**
437 * IEEE80211_RADIOTAP_TX_FLAGS __le16 bitmap 437 * IEEE80211_RADIOTAP_TX_FLAGS __le16 bitmap
438 * 438 *
439 * Properties of transmitted frames. See flags defined below. 439 * Properties of transmitted frames. See flags defined below.
440 */ 440 */
441 IEEE80211_RADIOTAP_TX_FLAGS = 15, 441 IEEE80211_RADIOTAP_TX_FLAGS = 15,
442 442
@@ -462,7 +462,7 @@ enum RadiotapType
462}; 462};
463 463
464/** 464/**
465 * Bitmask indicating an extension of the bitmask is used. 465 * Bitmask indicating an extension of the bitmask is used.
466 * (Mask corresponding to IEEE80211_RADIOTAP_EXT). 466 * (Mask corresponding to IEEE80211_RADIOTAP_EXT).
467 */ 467 */
468#define IEEE80211_RADIOTAP_PRESENT_EXTEND_MASK (1 << IEEE80211_RADIOTAP_EXT) 468#define IEEE80211_RADIOTAP_PRESENT_EXTEND_MASK (1 << IEEE80211_RADIOTAP_EXT)
@@ -487,7 +487,7 @@ enum RadiotapType
487 * 487 *
488 * Frame was sent/received with short preamble 488 * Frame was sent/received with short preamble
489 */ 489 */
490#define IEEE80211_RADIOTAP_F_SHORTPRE 0x02 490#define IEEE80211_RADIOTAP_F_SHORTPRE 0x02
491 491
492/** 492/**
493 * Bit in IEEE80211_RADIOTAP_FLAGS (which we might get 493 * Bit in IEEE80211_RADIOTAP_FLAGS (which we might get
@@ -497,7 +497,7 @@ enum RadiotapType
497 * 497 *
498 * Frame was sent/received with WEP encryption 498 * Frame was sent/received with WEP encryption
499 */ 499 */
500#define IEEE80211_RADIOTAP_F_WEP 0x04 500#define IEEE80211_RADIOTAP_F_WEP 0x04
501 501
502/** 502/**
503 * Bit in IEEE80211_RADIOTAP_FLAGS (which we might get 503 * Bit in IEEE80211_RADIOTAP_FLAGS (which we might get
@@ -507,7 +507,7 @@ enum RadiotapType
507 * 507 *
508 * Frame was sent/received with fragmentation 508 * Frame was sent/received with fragmentation
509 */ 509 */
510#define IEEE80211_RADIOTAP_F_FRAG 0x08 510#define IEEE80211_RADIOTAP_F_FRAG 0x08
511 511
512/** 512/**
513 * Bit in IEEE80211_RADIOTAP_FLAGS (which we might get 513 * Bit in IEEE80211_RADIOTAP_FLAGS (which we might get
@@ -517,7 +517,7 @@ enum RadiotapType
517 * 517 *
518 * Frame includes FCS (CRC at the end that needs to be removeD). 518 * Frame includes FCS (CRC at the end that needs to be removeD).
519 */ 519 */
520#define IEEE80211_RADIOTAP_F_FCS 0x10 520#define IEEE80211_RADIOTAP_F_FCS 0x10
521 521
522/** 522/**
523 * Bit in IEEE80211_RADIOTAP_FLAGS (which we might get 523 * Bit in IEEE80211_RADIOTAP_FLAGS (which we might get
@@ -528,32 +528,32 @@ enum RadiotapType
528 * Frame has padding between 802.11 header and payload 528 * Frame has padding between 802.11 header and payload
529 * (to 32-bit boundary) 529 * (to 32-bit boundary)
530 */ 530 */
531#define IEEE80211_RADIOTAP_F_DATAPAD 0x20 531#define IEEE80211_RADIOTAP_F_DATAPAD 0x20
532 532
533 533
534/** 534/**
535 * For IEEE80211_RADIOTAP_RX_FLAGS: 535 * For IEEE80211_RADIOTAP_RX_FLAGS:
536 * frame failed crc check 536 * frame failed crc check
537 */ 537 */
538#define IEEE80211_RADIOTAP_F_RX_BADFCS 0x0001 538#define IEEE80211_RADIOTAP_F_RX_BADFCS 0x0001
539 539
540/** 540/**
541 * For IEEE80211_RADIOTAP_TX_FLAGS ('txflags' in 'struct RadiotapTransmissionHeader'): 541 * For IEEE80211_RADIOTAP_TX_FLAGS ('txflags' in 'struct RadiotapTransmissionHeader'):
542 * failed due to excessive retries 542 * failed due to excessive retries
543 */ 543 */
544#define IEEE80211_RADIOTAP_F_TX_FAIL 0x0001 544#define IEEE80211_RADIOTAP_F_TX_FAIL 0x0001
545 545
546/** 546/**
547 * For IEEE80211_RADIOTAP_TX_FLAGS ('txflags' in 'struct RadiotapTransmissionHeader'): 547 * For IEEE80211_RADIOTAP_TX_FLAGS ('txflags' in 'struct RadiotapTransmissionHeader'):
548 * used cts 'protection' 548 * used cts 'protection'
549 */ 549 */
550#define IEEE80211_RADIOTAP_F_TX_CTS 0x0002 550#define IEEE80211_RADIOTAP_F_TX_CTS 0x0002
551 551
552/** 552/**
553 * For IEEE80211_RADIOTAP_TX_FLAGS ('txflags' in 'struct RadiotapTransmissionHeader'): 553 * For IEEE80211_RADIOTAP_TX_FLAGS ('txflags' in 'struct RadiotapTransmissionHeader'):
554 * used rts/cts handshake 554 * used rts/cts handshake
555 */ 555 */
556#define IEEE80211_RADIOTAP_F_TX_RTS 0x0004 556#define IEEE80211_RADIOTAP_F_TX_RTS 0x0004
557 557
558/** 558/**
559 * For IEEE80211_RADIOTAP_TX_FLAGS ('txflags' in 'struct RadiotapTransmissionHeader'): 559 * For IEEE80211_RADIOTAP_TX_FLAGS ('txflags' in 'struct RadiotapTransmissionHeader'):
@@ -563,7 +563,7 @@ enum RadiotapType
563 563
564/** 564/**
565 * For IEEE80211_RADIOTAP_TX_FLAGS ('txflags' in 'struct RadiotapTransmissionHeader'): 565 * For IEEE80211_RADIOTAP_TX_FLAGS ('txflags' in 'struct RadiotapTransmissionHeader'):
566 * sequence number handled by userspace 566 * sequence number handled by userspace
567 */ 567 */
568#define IEEE80211_RADIOTAP_F_TX_NOSEQ 0x0010 568#define IEEE80211_RADIOTAP_F_TX_NOSEQ 0x0010
569 569
@@ -591,7 +591,7 @@ struct Ieee80211RadiotapHeader
591 uint8_t it_version; 591 uint8_t it_version;
592 592
593 /** 593 /**
594 * Padding. Set to 0. 594 * Padding. Set to 0.
595 */ 595 */
596 uint8_t it_pad; 596 uint8_t it_pad;
597 597
@@ -611,7 +611,7 @@ struct Ieee80211RadiotapHeader
611 611
612 612
613/** 613/**
614 * Format of the header we need to prepend to messages to be sent to the 614 * Format of the header we need to prepend to messages to be sent to the
615 * Kernel. 615 * Kernel.
616 */ 616 */
617struct RadiotapTransmissionHeader 617struct RadiotapTransmissionHeader
@@ -752,7 +752,7 @@ struct SendBuffer
752 * destination? Always smaller than 'size'. 752 * destination? Always smaller than 'size'.
753 */ 753 */
754 size_t pos; 754 size_t pos;
755 755
756 /** 756 /**
757 * Buffered data; twice the maximum allowed message size as we add some 757 * Buffered data; twice the maximum allowed message size as we add some
758 * headers. 758 * headers.
@@ -794,7 +794,7 @@ static struct SendBuffer write_std;
794 * @param cls closure 794 * @param cls closure
795 * @param message the actual message 795 * @param message the actual message
796 */ 796 */
797typedef void (*MessageTokenizerCallback) (void *cls, 797typedef void (*MessageTokenizerCallback) (void *cls,
798 const struct 798 const struct
799 GNUNET_MessageHeader * 799 GNUNET_MessageHeader *
800 message); 800 message);
@@ -1059,7 +1059,7 @@ mst_destroy (struct MessageStreamTokenizer *mst)
1059 */ 1059 */
1060static int 1060static int
1061ieee80211_radiotap_iterator_init (struct Ieee80211RadiotapHeaderIterator *iterator, 1061ieee80211_radiotap_iterator_init (struct Ieee80211RadiotapHeaderIterator *iterator,
1062 const struct Ieee80211RadiotapHeader *radiotap_header, 1062 const struct Ieee80211RadiotapHeader *radiotap_header,
1063 size_t max_length) 1063 size_t max_length)
1064{ 1064{
1065 if ( (iterator == NULL) || 1065 if ( (iterator == NULL) ||
@@ -1204,26 +1204,26 @@ ieee80211_radiotap_iterator_next (struct Ieee80211RadiotapHeaderIterator *iterat
1204 /* need padding (by 'wanted_alignment - unalignment') */ 1204 /* need padding (by 'wanted_alignment - unalignment') */
1205 iterator->arg_index += wanted_alignment - unalignment; 1205 iterator->arg_index += wanted_alignment - unalignment;
1206 } 1206 }
1207 1207
1208 /* 1208 /*
1209 * this is what we will return to user, but we need to 1209 * this is what we will return to user, but we need to
1210 * move on first so next call has something fresh to test 1210 * move on first so next call has something fresh to test
1211 */ 1211 */
1212 iterator->this_arg_index = iterator->arg_index; 1212 iterator->this_arg_index = iterator->arg_index;
1213 iterator->this_arg = iterator->arg; 1213 iterator->this_arg = iterator->arg;
1214 1214
1215 /* internally move on the size of this arg (using lower nybble from 1215 /* internally move on the size of this arg (using lower nybble from
1216 the table) */ 1216 the table) */
1217 iterator->arg += rt_sizes[iterator->arg_index] & 0x0f; 1217 iterator->arg += rt_sizes[iterator->arg_index] & 0x0f;
1218 1218
1219 /* 1219 /*
1220 * check for insanity where we are given a bitmap that 1220 * check for insanity where we are given a bitmap that
1221 * claims to have more arg content than the length of the 1221 * claims to have more arg content than the length of the
1222 * radiotap section. We will normally end up equalling this 1222 * radiotap section. We will normally end up equalling this
1223 * max_length on the last arg, never exceeding it. 1223 * max_length on the last arg, never exceeding it.
1224 */ 1224 */
1225 if ((((void *) iterator->arg) - ((void *) iterator->rtheader)) > iterator->max_length) 1225 if ((((void *) iterator->arg) - ((void *) iterator->rtheader)) > iterator->max_length)
1226 return -1; 1226 return -1;
1227 } 1227 }
1228 1228
1229 /* Now, move on to next bit / next entry */ 1229 /* Now, move on to next bit / next entry */
@@ -1245,7 +1245,7 @@ ieee80211_radiotap_iterator_next (struct Ieee80211RadiotapHeaderIterator *iterat
1245 } 1245 }
1246 } 1246 }
1247 else 1247 else
1248 { 1248 {
1249 /* just try the next bit (while loop will move on) */ 1249 /* just try the next bit (while loop will move on) */
1250 iterator->bitmap_shifter >>= 1; 1250 iterator->bitmap_shifter >>= 1;
1251 } 1251 }
@@ -1364,7 +1364,7 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len)
1364 if (((crc) & 0xFF) == buf[0] && ((crc >> 8) & 0xFF) == buf[1] && 1364 if (((crc) & 0xFF) == buf[0] && ((crc >> 8) & 0xFF) == buf[1] &&
1365 ((crc >> 16) & 0xFF) == buf[2] && ((crc >> 24) & 0xFF) == buf[3]) 1365 ((crc >> 16) & 0xFF) == buf[2] && ((crc >> 24) & 0xFF) == buf[3])
1366 return 0; 1366 return 0;
1367 return 1; 1367 return 1;
1368} 1368}
1369 1369
1370 1370
@@ -1431,7 +1431,7 @@ linux_get_channel (const struct HardwareInfos *dev)
1431 * @return number of bytes written to 'buf' 1431 * @return number of bytes written to 'buf'
1432 */ 1432 */
1433static ssize_t 1433static ssize_t
1434linux_read (struct HardwareInfos *dev, 1434linux_read (struct HardwareInfos *dev,
1435 unsigned char *buf, size_t buf_size, 1435 unsigned char *buf, size_t buf_size,
1436 struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *ri) 1436 struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *ri)
1437{ 1437{
@@ -1452,7 +1452,7 @@ linux_read (struct HardwareInfos *dev,
1452 return -1; 1452 return -1;
1453 } 1453 }
1454 1454
1455 memset (ri, 0, sizeof (*ri)); 1455 memset (ri, 0, sizeof (*ri));
1456 switch (dev->arptype_in) 1456 switch (dev->arptype_in)
1457 { 1457 {
1458 case ARPHRD_IEEE80211_PRISM: 1458 case ARPHRD_IEEE80211_PRISM:
@@ -1511,7 +1511,7 @@ linux_read (struct HardwareInfos *dev,
1511 break; 1511 break;
1512 } 1512 }
1513 } 1513 }
1514 } 1514 }
1515 if ( (n < 8) || (n >= caplen) ) 1515 if ( (n < 8) || (n >= caplen) )
1516 return 0; /* invalid format */ 1516 return 0; /* invalid format */
1517 } 1517 }
@@ -1540,7 +1540,7 @@ linux_read (struct HardwareInfos *dev,
1540 if (!got_signal) 1540 if (!got_signal)
1541 { 1541 {
1542 ri->ri_power = * ((int8_t*) iterator.this_arg); 1542 ri->ri_power = * ((int8_t*) iterator.this_arg);
1543 got_signal = 1; 1543 got_signal = 1;
1544 } 1544 }
1545 break; 1545 break;
1546 case IEEE80211_RADIOTAP_DB_ANTSIGNAL: 1546 case IEEE80211_RADIOTAP_DB_ANTSIGNAL:
@@ -1594,7 +1594,7 @@ linux_read (struct HardwareInfos *dev,
1594 break; 1594 break;
1595 } /* end of 'switch' */ 1595 } /* end of 'switch' */
1596 } /* end of the 'while' loop */ 1596 } /* end of the 'while' loop */
1597 } 1597 }
1598 break; 1598 break;
1599 case ARPHRD_IEEE80211: 1599 case ARPHRD_IEEE80211:
1600 n = 0; /* no header */ 1600 n = 0; /* no header */
@@ -1607,7 +1607,7 @@ linux_read (struct HardwareInfos *dev,
1607 tmpbuf + sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee8023Frame), 1607 tmpbuf + sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee8023Frame),
1608 caplen - sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee8023Frame) - 4 /* 4 byte FCS */); 1608 caplen - sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee8023Frame) - 4 /* 4 byte FCS */);
1609 return caplen - sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee8023Frame) - 4; 1609 return caplen - sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee8023Frame) - 4;
1610 } 1610 }
1611 default: 1611 default:
1612 errno = ENOTSUP; /* unsupported format */ 1612 errno = ENOTSUP; /* unsupported format */
1613 return -1; 1613 return -1;
@@ -1617,8 +1617,8 @@ linux_read (struct HardwareInfos *dev,
1617 ri->ri_channel = linux_get_channel (dev); 1617 ri->ri_channel = linux_get_channel (dev);
1618 1618
1619 /* detect CRC32 at the end, even if the flag wasn't set and remove it */ 1619 /* detect CRC32 at the end, even if the flag wasn't set and remove it */
1620 if ( (0 == fcs_removed) && 1620 if ( (0 == fcs_removed) &&
1621 (0 == check_crc_buf_osdep (tmpbuf + n, caplen - sizeof (uint32_t))) ) 1621 (0 == check_crc_buf_osdep (tmpbuf + n, caplen - sizeof (uint32_t))) )
1622 { 1622 {
1623 /* NOTE: this heuristic can of course fail if there happens to 1623 /* NOTE: this heuristic can of course fail if there happens to
1624 be a matching checksum at the end. Would be good to have 1624 be a matching checksum at the end. Would be good to have
@@ -1751,9 +1751,9 @@ open_device_raw (struct HardwareInfos *dev)
1751 setsockopt (dev->fd_raw, SOL_PACKET, PACKET_ADD_MEMBERSHIP, &mr, 1751 setsockopt (dev->fd_raw, SOL_PACKET, PACKET_ADD_MEMBERSHIP, &mr,
1752 sizeof (mr))) 1752 sizeof (mr)))
1753 { 1753 {
1754 fprintf (stderr, 1754 fprintf (stderr,
1755 "Failed to enable promiscuous mode on interface `%.*s'\n", 1755 "Failed to enable promiscuous mode on interface `%.*s'\n",
1756 IFNAMSIZ, 1756 IFNAMSIZ,
1757 dev->iface); 1757 dev->iface);
1758 return 1; 1758 return 1;
1759 } 1759 }
@@ -1775,13 +1775,13 @@ test_wlan_interface (const char *iface)
1775 struct stat sbuf; 1775 struct stat sbuf;
1776 int ret; 1776 int ret;
1777 1777
1778 ret = snprintf (strbuf, sizeof (strbuf), 1778 ret = snprintf (strbuf, sizeof (strbuf),
1779 "/sys/class/net/%s/phy80211/subsystem", 1779 "/sys/class/net/%s/phy80211/subsystem",
1780 iface); 1780 iface);
1781 if ((ret < 0) || (ret >= sizeof (strbuf)) || (0 != stat (strbuf, &sbuf))) 1781 if ((ret < 0) || (ret >= sizeof (strbuf)) || (0 != stat (strbuf, &sbuf)))
1782 { 1782 {
1783 fprintf (stderr, 1783 fprintf (stderr,
1784 "Did not find 802.11 interface `%s'. Exiting.\n", 1784 "Did not find 802.11 interface `%s'. Exiting.\n",
1785 iface); 1785 iface);
1786 exit (1); 1786 exit (1);
1787 } 1787 }
@@ -1852,7 +1852,7 @@ stdin_send_hw (void *cls, const struct GNUNET_MessageHeader *hdr)
1852 sendsize = ntohs (hdr->size); 1852 sendsize = ntohs (hdr->size);
1853 if ( (sendsize < 1853 if ( (sendsize <
1854 sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage)) || 1854 sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapSendMessage)) ||
1855 (GNUNET_MESSAGE_TYPE_WLAN_DATA_TO_HELPER != ntohs (hdr->type)) ) 1855 (GNUNET_MESSAGE_TYPE_WLAN_DATA_TO_HELPER != ntohs (hdr->type)) )
1856 { 1856 {
1857 fprintf (stderr, "Received malformed message\n"); 1857 fprintf (stderr, "Received malformed message\n");
1858 exit (1); 1858 exit (1);
@@ -1870,10 +1870,10 @@ stdin_send_hw (void *cls, const struct GNUNET_MessageHeader *hdr)
1870 case ARPHRD_IEEE80211_FULL: 1870 case ARPHRD_IEEE80211_FULL:
1871 case ARPHRD_IEEE80211: 1871 case ARPHRD_IEEE80211:
1872 rtheader.header.it_version = 0; 1872 rtheader.header.it_version = 0;
1873 rtheader.header.it_pad = 0; 1873 rtheader.header.it_pad = 0;
1874 rtheader.header.it_len = GNUNET_htole16 (sizeof (rtheader)); 1874 rtheader.header.it_len = GNUNET_htole16 (sizeof (rtheader));
1875 rtheader.header.it_present = GNUNET_htole16 (IEEE80211_RADIOTAP_OUR_TRANSMISSION_HEADER_MASK); 1875 rtheader.header.it_present = GNUNET_htole16 (IEEE80211_RADIOTAP_OUR_TRANSMISSION_HEADER_MASK);
1876 rtheader.rate = header->rate; 1876 rtheader.rate = header->rate;
1877 rtheader.pad1 = 0; 1877 rtheader.pad1 = 0;
1878 rtheader.txflags = GNUNET_htole16 (IEEE80211_RADIOTAP_F_TX_NOACK | IEEE80211_RADIOTAP_F_TX_NOSEQ); 1878 rtheader.txflags = GNUNET_htole16 (IEEE80211_RADIOTAP_F_TX_NOACK | IEEE80211_RADIOTAP_F_TX_NOSEQ);
1879 memcpy (write_pout.buf, &rtheader, sizeof (rtheader)); 1879 memcpy (write_pout.buf, &rtheader, sizeof (rtheader));
@@ -1934,7 +1934,7 @@ main (int argc, char *argv[])
1934 return 254; 1934 return 254;
1935 } 1935 }
1936#else 1936#else
1937 if (0 != seteuid (0)) 1937 if (0 != seteuid (0))
1938 { 1938 {
1939 fprintf (stderr, "Failed to seteuid back to root: %s\n", strerror (errno)); 1939 fprintf (stderr, "Failed to seteuid back to root: %s\n", strerror (errno));
1940 return 254; 1940 return 254;
@@ -2012,9 +2012,9 @@ main (int argc, char *argv[])
2012 memcpy (&macmsg.mac, &dev.pl_mac, sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress)); 2012 memcpy (&macmsg.mac, &dev.pl_mac, sizeof (struct GNUNET_TRANSPORT_WLAN_MacAddress));
2013 memcpy (write_std.buf, &macmsg, sizeof (macmsg)); 2013 memcpy (write_std.buf, &macmsg, sizeof (macmsg));
2014 write_std.size = sizeof (macmsg); 2014 write_std.size = sizeof (macmsg);
2015 } 2015 }
2016 2016
2017 stdin_mst = mst_create (&stdin_send_hw, &dev); 2017 stdin_mst = mst_create (&stdin_send_hw, &dev);
2018 stdin_open = 1; 2018 stdin_open = 1;
2019 while (1) 2019 while (1)
2020 { 2020 {
@@ -2071,7 +2071,7 @@ main (int argc, char *argv[])
2071 if (FD_ISSET (dev.fd_raw, &wfds)) 2071 if (FD_ISSET (dev.fd_raw, &wfds))
2072 { 2072 {
2073 ssize_t ret = 2073 ssize_t ret =
2074 write (dev.fd_raw, write_pout.buf + write_std.pos, 2074 write (dev.fd_raw, write_pout.buf + write_std.pos,
2075 write_pout.size - write_pout.pos); 2075 write_pout.size - write_pout.pos);
2076 if (0 > ret) 2076 if (0 > ret)
2077 { 2077 {
@@ -2097,7 +2097,7 @@ main (int argc, char *argv[])
2097 2097
2098 if (FD_ISSET (STDIN_FILENO, &rfds)) 2098 if (FD_ISSET (STDIN_FILENO, &rfds))
2099 { 2099 {
2100 ssize_t ret = 2100 ssize_t ret =
2101 read (STDIN_FILENO, readbuf, sizeof (readbuf)); 2101 read (STDIN_FILENO, readbuf, sizeof (readbuf));
2102 if (0 > ret) 2102 if (0 > ret)
2103 { 2103 {
@@ -2120,9 +2120,9 @@ main (int argc, char *argv[])
2120 rrm = (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *) write_std.buf; 2120 rrm = (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *) write_std.buf;
2121 ret = 2121 ret =
2122 linux_read (&dev, (unsigned char *) &rrm->frame, 2122 linux_read (&dev, (unsigned char *) &rrm->frame,
2123 sizeof (write_std.buf) 2123 sizeof (write_std.buf)
2124 - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage) 2124 - sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage)
2125 + sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame), 2125 + sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame),
2126 rrm); 2126 rrm);
2127 if (0 > ret) 2127 if (0 > ret)
2128 { 2128 {
@@ -2131,8 +2131,8 @@ main (int argc, char *argv[])
2131 } 2131 }
2132 if ((0 < ret) && (0 == mac_test (&rrm->frame, &dev))) 2132 if ((0 < ret) && (0 == mac_test (&rrm->frame, &dev)))
2133 { 2133 {
2134 write_std.size = ret 2134 write_std.size = ret
2135 + sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage) 2135 + sizeof (struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage)
2136 - sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame); 2136 - sizeof (struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame);
2137 rrm->header.size = htons (write_std.size); 2137 rrm->header.size = htons (write_std.size);
2138 rrm->header.type = htons (GNUNET_MESSAGE_TYPE_WLAN_DATA_FROM_HELPER); 2138 rrm->header.type = htons (GNUNET_MESSAGE_TYPE_WLAN_DATA_FROM_HELPER);