113 #include "gnunet_private_config.h"
114 #include <netpacket/packet.h>
115 #include <linux/if_ether.h>
116 #include <linux/wireless.h>
126 #define ARPHRD_ETHER 1
134 #define ARPHRD_IEEE80211 801
141 #define ARPHRD_IEEE80211_PRISM 802
148 #define ARPHRD_IEEE80211_FULL 803
164 #define PRISM_DEVICE_NAME_LENGTH 16
169 #define PRISM_MSGCODE_MONITOR 0x0041
176 #define PRISM_DID_MACTIME 0x2041
181 #define PRISM_DID_CHANNEL 0x3041
188 #define PRISM_DID_SIGNAL 0x6041
193 #define PRISM_DID_NOISE 0x7041
198 #define PRISM_DID_RATE 0x8041
204 #define PRISM_STATUS_OK 0
209 #define PRISM_STATUS_NO_VALUE 1
443 #define IEEE80211_RADIOTAP_PRESENT_EXTEND_MASK (1 << IEEE80211_RADIOTAP_EXT)
454 #define IEEE80211_RADIOTAP_F_CFP 0x01
464 #define IEEE80211_RADIOTAP_F_SHORTPRE 0x02
474 #define IEEE80211_RADIOTAP_F_WEP 0x04
484 #define IEEE80211_RADIOTAP_F_FRAG 0x08
494 #define IEEE80211_RADIOTAP_F_FCS 0x10
505 #define IEEE80211_RADIOTAP_F_DATAPAD 0x20
512 #define IEEE80211_RADIOTAP_F_RX_BADFCS 0x0001
518 #define IEEE80211_RADIOTAP_F_TX_FAIL 0x0001
524 #define IEEE80211_RADIOTAP_F_TX_CTS 0x0002
530 #define IEEE80211_RADIOTAP_F_TX_RTS 0x0004
536 #define IEEE80211_RADIOTAP_F_TX_NOACK 0x0008
542 #define IEEE80211_RADIOTAP_F_TX_NOSEQ 0x0010
623 #define IEEE80211_RADIOTAP_OUR_TRANSMISSION_HEADER_MASK ((1 \
625 IEEE80211_RADIOTAP_RATE) \
628 IEEE80211_RADIOTAP_TX_FLAGS))
704 char iface[IFNAMSIZ];
755 #define ALIGN_FACTOR 8
760 #define MIN_BUFFER_SIZE sizeof(struct GNUNET_MessageHeader)
828 fprintf (stderr,
"Failed to allocate buffer for tokenizer\n");
832 if (NULL ==
ret->hdr)
834 fprintf (stderr,
"Failed to allocate buffer for alignment\n");
863 unsigned long offset;
867 ibuf = (
char *) mst->
hdr;
876 memmove (ibuf, &ibuf[mst->
off], mst->
pos);
894 want = ntohs (hdr->
size);
898 "Received invalid message from stdin\n");
905 memmove (ibuf, &ibuf[mst->
off], mst->
pos);
910 mst->
hdr = realloc (mst->
hdr, want);
911 if (NULL == mst->
hdr)
913 fprintf (stderr,
"Failed to allocate buffer for alignment\n");
916 ibuf = (
char *) mst->
hdr;
920 if (mst->
pos - mst->
off < want)
928 if (mst->
pos - mst->
off < want)
945 offset = (
unsigned long)
buf;
951 want = ntohs (hdr->
size);
955 "Received invalid message from stdin\n");
976 if (NULL == mst->
hdr)
978 fprintf (stderr,
"Failed to allocate buffer for alignment\n");
981 ibuf = (
char *) mst->
hdr;
987 "Assertion failed\n");
1040 (radiotap_header == NULL))
1053 iterator->rtheader = radiotap_header;
1056 iterator->arg = ((uint8_t *) radiotap_header) +
sizeof(
struct
1114 static const uint8_t rt_sizes[] = {
1143 while (
iterator->arg_index <
sizeof(rt_sizes))
1145 int hit = (0 != (
iterator->bitmap_shifter & 1));
1149 unsigned int wanted_alignment;
1150 unsigned int unalignment;
1173 wanted_alignment = rt_sizes[
iterator->arg_index] >> 4;
1175 & (wanted_alignment - 1);
1176 if (0 != unalignment)
1179 iterator->arg_index += wanted_alignment - unalignment;
1206 if (0 == (
iterator->arg_index % 32))
1209 if (0 != (
iterator->bitmap_shifter & 1))
1218 iterator->arg_index =
sizeof(rt_sizes);
1245 static unsigned long
1248 static const unsigned long int crc_tbl_osdep[256] = {
1249 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F,
1250 0xE963A535, 0x9E6495A3,
1251 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD,
1252 0xE7B82D07, 0x90BF1D91,
1253 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB,
1254 0xF4D4B551, 0x83D385C7,
1255 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9,
1256 0xFA0F3D63, 0x8D080DF5,
1257 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447,
1258 0xD20D85FD, 0xA50AB56B,
1259 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75,
1260 0xDCD60DCF, 0xABD13D59,
1261 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423,
1262 0xCFBA9599, 0xB8BDA50F,
1263 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11,
1264 0xC1611DAB, 0xB6662D3D,
1265 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F,
1266 0x9FBFE4A5, 0xE8B8D433,
1267 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D,
1268 0x91646C97, 0xE6635C01,
1269 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B,
1270 0x8208F4C1, 0xF50FC457,
1271 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49,
1272 0x8CD37CF3, 0xFBD44C65,
1273 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7,
1274 0xA4D1C46D, 0xD3D6F4FB,
1275 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5,
1276 0xAA0A4C5F, 0xDD0D7CC9,
1277 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3,
1278 0xB966D409, 0xCE61E49F,
1279 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81,
1280 0xB7BD5C3B, 0xC0BA6CAD,
1281 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF,
1282 0x04DB2615, 0x73DC1683,
1283 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D,
1284 0x0A00AE27, 0x7D079EB1,
1285 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB,
1286 0x196C3671, 0x6E6B06E7,
1287 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9,
1288 0x17B7BE43, 0x60B08ED5,
1289 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767,
1290 0x3FB506DD, 0x48B2364B,
1291 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55,
1292 0x316E8EEF, 0x4669BE79,
1293 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703,
1294 0x220216B9, 0x5505262F,
1295 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31,
1296 0x2CD99E8B, 0x5BDEAE1D,
1297 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F,
1298 0x72076785, 0x05005713,
1299 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D,
1300 0x7CDCEFB7, 0x0BDBDF21,
1301 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B,
1302 0x6FB077E1, 0x18B74777,
1303 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69,
1304 0x616BFFD3, 0x166CCF45,
1305 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7,
1306 0x4969474D, 0x3E6E77DB,
1307 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5,
1308 0x47B2CF7F, 0x30B5FFE9,
1309 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693,
1310 0x54DE5729, 0x23D967BF,
1311 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1,
1312 0x5A05DF1B, 0x2D02EF8D
1315 unsigned long crc = 0xFFFFFFFF;
1318 crc = crc_tbl_osdep[(crc ^ *
buf) & 0xFF] ^ (crc >> 8);
1338 if ((((crc) & 0xFF) ==
buf[0]) && (((crc >> 8) & 0xFF) ==
buf[1]) &&
1339 ( ((crc >> 16) & 0xFF) ==
buf[2]) && ( ((crc >> 24) & 0xFF) ==
buf[3]) )
1359 if ((frequency >= 2412) && (frequency <= 2472))
1360 return (frequency - 2407) / 5;
1361 if (frequency == 2484)
1363 if ((frequency >= 5000) && (frequency <= 6100))
1364 return (frequency - 5000) / 5;
1381 memset (&wrq, 0,
sizeof(
struct iwreq));
1382 strncpy (wrq.ifr_name, dev->
iface, IFNAMSIZ);
1383 if (0 > ioctl (dev->
fd_raw, SIOCGIWFREQ, &wrq))
1385 frequency = wrq.u.freq.m;
1386 if (100000000 < frequency)
1387 frequency /= 100000;
1388 else if (1000000 < frequency)
1390 if (1000 < frequency)
1409 unsigned char *
buf,
size_t buf_size,
1412 unsigned char tmpbuf[buf_size];
1417 int got_channel = 0;
1418 int fcs_removed = 0;
1420 caplen = read (dev->
fd_raw, tmpbuf, buf_size);
1423 if (EAGAIN == errno)
1425 fprintf (stderr,
"Failed to read from RAW socket: %s\n", strerror (errno));
1429 memset (ri, 0,
sizeof(*ri));
1438 if ((n < 8) || (n >= caplen))
1448 pos = (
const char *) &
ph[1];
1493 if ((n < 8) || (n >= caplen))
1566 uint8_t flags = *
iterator.this_arg;
1571 caplen -=
sizeof(uint32_t);
1578 uint16_t flags = ntohs (*((uint16_t *)
iterator.this_arg));
1597 tmpbuf +
sizeof(
struct
1599 caplen -
sizeof(
struct
1614 if ((0 == fcs_removed) &&
1620 caplen -=
sizeof(uint32_t);
1644 struct packet_mreq mr;
1645 struct sockaddr_ll sll;
1648 memset (&ifr, 0,
sizeof(ifr));
1649 strncpy (ifr.ifr_name, dev->
iface, IFNAMSIZ);
1650 if (-1 == ioctl (dev->
fd_raw, SIOCGIFINDEX, &ifr))
1652 fprintf (stderr,
"ioctl(SIOCGIFINDEX) on interface `%.*s' failed: %s\n",
1653 IFNAMSIZ, dev->
iface, strerror (errno));
1658 memset (&sll, 0,
sizeof(sll));
1659 sll.sll_family = AF_PACKET;
1660 sll.sll_ifindex = ifr.ifr_ifindex;
1661 sll.sll_protocol = htons (ETH_P_ALL);
1662 if (-1 == ioctl (dev->
fd_raw, SIOCGIFHWADDR, &ifr))
1664 fprintf (stderr,
"ioctl(SIOCGIFHWADDR) on interface `%.*s' failed: %s\n",
1665 IFNAMSIZ, dev->
iface, strerror (errno));
1674 "Error: interface `%.*s' is not using a supported hardware address family (got %d)\n",
1675 IFNAMSIZ, dev->
iface,
1676 ifr.ifr_hwaddr.sa_family);
1681 memset (&wrq, 0,
sizeof(
struct iwreq));
1682 strncpy (wrq.ifr_name, dev->
iface, IFNAMSIZ);
1683 if (-1 == ioctl (dev->
fd_raw, SIOCGIWMODE, &wrq))
1687 wrq.u.mode = IW_MODE_MONITOR;
1690 if ((wrq.u.mode != IW_MODE_MONITOR) &&
1691 (wrq.u.mode != IW_MODE_ADHOC))
1694 "Error: interface `%.*s' is not in monitor or ad-hoc mode (got %d)\n",
1695 IFNAMSIZ, dev->
iface,
1701 if ((ifr.ifr_flags | IFF_UP | IFF_BROADCAST | IFF_RUNNING) != ifr.ifr_flags)
1704 ifr.ifr_flags |= IFF_UP | IFF_BROADCAST | IFF_RUNNING;
1706 if (-1 == ioctl (dev->
fd_raw, SIOCSIFFLAGS, &ifr))
1708 fprintf (stderr,
"ioctl(SIOCSIFFLAGS) on interface `%.*s' failed: %s\n",
1709 IFNAMSIZ, dev->
iface, strerror (errno));
1715 if (-1 == bind (dev->
fd_raw, (
struct sockaddr *) &sll,
sizeof(sll)))
1717 fprintf (stderr,
"Failed to bind interface `%.*s': %s\n", IFNAMSIZ,
1718 dev->
iface, strerror (errno));
1723 if (-1 == ioctl (dev->
fd_raw, SIOCGIFHWADDR, &ifr))
1725 fprintf (stderr,
"ioctl(SIOCGIFHWADDR) on interface `%.*s' failed: %s\n",
1726 IFNAMSIZ, dev->
iface, strerror (errno));
1737 fprintf (stderr,
"Unsupported hardware link type %d on interface `%.*s'\n",
1738 ifr.ifr_hwaddr.sa_family, IFNAMSIZ, dev->
iface);
1743 memset (&mr, 0,
sizeof(mr));
1744 mr.mr_ifindex = sll.sll_ifindex;
1745 mr.mr_type = PACKET_MR_PROMISC;
1747 setsockopt (dev->
fd_raw, SOL_PACKET, PACKET_ADD_MEMBERSHIP, &mr,
1751 "Failed to enable promiscuous mode on interface `%.*s'\n",
1774 ret = snprintf (strbuf,
sizeof(strbuf),
1775 "/sys/class/net/%s/phy80211/subsystem",
1777 if ((
ret < 0) || (
ret >=
sizeof(strbuf)) || (0 != stat (strbuf, &sbuf)))
1780 "Did not find 802.11 interface `%s'. Exiting.\n",
1848 sendsize = ntohs (hdr->
size);
1853 fprintf (stderr,
"Received malformed message\n");
1860 fprintf (stderr,
"Packet too big for buffer\n");
1880 wlanheader = (
struct
1895 etheader.
type = htons (ETH_P_IP);
1906 "Unsupported ARPTYPE!\n");
1936 #ifdef HAVE_SETRESUID
1937 uid_t uid = getuid ();
1939 if (0 != setresuid (uid, 0, 0))
1942 "Failed to setresuid to root: %s\n",
1947 if (0 != seteuid (0))
1950 "Failed to seteuid back to root: %s\n", strerror (errno));
1957 memset (&dev, 0,
sizeof(dev));
1958 dev.
fd_raw = socket (PF_PACKET, SOCK_RAW, htons (ETH_P_ALL));
1965 "You must specify the name of the interface as the first and only argument to this program.\n");
1967 (void) close (dev.
fd_raw);
1973 fprintf (stderr,
"Failed to create raw socket: %s\n", strerror (raw_eno));
1976 if (dev.
fd_raw >= FD_SETSIZE)
1978 fprintf (stderr,
"File descriptor too large for select (%d > %d)\n",
1980 (void) close (dev.
fd_raw);
1985 (void) close (dev.
fd_raw);
1988 memcpy (dev.
iface, argv[1], IFNAMSIZ);
1991 (void) close (dev.
fd_raw);
1997 uid_t uid = getuid ();
1998 #ifdef HAVE_SETRESUID
1999 if (0 != setresuid (uid, uid, uid))
2001 fprintf (stderr,
"Failed to setresuid: %s\n", strerror (errno));
2003 (void) close (dev.
fd_raw);
2007 if (0 != (setuid (uid) | seteuid (uid)))
2009 fprintf (stderr,
"Failed to setuid: %s\n", strerror (errno));
2011 (void) close (dev.
fd_raw);
2022 macmsg.
hdr.
size = htons (
sizeof(macmsg));
2038 FD_SET (STDIN_FILENO, &rfds);
2039 maxfd = MAX (maxfd, STDIN_FILENO);
2043 FD_SET (dev.
fd_raw, &rfds);
2044 maxfd = MAX (maxfd, dev.
fd_raw);
2049 FD_SET (STDOUT_FILENO, &wfds);
2050 maxfd = MAX (maxfd, STDOUT_FILENO);
2054 FD_SET (dev.
fd_raw, &wfds);
2055 maxfd = MAX (maxfd, dev.
fd_raw);
2058 int retval = select (maxfd + 1, &rfds, &wfds, NULL, NULL);
2059 if ((-1 == retval) && (EINTR == errno))
2063 fprintf (stderr,
"select failed: %s\n", strerror (errno));
2067 if (FD_ISSET (STDOUT_FILENO, &wfds))
2074 fprintf (stderr,
"Failed to write to STDOUT: %s\n", strerror (errno));
2084 if (FD_ISSET (dev.
fd_raw, &wfds))
2091 fprintf (stderr,
"Failed to write to WLAN device: %s\n",
2099 fprintf (stderr,
"Write error, partial send: %u/%u\n",
2111 if (FD_ISSET (STDIN_FILENO, &rfds))
2114 read (STDIN_FILENO, readbuf,
sizeof(readbuf));
2117 fprintf (stderr,
"Read error from STDIN: %s\n", strerror (errno));
2128 if (FD_ISSET (dev.
fd_raw, &rfds))
2144 fprintf (stderr,
"Read error from raw socket: %s\n", strerror (errno));
2160 (void) close (dev.
fd_raw);
static size_t do_align(size_t start_position, size_t end_position)
Given the start and end position of a block of data, return the end position of that data after align...
static int ret
Return value of the commandline.
static struct GNUNET_ATS_PerformanceHandle * ph
ATS performance handle used.
struct GNUNET_MessageStreamTokenizer * stdin_mst
Tokenizer for the data we get from stdin.
#define PRISM_DID_CHANNEL
Channel element.
#define MIN_BUFFER_SIZE
Smallest supported message.
static struct SendBuffer write_std
Buffer for data read from the wireless card to be transmitted to stdout.
static struct SendBuffer write_pout
Buffer for data read from stdin to be transmitted to the wirless card.
#define ALIGN_FACTOR
To what multiple do we align messages? 8 byte should suffice for everyone for now.
int main(int argc, char *argv[])
Main function of the helper.
#define IEEE80211_RADIOTAP_F_RX_BADFCS
For IEEE80211_RADIOTAP_RX_FLAGS: frame failed crc check.
#define IEEE80211_RADIOTAP_F_TX_NOSEQ
For IEEE80211_RADIOTAP_TX_FLAGS ('txflags' in 'struct RadiotapTransmissionHeader'): sequence number h...
static unsigned long calc_crc_osdep(const unsigned char *buf, size_t len)
Calculate crc32, the start of the calculation.
static int mac_test(const struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *taIeeeHeader, const struct HardwareInfos *dev)
Test incoming packets mac for being our own.
static void mac_set(struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame *taIeeeHeader, const struct HardwareInfos *dev)
Set the wlan header to sane values to make attacks more difficult.
void(* MessageTokenizerCallback)(void *cls, const struct GNUNET_MessageHeader *message)
Functions with this signature are called whenever a complete message is received by the tokenizer.
#define PRISM_DEVICE_NAME_LENGTH
Device name length in PRISM frames.
static int mst_receive(struct MessageStreamTokenizer *mst, const char *buf, size_t size)
Add incoming data to the receive buffer and call the callback for all complete messages.
#define MAXLINE
Maximum size of a message allowed in either direction (used for our receive and sent buffers).
#define PRISM_STATUS_OK
Value is set (supplied)
#define ARPHRD_IEEE80211_FULL
Packet format type for the messages we receive from the kernel.
#define PRISM_DID_SIGNAL
Signal element.
#define IEEE80211_RADIOTAP_OUR_TRANSMISSION_HEADER_MASK
The above 'struct RadiotapTransmissionHeader' should have the following value for 'header....
#define PRISM_DID_NOISE
Noise element.
static int ieee80211_radiotap_iterator_next(struct Ieee80211RadiotapHeaderIterator *iterator)
Returns the next radiotap parser iterator arg.
static int ieee80211_radiotap_iterator_init(struct Ieee80211RadiotapHeaderIterator *iterator, const struct Ieee80211RadiotapHeader *radiotap_header, size_t max_length)
Radiotap header iteration.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
RadiotapType
Bits in the 'it_present' bitmask from the 'struct Ieee80211RadiotapHeader'.
@ IEEE80211_RADIOTAP_DB_TX_ATTENUATION
IEEE80211_RADIOTAP_DB_TX_ATTENUATION __le16 decibels (dB)
@ IEEE80211_RADIOTAP_EXT
Extension bit, used to indicate that more bits are needed for the bitmask.
@ IEEE80211_RADIOTAP_DATA_RETRIES
IEEE80211_RADIOTAP_DATA_RETRIES uint8_t data.
@ IEEE80211_RADIOTAP_DBM_TX_POWER
IEEE80211_RADIOTAP_DBM_TX_POWER s8 decibels from one milliwatt (dBm)
@ IEEE80211_RADIOTAP_TX_FLAGS
IEEE80211_RADIOTAP_TX_FLAGS __le16 bitmap.
@ IEEE80211_RADIOTAP_RTS_RETRIES
IEEE80211_RADIOTAP_RTS_RETRIES uint8_t data.
@ IEEE80211_RADIOTAP_LOCK_QUALITY
IEEE80211_RADIOTAP_LOCK_QUALITY __le16 unitless.
@ IEEE80211_RADIOTAP_CHANNEL
IEEE80211_RADIOTAP_CHANNEL 2 x __le16 MHz, bitmap.
@ IEEE80211_RADIOTAP_FLAGS
IEEE80211_RADIOTAP_FLAGS uint8_t bitmap.
@ IEEE80211_RADIOTAP_TX_ATTENUATION
IEEE80211_RADIOTAP_TX_ATTENUATION __le16 unitless.
@ IEEE80211_RADIOTAP_DB_ANTNOISE
IEEE80211_RADIOTAP_DB_ANTNOISE uint8_t decibel (dB)
@ IEEE80211_RADIOTAP_DB_ANTSIGNAL
IEEE80211_RADIOTAP_DB_ANTSIGNAL uint8_t decibel (dB)
@ IEEE80211_RADIOTAP_TSFT
IEEE80211_RADIOTAP_TSFT __le64 microseconds.
@ IEEE80211_RADIOTAP_RATE
IEEE80211_RADIOTAP_RATE uint8_t 500kb/s.
@ IEEE80211_RADIOTAP_FHSS
IEEE80211_RADIOTAP_FHSS __le16 see below.
@ IEEE80211_RADIOTAP_DBM_ANTNOISE
IEEE80211_RADIOTAP_DBM_ANTNOISE s8 decibels from one milliwatt (dBm)
@ IEEE80211_RADIOTAP_ANTENNA
IEEE80211_RADIOTAP_ANTENNA uint8_t antenna index.
@ IEEE80211_RADIOTAP_DBM_ANTSIGNAL
IEEE80211_RADIOTAP_DBM_ANTSIGNAL s8 decibels from one milliwatt (dBm)
@ IEEE80211_RADIOTAP_RX_FLAGS
IEEE80211_RADIOTAP_RX_FLAGS __le16 bitmap.
static void mst_destroy(struct MessageStreamTokenizer *mst)
Destroys a tokenizer.
#define ARPHRD_ETHER
Packet format type for the messages we receive from the kernel.
#define ARPHRD_IEEE80211_PRISM
Packet format type for the messages we receive from the kernel.
static int linux_get_channel(const struct HardwareInfos *dev)
Get the channel used by our WLAN interface.
static int open_device_raw(struct HardwareInfos *dev)
Open the wireless network interface for reading/writing.
static int check_crc_buf_osdep(const unsigned char *buf, size_t len)
Calculate and check crc of the wlan packet.
#define IEEE80211_RADIOTAP_PRESENT_EXTEND_MASK
Bitmask indicating an extension of the bitmask is used.
static struct MessageStreamTokenizer * mst_create(MessageTokenizerCallback cb, void *cb_cls)
Create a message stream tokenizer.
#define IEEE80211_RADIOTAP_F_FCS
Bit in IEEE80211_RADIOTAP_FLAGS (which we might get as part of a 'struct Ieee80211RadiotapHeader' ext...
#define ARPHRD_IEEE80211
Packet format type for the messages we receive from the kernel.
enum RadiotapType __attribute__
#define IEEE80211_RADIOTAP_F_TX_NOACK
For IEEE80211_RADIOTAP_TX_FLAGS ('txflags' in 'struct RadiotapTransmissionHeader'): frame should not ...
static int get_channel_from_frequency(int32_t frequency)
Return the channel from the frequency (in Mhz)
static void stdin_send_hw(void *cls, const struct GNUNET_MessageHeader *hdr)
Process data from the stdin.
static int test_wlan_interface(const char *iface)
Test if the given interface name really corresponds to a wireless device.
static ssize_t linux_read(struct HardwareInfos *dev, unsigned char *buf, size_t buf_size, struct GNUNET_TRANSPORT_WLAN_RadiotapReceiveMessage *ri)
Read from the raw socket (the wlan card), parse the packet and put the result into the buffer for tra...
#define PRISM_DID_MACTIME
Mac time element.
#define PRISM_MSGCODE_MONITOR
Monitor Frame (indicator that we have a 'struct PrismHeader').
#define PRISM_DID_RATE
Rate element, in units/multiples of 500Khz.
static struct GNUNET_PeerIdentity all_zeros
Peer identity that is all zeros, used as a way to indicate "all peers".
#define IEEE80211_FC0_TYPE_DATA
Constants for network protocols.
static int iterator(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Iterator over hash map entries.
#define GNUNET_le32toh(x)
#define GNUNET_le16toh(x)
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_le64toh(x)
#define GNUNET_htole16(x)
#define GNUNET_MESSAGE_TYPE_WLAN_DATA_TO_HELPER
Type of data messages from the plugin to the gnunet-wlan-helper.
#define GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL
Control message between the gnunet-wlan-helper and the daemon (with the MAC).
#define GNUNET_MESSAGE_TYPE_WLAN_DATA_FROM_HELPER
Type of data messages from the gnunet-wlan-helper to the plugin.
static unsigned int size
Size of the "table".
header for transport plugin and the helper for wlan
static GNUNET_NETWORK_STRUCT_END const struct GNUNET_TRANSPORT_WLAN_MacAddress mac_bssid_gnunet
GNUnet bssid.
static const struct GNUNET_TRANSPORT_WLAN_MacAddress bc_all_mac
Broadcast MAC.
#define MAC_ADDR_SIZE
Number fo bytes in a mac address.
static struct GNUNET_TIME_Relative delta
Format of a WLAN Control Message.
struct GNUNET_MessageHeader hdr
Message header.
struct GNUNET_TRANSPORT_WLAN_MacAddress mac
MAC Address of the local WLAN interface.
generic definitions for IEEE 802.11 frames
uint16_t frame_control
802.11 Frame Control field.
struct GNUNET_TRANSPORT_WLAN_MacAddress addr1
Address 1: destination address in ad-hoc mode or AP, BSSID if station,.
struct GNUNET_TRANSPORT_WLAN_MacAddress addr3
Address 3: BSSID in ad-hoc mode, Destination if station, source if AP.
struct GNUNET_TRANSPORT_WLAN_MacAddress addr2
Address 2: source address if in ad-hoc-mode or station, BSSID if AP.
generic definitions for IEEE 802.3 frames
uint16_t type
Packet type ID.
struct GNUNET_TRANSPORT_WLAN_MacAddress src
Address 2: source address if in ad-hoc-mode or station, BSSID if AP.
struct GNUNET_TRANSPORT_WLAN_MacAddress dst
Address 1: destination address in ad-hoc mode or AP, BSSID if station,.
Message from the WLAN helper to the plugin: we have received the given message with the given perform...
uint32_t ri_channel
IEEE80211_RADIOTAP_CHANNEL, 0 if unknown.
struct GNUNET_TRANSPORT_WLAN_Ieee80211Frame frame
IEEE Frame.
uint64_t ri_mactime
IEEE80211_RADIOTAP_TSFT, 0 if unknown.
uint32_t ri_antenna
IEEE80211_RADIOTAP_ANTENNA, 0 if unknown.
int32_t ri_noise
either IEEE80211_RADIOTAP_DBM_ANTNOISE or IEEE80211_RADIOTAP_DB_ANTNOISE, 0 if unknown.
uint32_t ri_rate
IEEE80211_RADIOTAP_RATE * 50000, 0 if unknown.
struct GNUNET_MessageHeader header
Type is 'GNUNET_MESSAGE_TYPE_WLAN_DATA_FROM_HELPER'.
int32_t ri_power
from radiotap either IEEE80211_RADIOTAP_DBM_ANTSIGNAL or IEEE80211_RADIOTAP_DB_ANTSIGNAL,...
Message from the plugin to the WLAN helper: send the given message with the given connection paramete...
struct GNUNET_MessageHeader header
Type is 'GNUNET_MESSAGE_TYPE_WLAN_DATA_TO_HELPER'.
struct for storing the information of the hardware.
char iface[IFNAMSIZ]
Name of the interface, not necessarily 0-terminated (!).
int fd_raw
file descriptor for the raw socket
int arptype_in
Which format has the header that we're getting when receiving packets? Some ARPHRD_IEEE80211_XXX-valu...
struct GNUNET_TRANSPORT_WLAN_MacAddress pl_mac
MAC address of our own bluetooth interface.
Handle to a message stream tokenizer.
void * cb_cls
Closure for cb.
struct GNUNET_MessageHeader * hdr
Beginning of the buffer.
MessageTokenizerCallback cb
Function to call on completed messages.
size_t curr_buf
Size of the buffer (starting at 'hdr').
size_t pos
How many bytes in buffer are valid right now?
size_t off
How many bytes in buffer have we already processed?
Values in the 'struct PrismHeader'.
uint32_t data
The data value.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
uint32_t did
This has a different ID for each parameter, see PRISM_DID_* constants.
uint16_t status
See PRISM_STATUS_*-constants.
IO buffer used for buffering data in transit (to wireless or to stdout).
size_t pos
How many bytes that were stored in 'buf' did we already write to the destination? Always smaller than...
size_t size
How many bytes of data are stored in 'buf' for transmission right now? Data always starts at offset 0...
char buf[4096 *2]
Buffered data; twice the maximum allowed message size as we add some headers.