aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2017-04-07 13:27:55 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2017-04-07 13:27:55 +0200
commitbed4c80f31051ec47463caa3e9511374062c6536 (patch)
tree467481d54a95a5409516ceb53dba7f453170a48e
parent9eb76adec8d6a6f15a461da7c5e1e6920a92105a (diff)
downloadwifi-triangulator-bed4c80f31051ec47463caa3e9511374062c6536.tar.gz
wifi-triangulator-bed4c80f31051ec47463caa3e9511374062c6536.tar.bz2
wifi-triangulator-bed4c80f31051ec47463caa3e9511374062c6536.tar.xz
wifi-triangulator-bed4c80f31051ec47463caa3e9511374062c6536.zip
o Better CMake checks.
o Checking command line arguments.
-rw-r--r--CMakeLists.txt14
-rw-r--r--README.md12
-rw-r--r--main.cpp8
3 files changed, 30 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9712cca..ba802f4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,13 +1,21 @@
cmake_minimum_required(VERSION 3.6)
-project(wifi_triangulator)
+include(CheckIncludeFiles)
+include(CheckLibraryExists)
+project(wifi-triangulator)
set(CMAKE_CXX_STANDARD 14)
+check_include_files("pcap.h" HAVE_PCAP_H)
+
+if(NOT HAVE_PCAP_H)
+ message(FATAL_ERROR "Missing pcap.h. You should probably install libpcap-dev or similar.")
+endif()
+
set(SOURCE_FILES main.cpp
third-party/radiotap-library/radiotap.c
third-party/radiotap-library/radiotap.h
third-party/radiotap-library/radiotap_iter.h
third-party/radiotap-library/platform.h)
-add_executable(wifi_triangulator ${SOURCE_FILES})
+add_executable(wifi-triangulator ${SOURCE_FILES})
-target_link_libraries(wifi_triangulator PUBLIC pcap)
+target_link_libraries(wifi-triangulator PUBLIC pcap)
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..8d94a33
--- /dev/null
+++ b/README.md
@@ -0,0 +1,12 @@
+# Building
+
+ mkdir build
+ cd build
+ cmake ..
+ make
+
+# Running
+
+ sudo ifconfig wlan0 down
+ sudo iwconfig wlan0 mode monitor
+ sudo build/wifi-triangulator wlan0
diff --git a/main.cpp b/main.cpp
index e862ee1..9f3028e 100644
--- a/main.cpp
+++ b/main.cpp
@@ -327,9 +327,15 @@ void got_packet(u_char *args, const struct pcap_pkthdr *header, const u_char *pa
}
int main(int argc, char *argv[]) {
- char *dev = argv[1];
char errbuf[1000];
+ if (argc != 2) {
+ fprintf(stderr, "usage: %s [interface]\n", argv[0]);
+ return EXIT_FAILURE;
+ }
+
+ char *dev = argv[1];
+
pcap_t *handle;
handle = pcap_open_live(dev, BUFSIZ, 1, 1000, errbuf);