2 This file is part of GNUnet.
3 (C) 2010 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file src/transport/gnunet-transport-wlan-helper.c
23 * @brief wlan layer two server; must run as root (SUID will do)
24 * This code will work under GNU/Linux only.
25 * @author David Brodski
27 * This program serves as the mediator between the wlan interface and
33 #include "gnunet_constants.h"
34 #include "gnunet_os_lib.h"
35 #include "gnunet_transport_plugin.h"
36 #include "transport.h"
37 #include "gnunet_util_lib.h"
38 #include "plugin_transport_wlan.h"
39 #include "gnunet_common.h"
40 #include "gnunet-transport-wlan-helper.h"
41 #include "ieee80211_radiotap.h"
51 //#include "radiotap.h"
55 { 0x13, 0x22, 0x33, 0x44, 0x55, 0x66 };
57 /* wifi bitrate to use in 500kHz units */
59 static const u8 u8aRatesToUse[] = {
74 #define OFFSET_FLAGS 0x10
75 #define OFFSET_RATE 0x11
77 // this is where we store a summary of the
78 // information from the radiotap header
86 } __attribute__((packed)) PENUMBRA_RADIOTAP_DATA;
89 Dump(u8 * pu8, int nLength)
91 char sz[256], szBuf[512], szChar[17], *buf, fFirst = 1;
92 unsigned char baaLast[2][16];
93 uint n, nPos = 0, nStart = 0, nLine = 0, nSameCount = 0;
98 for (n = 0; n < nLength; n++) {
99 baaLast[(nLine&1)^1][n&0xf] = pu8[n];
100 if ((pu8[n] < 32) || (pu8[n] >= 0x7f))
103 szChar[n&0xf] = pu8[n];
104 szChar[(n&0xf)+1] = '\0';
105 nPos += sprintf(&sz[nPos], "%02X ",
106 baaLast[(nLine&1)^1][n&0xf]);
109 if ((memcmp(baaLast[0], baaLast[1], 16) == 0) && (!fFirst)) {
113 buf += sprintf(buf, "(repeated %d times)\n",
115 buf += sprintf(buf, "%04x: %s %s\n",
121 nPos = 0; nStart = n+1; nLine++;
122 fFirst = 0; sz[0] = '\0'; szChar[0] = '\0';
125 buf += sprintf(buf, "(repeated %d times)\n", nSameCount);
127 buf += sprintf(buf, "%04x: %s", nStart, sz);
131 buf += sprintf(buf, " ");
135 buf += sprintf(buf, "%s\n", szChar);
144 "Usage: wlan-hwd [options] <interface>\n\nOptions\n"
145 "-f/--fcs Mark as having FCS (CRC) already\n"
146 " (pkt ends with 4 x sacrificial - chars)\n"
148 " echo -n mon0 > /sys/class/ieee80211/phy0/add_iface\n"
149 " iwconfig mon0 mode monitor\n"
150 " ifconfig mon0 up\n"
151 " wlan-hwd mon0 Spam down mon0 with\n"
152 " radiotap header first\n"
157 int flagHelp = 0, flagMarkWithFCS = 0;
164 * Copyright 2007 Andy Green <andy@warmcat.com>
168 * ieee80211_radiotap_iterator_init - radiotap parser iterator initialization
169 * @param iterator: radiotap_iterator to initialize
170 * @param radiotap_header: radiotap header to parse
171 * @param max_length: total length we can parse into (eg, whole packet length)
173 * @return 0 or a negative error code if there is a problem.
175 * This function initializes an opaque iterator struct which can then
176 * be passed to ieee80211_radiotap_iterator_next() to visit every radiotap
177 * argument which is present in the header. It knows about extended
178 * present headers and handles them.
181 * call __ieee80211_radiotap_iterator_init() to init a semi-opaque iterator
182 * struct ieee80211_radiotap_iterator (no need to init the struct beforehand)
183 * checking for a good 0 return code. Then loop calling
184 * __ieee80211_radiotap_iterator_next()... it returns either 0,
185 * -ENOENT if there are no more args to parse, or -EINVAL if there is a problem.
186 * The iterator's this_arg member points to the start of the argument
187 * associated with the current argument index that is present, which can be
188 * found in the iterator's this_arg_index member. This arg index corresponds
189 * to the IEEE80211_RADIOTAP_... defines.
191 * Radiotap header length:
192 * You can find the CPU-endian total radiotap header length in
193 * iterator->max_length after executing ieee80211_radiotap_iterator_init()
197 * See Documentation/networking/radiotap-headers.txt
200 int ieee80211_radiotap_iterator_init(
201 struct ieee80211_radiotap_iterator *iterator,
202 struct ieee80211_radiotap_header *radiotap_header,
205 /* Linux only supports version 0 radiotap format */
206 if (radiotap_header->it_version)
209 /* sanity check for allowed length and radiotap length field */
210 if (max_length < le16_to_cpu(radiotap_header->it_len))
213 iterator->rtheader = radiotap_header;
214 iterator->max_length = le16_to_cpu(radiotap_header->it_len);
215 iterator->arg_index = 0;
216 iterator->bitmap_shifter = le32_to_cpu(radiotap_header->it_present);
217 iterator->arg = (u8 *)radiotap_header + sizeof(*radiotap_header);
218 iterator->this_arg = 0;
220 /* find payload start allowing for extended bitmap(s) */
222 if (unlikely(iterator->bitmap_shifter & (1<<IEEE80211_RADIOTAP_EXT))) {
223 while (le32_to_cpu(*((u32 *)iterator->arg)) &
224 (1<<IEEE80211_RADIOTAP_EXT)) {
225 iterator->arg += sizeof(u32);
228 * check for insanity where the present bitmaps
229 * keep claiming to extend up to or even beyond the
230 * stated radiotap header length
233 if (((ulong)iterator->arg -
234 (ulong)iterator->rtheader) > iterator->max_length)
238 iterator->arg += sizeof(u32);
241 * no need to check again for blowing past stated radiotap
242 * header length, because ieee80211_radiotap_iterator_next
243 * checks it before it is dereferenced
247 /* we are all initialized happily */
254 * ieee80211_radiotap_iterator_next - return next radiotap parser iterator arg
255 * @param iterator: radiotap_iterator to move to next arg (if any)
257 * @return 0 if there is an argument to handle,
258 * -ENOENT if there are no more args or -EINVAL
259 * if there is something else wrong.
261 * This function provides the next radiotap arg index (IEEE80211_RADIOTAP_*)
262 * in this_arg_index and sets this_arg to point to the
263 * payload for the field. It takes care of alignment handling and extended
264 * present fields. this_arg can be changed by the caller (eg,
265 * incremented to move inside a compound argument like
266 * IEEE80211_RADIOTAP_CHANNEL). The args pointed to are in
267 * little-endian format whatever the endianess of your CPU.
270 int ieee80211_radiotap_iterator_next(
271 struct ieee80211_radiotap_iterator *iterator)
275 * small length lookup table for all radiotap types we heard of
276 * starting from b0 in the bitmap, so we can walk the payload
277 * area of the radiotap header
279 * There is a requirement to pad args, so that args
280 * of a given length must begin at a boundary of that length
281 * -- but note that compound args are allowed (eg, 2 x u16
282 * for IEEE80211_RADIOTAP_CHANNEL) so total arg length is not
283 * a reliable indicator of alignment requirement.
285 * upper nybble: content alignment for arg
286 * lower nybble: content length for arg
289 static const u8 rt_sizes[] = {
290 [IEEE80211_RADIOTAP_TSFT] = 0x88,
291 [IEEE80211_RADIOTAP_FLAGS] = 0x11,
292 [IEEE80211_RADIOTAP_RATE] = 0x11,
293 [IEEE80211_RADIOTAP_CHANNEL] = 0x24,
294 [IEEE80211_RADIOTAP_FHSS] = 0x22,
295 [IEEE80211_RADIOTAP_DBM_ANTSIGNAL] = 0x11,
296 [IEEE80211_RADIOTAP_DBM_ANTNOISE] = 0x11,
297 [IEEE80211_RADIOTAP_LOCK_QUALITY] = 0x22,
298 [IEEE80211_RADIOTAP_TX_ATTENUATION] = 0x22,
299 [IEEE80211_RADIOTAP_DB_TX_ATTENUATION] = 0x22,
300 [IEEE80211_RADIOTAP_DBM_TX_POWER] = 0x11,
301 [IEEE80211_RADIOTAP_ANTENNA] = 0x11,
302 [IEEE80211_RADIOTAP_DB_ANTSIGNAL] = 0x11,
303 [IEEE80211_RADIOTAP_DB_ANTNOISE] = 0x11
305 * add more here as they are defined in
306 * include/net/ieee80211_radiotap.h
311 * for every radiotap entry we can at
312 * least skip (by knowing the length)...
315 while (iterator->arg_index < sizeof(rt_sizes)) {
319 if (!(iterator->bitmap_shifter & 1))
320 goto next_entry; /* arg not present */
323 * arg is present, account for alignment padding
324 * 8-bit args can be at any alignment
325 * 16-bit args must start on 16-bit boundary
326 * 32-bit args must start on 32-bit boundary
327 * 64-bit args must start on 64-bit boundary
329 * note that total arg size can differ from alignment of
330 * elements inside arg, so we use upper nybble of length
331 * table to base alignment on
333 * also note: these alignments are ** relative to the
334 * start of the radiotap header **. There is no guarantee
335 * that the radiotap header itself is aligned on any
339 pad = (((ulong)iterator->arg) -
340 ((ulong)iterator->rtheader)) &
341 ((rt_sizes[iterator->arg_index] >> 4) - 1);
344 iterator->arg_index +=
345 (rt_sizes[iterator->arg_index] >> 4) - pad;
348 * this is what we will return to user, but we need to
349 * move on first so next call has something fresh to test
351 iterator->this_arg_index = iterator->arg_index;
352 iterator->this_arg = iterator->arg;
355 /* internally move on the size of this arg */
356 iterator->arg += rt_sizes[iterator->arg_index] & 0x0f;
359 * check for insanity where we are given a bitmap that
360 * claims to have more arg content than the length of the
361 * radiotap section. We will normally end up equalling this
362 * max_length on the last arg, never exceeding it.
365 if (((ulong)iterator->arg - (ulong)iterator->rtheader) >
366 iterator->max_length)
370 iterator->arg_index++;
371 if (unlikely((iterator->arg_index & 31) == 0)) {
372 /* completed current u32 bitmap */
373 if (iterator->bitmap_shifter & 1) {
374 /* b31 was set, there is more */
375 /* move to next u32 bitmap */
376 iterator->bitmap_shifter =
377 le32_to_cpu(*iterator->next_bitmap);
378 iterator->next_bitmap++;
380 /* no more bitmaps: end */
381 iterator->arg_index = sizeof(rt_sizes);
383 } else { /* just try the next bit */
384 iterator->bitmap_shifter >>= 1;
387 /* if we found a valid arg earlier, return it now */
392 /* we don't know how to handle any more args, we're done */
396 #define FIFO_FILE1 "/tmp/MYFIFOin"
397 #define FIFO_FILE2 "/tmp/MYFIFOout"
401 static int closeprog;
414 char buf[MAXLINE * 2];
418 stdin_send (void *cls,
420 const struct GNUNET_MessageHeader *hdr)
422 struct sendbuf *write_pout = cls;
423 int sendsize = ntohs(hdr->size) - sizeof(struct RadiotapHeader) ;
424 struct GNUNET_MessageHeader newheader;
426 GNUNET_assert(GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA == ntohs(hdr->type));
427 GNUNET_assert (sendsize + write_pout->size < MAXLINE *2);
430 newheader.size = htons(sendsize);
431 newheader.type = htons(GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA);
434 memcpy(write_pout->buf + write_pout->size, &newheader, sizeof(struct GNUNET_MessageHeader));
435 write_pout->size += sizeof(struct GNUNET_MessageHeader);
437 memcpy(write_pout->buf + write_pout->size, hdr + sizeof(struct RadiotapHeader) + sizeof(struct GNUNET_MessageHeader), sizeof(struct GNUNET_MessageHeader));
438 write_pout->size += sendsize;
442 file_in_send (void *cls,
444 const struct GNUNET_MessageHeader *hdr)
446 struct sendbuf * write_std = cls;
447 int sendsize = ntohs(hdr->size);
449 GNUNET_assert(GNUNET_MESSAGE_TYPE_WLAN_HELPER_DATA == ntohs(hdr->type));
450 GNUNET_assert (sendsize + write_std->size < MAXLINE *2);
452 memcpy(write_std->buf + write_std->size, hdr, sendsize);
453 write_std->size += sendsize;
457 testmode(int argc, char *argv[])
468 //make the fifos if needed
469 if (0 != stat(FIFO_FILE1, &st))
471 if (0 == stat(FIFO_FILE2, &st))
473 fprintf(stderr, "FIFO_FILE2 exists, but FIFO_FILE1 not");
478 erg = mknod(FIFO_FILE1, S_IFIFO | 0666, 0);
479 erg = mknod(FIFO_FILE2, S_IFIFO | 0666, 0);
485 if (0 != stat(FIFO_FILE2, &st))
487 fprintf(stderr, "FIFO_FILE1 exists, but FIFO_FILE2 not");
493 if (strstr(argv[2], "1"))
495 //fprintf(stderr, "First\n");
497 fpin = fopen(FIFO_FILE1, "r");
500 fprintf(stderr, "fopen of read FIFO_FILE1");
503 if (NULL == (fpout = fopen(FIFO_FILE2, "w")))
505 fprintf(stderr, "fopen of write FIFO_FILE2");
513 //fprintf(stderr, "Second\n");
514 if (NULL == (fpout = fopen(FIFO_FILE1, "w")))
516 fprintf(stderr, "fopen of write FIFO_FILE1");
519 if (NULL == (fpin = fopen(FIFO_FILE2, "r")))
521 fprintf(stderr, "fopen of read FIFO_FILE2");
527 fdpin = fileno(fpin);
528 if (fdpin >= FD_SETSIZE)
530 fprintf(stderr, "File fdpin number too large (%d > %u)\n", fdpin,
531 (unsigned int) FD_SETSIZE);
536 fdpout = fileno(fpout);
537 if (fdpout >= FD_SETSIZE)
539 fprintf(stderr, "File fdpout number too large (%d > %u)\n", fdpout,
540 (unsigned int) FD_SETSIZE);
546 signal(SIGINT, &sigfunc);
547 signal(SIGTERM, &sigfunc);
549 char readbuf[MAXLINE];
551 struct sendbuf write_std;
555 struct sendbuf write_pout;
569 struct GNUNET_SERVER_MessageStreamTokenizer * stdin_mst;
570 struct GNUNET_SERVER_MessageStreamTokenizer * file_in_mst;
572 stdin_mst = GNUNET_SERVER_mst_create(&stdin_send, &write_pout);
573 file_in_mst = GNUNET_SERVER_mst_create(&file_in_send, &write_std);
577 struct Wlan_Helper_Control_Message macmsg;
579 //Send random mac address
580 macmsg.mac.mac[0] = 0x13;
581 macmsg.mac.mac[1] = 0x22;
582 macmsg.mac.mac[2] = 0x33;
583 macmsg.mac.mac[3] = 0x44;
584 macmsg.mac.mac[4] = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 255);
585 macmsg.mac.mac[5] = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, 255);
586 macmsg.hdr.size = htons(sizeof(struct Wlan_Helper_Control_Message));
587 macmsg.hdr.type = htons(GNUNET_MESSAGE_TYPE_WLAN_HELPER_CONTROL);
589 memcpy(&write_std.buf, &macmsg, sizeof(struct Wlan_Helper_Control_Message));
590 write_std.size = sizeof(struct Wlan_Helper_Control_Message);
596 retval = select(0, NULL, NULL, NULL, &tv);
601 // if there is something to write
603 FD_SET(STDOUT_FILENO, &wfds);
605 retval = select(STDOUT_FILENO + 1, NULL, &wfds, NULL, &tv);
607 if (FD_ISSET(STDOUT_FILENO, &wfds))
609 ret = write(STDOUT_FILENO, write_std.buf + write_std.pos, write_std.size
615 fprintf(stderr, "Write ERROR to STDOUT");
620 write_std.pos += ret;
622 if (write_std.pos == write_std.size)
630 memcpy(&write_std.buf, &macmsg, sizeof(struct Wlan_Helper_Control_Message));
631 write_std.size = sizeof(struct Wlan_Helper_Control_Message);
637 retval = select(0, NULL, NULL, NULL, &tv);
639 while (0 == closeprog)
649 // if output queue is empty
650 if (0 == write_pout.size)
652 FD_SET(STDIN_FILENO, &rfds);
655 if (0 == write_std.size)
657 FD_SET(fdpin, &rfds);
661 // if there is something to write
662 if (0 < write_std.size){
663 FD_SET(STDOUT_FILENO, &wfds);
664 maxfd = MAX(maxfd, STDOUT_FILENO);
667 if (0 < write_pout.size){
668 FD_SET(fdpout, &wfds);
669 maxfd = MAX(maxfd, fdpout);
673 retval = select(maxfd + 1, &rfds, &wfds, NULL, &tv);
675 if (-1 == retval && EINTR == errno)
681 fprintf(stderr, "select failed: %s\n", strerror(errno));
685 if (FD_ISSET(STDOUT_FILENO, &wfds))
687 ret = write(STDOUT_FILENO, write_std.buf + write_std.pos,
688 write_std.size - write_std.pos);
693 fprintf(stderr, "Write ERROR to STDOUT");
698 write_std.pos += ret;
700 if (write_std.pos == write_std.size)
708 if (FD_ISSET(fdpout, &wfds))
710 ret = write(fdpout, write_pout.buf + write_pout.pos, write_pout.size
716 fprintf(stderr, "Write ERROR to fdpout");
721 write_pout.pos += ret;
723 if (write_pout.pos == write_pout.size)
731 if (FD_ISSET(STDIN_FILENO, &rfds))
733 readsize = read(STDIN_FILENO, readbuf, sizeof(readbuf));
738 fprintf(stderr, "Read ERROR to STDIN_FILENO");
743 GNUNET_SERVER_mst_receive(stdin_mst, NULL, readbuf, readsize,
744 GNUNET_NO, GNUNET_NO);
749 if (FD_ISSET(fdpin, &rfds))
751 readsize = read(fdpin, readbuf, sizeof(readbuf));
756 fprintf(stderr, "Read ERROR to fdpin");
761 GNUNET_SERVER_mst_receive(file_in_mst, NULL, readbuf, readsize,
762 GNUNET_NO, GNUNET_NO);
784 main(int argc, char *argv[])
790 "This program must be started with the interface and the operating mode as argument.\n");
794 if (strstr(argv[2], "1") || strstr(argv[2], "2"))
797 return testmode(argc, argv);
801 u8 u8aSendBuffer[500];
802 char szErrbuf[PCAP_ERRBUF_SIZE];
803 int nCaptureHeaderLength = 0, n80211HeaderLength = 0, nLinkEncap = 0;
804 int nOrdinal = 0, r, nDelay = 100000;
805 int nRateIndex = 0, retval, bytes;
806 pcap_t *ppcap = NULL;
807 struct bpf_program bpfprogram;
808 char * szProgram = "", fBrokenSocket = 0;
810 char szHostname[PATH_MAX];
812 if (gethostname(szHostname, sizeof (szHostname) - 1)) {
813 perror("unable to get hostname");
815 szHostname[sizeof (szHostname) - 1] = '\0';
818 printf("Packetspammer (c)2007 Andy Green <andy@warmcat.com> GPL2\n");
822 static const struct option optiona[] = {
823 { "delay", required_argument, NULL, 'd' },
824 { "fcs", no_argument, &flagMarkWithFCS, 1 },
825 { "help", no_argument, &flagHelp, 1 },
826 { "verbose", no_argument, &flagVerbose, 1},
829 int c = getopt_long(argc, argv, "d:hf",
830 optiona, &nOptionIndex);
835 case 0: // long option
842 nDelay = atoi(optarg);
845 case 'f': // mark as FCS attached
849 case 'v': //Verbose / readable output to cout
854 printf("unknown switch %c\n", c);
864 // open the interface in pcap
867 ppcap = pcap_open_live(argv[optind], 800, 1, 20, szErrbuf);
869 printf("Unable to open interface %s in pcap: %s\n",
870 argv[optind], szErrbuf);
874 //get mac from interface
879 sock=socket(PF_INET, SOCK_STREAM, 0);
881 perror("can not open socket\n");
885 if (-1==ioctl(sock, SIOCGIFHWADDR, &ifr)) {
886 perror("ioctl(SIOCGIFHWADDR) ");
889 for (j=0, k=0; j<6; j++) {
890 k+=snprintf(mac+k, sizeof(mac)-k-1, j ? ":%02X" : "%02X",
891 (int)(unsigned int)(unsigned char)ifr.ifr_hwaddr.sa_data[j]);
893 mac[sizeof(mac)-1]='\0';
897 nLinkEncap = pcap_datalink(ppcap);
898 nCaptureHeaderLength = 0;home/mwachs/gnb/bin/
900 switch (nLinkEncap) {
902 case DLT_PRISM_HEADER:
903 printf("DLT_PRISM_HEADER Encap\n");
904 nCaptureHeaderLength = 0x40;
905 n80211HeaderLength = 0x20; // ieee80211 comes after this
906 szProgram = "radio[0x4a:4]==0x13223344";
909 case DLT_IEEE802_11_RADIO:
910 printf("DLT_IEEE802_11_RADIO Encap\n");
911 nCaptureHeaderLength = 0x40;
912 n80211HeaderLength = 0x18; // ieee80211 comes after this
913 szProgram = "ether[0x0a:4]==0x13223344";
917 printf("!!! unknown encapsulation on %s !\n", argv[1]);
922 if (pcap_compile(ppcap, &bpfprogram, szProgram, 1, 0) == -1) {
924 puts(pcap_geterr(ppcap));
927 if (pcap_setfilter(ppcap, &bpfprogram) == -1) {
929 puts(pcap_geterr(ppcap));
931 printf("RX Filter applied\n");
933 pcap_freecode(&bpfprogram);
936 pcap_setnonblock(ppcap, 1, szErrbuf);
938 printf(" (delay between packets %dus)\n", nDelay);
940 memset(u8aSendBuffer, 0, sizeof (u8aSendBuffer));
942 while (!fBrokenSocket) {
943 u8 * pu8 = u8aSendBuffer;
944 struct pcap_pkthdr * ppcapPacketHeader = NULL;
945 struct ieee80211_radiotap_iterator rti;
946 PENUMBRA_RADIOTAP_DATA prd;
949 prd.m_nChannel = 255;
950 prd.m_nAntenna = 255;
951 prd.m_nRadiotapFlags = 255;
952 u8 * pu8Payload = u8aSendBuffer;
957 retval = pcap_next_ex(ppcap, &ppcapPacketHeader,
958 (const u_char**)&pu8Payload);
968 u16HeaderLen = (pu8Payload[2] + (pu8Payload[3] << 8));
971 Dump(pu8Payload, u16HeaderLen);
973 if (ppcapPacketHeader->len <
974 (u16HeaderLen + n80211HeaderLength))
977 bytes = ppcapPacketHeader->len -
978 (u16HeaderLen + n80211HeaderLength);
982 if (ieee80211_radiotap_iterator_init(&rti,
983 (struct ieee80211_radiotap_header *)pu8Payload,
987 while ((n = ieee80211_radiotap_iterator_next(&rti)) == 0) {
989 switch (rti.this_arg_index) {
990 case IEEE80211_RADIOTAP_RATE:
991 prd.m_nRate = (*rti.this_arg);
994 case IEEE80211_RADIOTAP_CHANNEL:
996 le16_to_cpu(*((u16 *)rti.this_arg));
997 prd.m_nChannelFlags =
998 le16_to_cpu(*((u16 *)(rti.this_arg + 2)));
1001 case IEEE80211_RADIOTAP_ANTENNA:
1002 prd.m_nAntenna = (*rti.this_arg) + 1;
1005 case IEEE80211_RADIOTAP_FLAGS:
1006 prd.m_nRadiotapFlags = *rti.this_arg;
1012 pu8Payload += u16HeaderLen + n80211HeaderLength;
1014 if (prd.m_nRadiotapFlags & IEEE80211_RADIOTAP_F_FCS)
1017 printf("RX: Rate: %2d.%dMbps, Freq: %d.%dGHz, "
1018 "Ant: %d, Flags: 0x%X\n",
1019 prd.m_nRate / 2, 5 * (prd.m_nRate & 1),
1020 prd.m_nChannel / 1000,
1021 prd.m_nChannel - ((prd.m_nChannel / 1000) * 1000),
1023 prd.m_nRadiotapFlags);
1025 Dump(pu8Payload, bytes);
1031 memcpy(u8aSendBuffer, u8aRadiotapHeader,
1032 sizeof (u8aRadiotapHeader));
1033 if (flagMarkWithFCS)
1034 pu8[OFFSET_FLAGS] |= IEEE80211_RADIOTAP_F_FCS;
1035 nRate = pu8[OFFSET_RATE] = u8aRatesToUse[nRateIndex++];
1036 if (nRateIndex >= sizeof (u8aRatesToUse))
1038 pu8 += sizeof (u8aRadiotapHeader);
1040 memcpy(pu8, u8aIeeeHeader, sizeof (u8aIeeeHeader));
1041 pu8 += sizeof (u8aIeeeHeader);
1043 pu8 += sprintf((char *)u8aSendBuffer,
1044 "Packetspammer %02d"
1046 "#%05d -- :-D --%s ----",
1047 nRate/2, nOrdinal++, szHostname);
1048 r = pcap_inject(ppcap, u8aSendBuffer, pu8 - u8aSendBuffer);
1049 if (r != (pu8-u8aSendBuffer)) {
1050 perror("Trouble injecting packet");