Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
rodizio1 authored Jun 17, 2017
1 parent 7641d45 commit 1757ba3
Show file tree
Hide file tree
Showing 31 changed files with 5,967 additions and 0 deletions.
51 changes: 51 additions & 0 deletions wifibroadcast/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
wifibroadcast and its FEC code are free software

you can redistribute wifibroadcast core functionality and/or
it them under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; see the file COPYING.
If not, write to the Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

the FEC code is covered by the following license:
fec.c -- forward error correction based on Vandermonde matrices
980624
(C) 1997-98 Luigi Rizzo ([email protected])
(C) 2001 Alain Knaff ([email protected])

Portions derived from code by Phil Karn ([email protected]),
Robert Morelos-Zaragoza ([email protected]) and Hari
Thirumoorthy ([email protected]), Aug 1995

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials
provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.

49 changes: 49 additions & 0 deletions wifibroadcast/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
LDFLAGS=-lrt -lpcap -lwiringPi
CPPFLAGS=-Wall -D _GNU_SOURCE

all: rx rcrx rssirx rssitx tx rx_status tracker channelscan check_alive rssi_forward rssi_forward_stdout rssi_write_shmem

%.o: %.c
gcc -c -o $@ $< $(CPPFLAGS)


rx: rx.o lib.o radiotap.o fec.o
gcc -o $@ $^ $(LDFLAGS)

rcrx: rcrx.o lib.o radiotap.o
gcc -o $@ $^ $(LDFLAGS)

rssirx: rssirx.o lib.o radiotap.o
gcc -o $@ $^ $(LDFLAGS)

rssitx: rssitx.o lib.o radiotap.o
gcc -o $@ $^ $(LDFLAGS)

tx: tx.o lib.o fec.o
gcc -o $@ $^ $(LDFLAGS)

rx_status: rx_status.o
gcc -o $@ $^ $(LDFLAGS)

tracker: tracker.o
gcc -o $@ $^ $(LDFLAGS)

channelscan: channelscan.o
gcc -o $@ $^ $(LDFLAGS)

check_alive: check_alive.o
gcc -o $@ $^ $(LDFLAGS)

rssi_forward: rssi_forward.o
gcc -o $@ $^ $(LDFLAGS)

rssi_forward_stdout: rssi_forward_stdout.o
gcc -o $@ $^ $(LDFLAGS)

rssi_write_shmem: rssi_write_shmem.o
gcc -o $@ $^ $(LDFLAGS)



clean:
rm -f rx rcrx rssirx rssitx tx rx_status tracker channelscan check_alive rssi_forward rssi_forward_stdout rssi_write_shmem *~ *.o
297 changes: 297 additions & 0 deletions wifibroadcast/channelscan.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,297 @@
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <resolv.h>
#include <string.h>
#include <utime.h>
#include <unistd.h>
#include <getopt.h>
#include <pcap.h>
#include <endian.h>
#include <fcntl.h>
#include <sys/mman.h>
#include "lib.h"

wifibroadcast_rx_status_t *status_memory_open(void) {
int fd;

for(;;) {
fd = shm_open("/wifibroadcast_rx_status_0", O_RDWR, S_IRUSR | S_IWUSR);
if(fd > 0) {
break;
}
usleep(200000);
}

if (ftruncate(fd, sizeof(wifibroadcast_rx_status_t)) == -1) {
perror("ftruncate");
exit(1);
}

void *retval = mmap(NULL, sizeof(wifibroadcast_rx_status_t), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (retval == MAP_FAILED) {
perror("mmap");
exit(1);
}

return (wifibroadcast_rx_status_t*)retval;
}


int main(int argc, char *argv[]) {

int band = atoi(argv[1]);
char* nic = argv[2];
int blocks1 = 0;
int blocks2 = 0;
int freq = 0;
char cmd[50];

wifibroadcast_rx_status_t *t = status_memory_open();

if (band == 2324) {

snprintf(cmd, sizeof cmd, "/usr/sbin/iw dev %s set freq 2484", nic);
system(cmd);
blocks1 = t->received_packet_cnt;
usleep(30000);
blocks2 = t->received_packet_cnt;
if (blocks1 != blocks2) { printf("2484"); exit(0); }


snprintf(cmd, sizeof cmd, "/usr/sbin/iw dev %s set freq 2477", nic);
system(cmd);
usleep(20000);
blocks1 = t->received_packet_cnt;
usleep(30000);
blocks2 = t->received_packet_cnt;
if (blocks1 != blocks2) { printf("2477"); exit(0); }

snprintf(cmd, sizeof cmd, "/usr/sbin/iw dev %s set freq 2482", nic);
system(cmd);
usleep(20000);
blocks1 = t->received_packet_cnt;
usleep(30000);
blocks2 = t->received_packet_cnt;
if (blocks1 != blocks2) { printf("2482"); exit(0); }

snprintf(cmd, sizeof cmd, "/usr/sbin/iw dev %s set freq 2477", nic);
system(cmd);
usleep(20000);
blocks1 = t->received_packet_cnt;
usleep(30000);
blocks2 = t->received_packet_cnt;
if (blocks1 != blocks2) { printf("2477"); exit(0); }

snprintf(cmd, sizeof cmd, "/usr/sbin/iw dev %s set freq 2487", nic);
system(cmd);
usleep(20000);
blocks1 = t->received_packet_cnt;
usleep(30000);
blocks2 = t->received_packet_cnt;
if (blocks1 != blocks2) { printf("2487"); exit(0); }

snprintf(cmd, sizeof cmd, "/usr/sbin/iw dev %s set freq 2489", nic);
system(cmd);
usleep(20000);
blocks1 = t->received_packet_cnt;
usleep(30000);
blocks2 = t->received_packet_cnt;
if (blocks1 != blocks2) { printf("2489"); exit(0); }

snprintf(cmd, sizeof cmd, "/usr/sbin/iw dev %s set freq 2492", nic);
system(cmd);
usleep(20000);
blocks1 = t->received_packet_cnt;
usleep(30000);
blocks2 = t->received_packet_cnt;
if (blocks1 != blocks2) { printf("2492"); exit(0); }

snprintf(cmd, sizeof cmd, "/usr/sbin/iw dev %s set freq 2494", nic);
system(cmd);
usleep(20000);
blocks1 = t->received_packet_cnt;
usleep(30000);
blocks2 = t->received_packet_cnt;
if (blocks1 != blocks2) { printf("2494"); exit(0); }

snprintf(cmd, sizeof cmd, "/usr/sbin/iw dev %s set freq 2497", nic);
system(cmd);
usleep(20000);
blocks1 = t->received_packet_cnt;
usleep(30000);
blocks2 = t->received_packet_cnt;
if (blocks1 != blocks2) { printf("2497"); exit(0); }

snprintf(cmd, sizeof cmd, "/usr/sbin/iw dev %s set freq 2499", nic);
system(cmd);
usleep(20000);
blocks1 = t->received_packet_cnt;
usleep(30000);
blocks2 = t->received_packet_cnt;
if (blocks1 != blocks2) { printf("2499"); exit(0); }

for (freq=2407; freq >= 2312; freq = freq - 5) {
snprintf(cmd, sizeof cmd, "/usr/sbin/iw dev %s set freq %d", nic, freq);
system(cmd);
usleep(20000);
blocks1 = t->received_packet_cnt;
usleep(30000);
blocks2 = t->received_packet_cnt;
if (blocks1 != blocks2) { printf("%d",freq); exit(0); }
}

snprintf(cmd, sizeof cmd, "/usr/sbin/iw dev %s set freq 2512", nic);
system(cmd);
usleep(20000);
blocks1 = t->received_packet_cnt;
usleep(30000);
blocks2 = t->received_packet_cnt;
if (blocks1 != blocks2) { printf("2512"); exit(0); }

snprintf(cmd, sizeof cmd, "/usr/sbin/iw dev %s set freq 2532", nic);
system(cmd);
usleep(20000);
blocks1 = t->received_packet_cnt;
usleep(30000);
blocks2 = t->received_packet_cnt;
if (blocks1 != blocks2) { printf("2532"); exit(0); }

snprintf(cmd, sizeof cmd, "/usr/sbin/iw dev %s set freq 2572", nic);
system(cmd);
usleep(20000);
blocks1 = t->received_packet_cnt;
usleep(30000);
blocks2 = t->received_packet_cnt;
if (blocks1 != blocks2) { printf("2572"); exit(0); }

snprintf(cmd, sizeof cmd, "/usr/sbin/iw dev %s set freq 2592", nic);
system(cmd);
usleep(20000);
blocks1 = t->received_packet_cnt;
usleep(30000);
blocks2 = t->received_packet_cnt;
if (blocks1 != blocks2) { printf("2592"); exit(0); }

snprintf(cmd, sizeof cmd, "/usr/sbin/iw dev %s set freq 2612", nic);
system(cmd);
usleep(20000);
blocks1 = t->received_packet_cnt;
usleep(30000);
blocks2 = t->received_packet_cnt;
if (blocks1 != blocks2) { printf("2612"); exit(0); }

snprintf(cmd, sizeof cmd, "/usr/sbin/iw dev %s set freq 2632", nic);
system(cmd);
usleep(20000);
blocks1 = t->received_packet_cnt;
usleep(30000);
blocks2 = t->received_packet_cnt;
if (blocks1 != blocks2) { printf("2632"); exit(0); }

snprintf(cmd, sizeof cmd, "/usr/sbin/iw dev %s set freq 2672", nic);
system(cmd);
usleep(20000);
blocks1 = t->received_packet_cnt;
usleep(30000);
blocks2 = t->received_packet_cnt;
if (blocks1 != blocks2) { printf("2672"); exit(0); }

snprintf(cmd, sizeof cmd, "/usr/sbin/iw dev %s set freq 2692", nic);
system(cmd);
usleep(20000);
blocks1 = t->received_packet_cnt;
usleep(30000);
blocks2 = t->received_packet_cnt;
if (blocks1 != blocks2) { printf("2692"); exit(0); }

}

if (band == 245) {

snprintf(cmd, sizeof cmd, "/usr/sbin/iw dev %s set freq 2484", nic);
system(cmd);
usleep(20000);
blocks1 = t->received_packet_cnt;
usleep(30000);
blocks2 = t->received_packet_cnt;
if (blocks1 != blocks2) { printf("2484"); exit(0); }

for (freq=2472; freq >= 2412; freq = freq - 5) {
snprintf(cmd, sizeof cmd, "/usr/sbin/iw dev %s set freq %d", nic, freq);
system(cmd);
usleep(20000);
blocks1 = t->received_packet_cnt;
usleep(30000);
blocks2 = t->received_packet_cnt;
if (blocks1 != blocks2) { printf("%d",freq); exit(0); }
}

for (freq=5825; freq >= 5745; freq = freq - 20) {
snprintf(cmd, sizeof cmd, "/usr/sbin/iw dev %s set freq %d", nic, freq);
system(cmd);
usleep(20000);
blocks1 = t->received_packet_cnt;
usleep(30000);
blocks2 = t->received_packet_cnt;
if (blocks1 != blocks2) {
printf("%d",freq);
exit(0);
}
}

for (freq=5700; freq >= 5500; freq = freq - 20) {
snprintf(cmd, sizeof cmd, "/usr/sbin/iw dev %s set freq %d", nic, freq);
system(cmd);
usleep(20000);
blocks1 = t->received_packet_cnt;
usleep(30000);
blocks2 = t->received_packet_cnt;
if (blocks1 != blocks2) {
printf("%d",freq);
exit(0);
}
}

for (freq=5320; freq >= 5180; freq = freq - 20) {
snprintf(cmd, sizeof cmd, "/usr/sbin/iw dev %s set freq %d", nic, freq);
system(cmd);
usleep(20000);
blocks1 = t->received_packet_cnt;
usleep(30000);
blocks2 = t->received_packet_cnt;
if (blocks1 != blocks2) {
printf("%d",freq);
exit(0);
}
}

}


if (band == 24) {

snprintf(cmd, sizeof cmd, "/usr/sbin/iw dev %s set freq 2484", nic);
system(cmd);
usleep(20000);
blocks1 = t->received_packet_cnt;
usleep(30000);
blocks2 = t->received_packet_cnt;
if (blocks1 != blocks2) { printf("2484"); exit(0); }

for (freq=2472; freq >= 2412; freq = freq - 5) {
snprintf(cmd, sizeof cmd, "/usr/sbin/iw dev %s set freq %d", nic, freq);
system(cmd);
usleep(20000);
blocks1 = t->received_packet_cnt;
usleep(30000);
blocks2 = t->received_packet_cnt;
if (blocks1 != blocks2) { printf("%d",freq); exit(0); }
}

}

// if nothing found, return zero as channel
printf("0");
return 0;
}
Loading

0 comments on commit 1757ba3

Please sign in to comment.