wireless-tools: Remove our hack from the package
This is not of general interest for our users. Move the code somewhere else. Related: SYS#922
This commit is contained in:
parent
21356b7508
commit
ea1483dd5c
|
@ -1,197 +0,0 @@
|
||||||
From 987960ea03c59a2ef9164e4f7309031ef4e0242d Mon Sep 17 00:00:00 2001
|
|
||||||
Message-Id: <987960ea03c59a2ef9164e4f7309031ef4e0242d.1410189314.git.daniel@totalueberwachung.de>
|
|
||||||
From: Daniel Willmann <dwillmann@sysmocom.de>
|
|
||||||
Date: Mon, 8 Sep 2014 15:53:54 +0200
|
|
||||||
Subject: [PATCH 1/1] Add wifi2udp program
|
|
||||||
|
|
||||||
---
|
|
||||||
Makefile | 4 +-
|
|
||||||
wifi2udp.c | 146 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
||||||
2 files changed, 149 insertions(+), 1 deletion(-)
|
|
||||||
create mode 100644 wifi2udp.c
|
|
||||||
|
|
||||||
Index: wireless_tools.30/Makefile
|
|
||||||
===================================================================
|
|
||||||
--- wireless_tools.30.orig/Makefile
|
|
||||||
+++ wireless_tools.30/Makefile
|
|
||||||
@@ -50,7 +50,7 @@ WEXT_HEADER = wireless.$(WE_VERSION).h
|
|
||||||
# Targets to build
|
|
||||||
STATIC=libiw.a
|
|
||||||
DYNAMIC=libiw.so.$(WT_VERSION)
|
|
||||||
-PROGS= iwconfig iwlist iwpriv iwspy iwgetid iwevent ifrename
|
|
||||||
+PROGS= iwconfig iwlist iwpriv iwspy iwgetid iwevent ifrename wifi2udp
|
|
||||||
MANPAGES8=iwconfig.8 iwlist.8 iwpriv.8 iwspy.8 iwgetid.8 iwevent.8 ifrename.8
|
|
||||||
MANPAGES7=wireless.7
|
|
||||||
MANPAGES5=iftab.5
|
|
||||||
@@ -105,7 +105,7 @@ endif
|
|
||||||
|
|
||||||
# Other flags
|
|
||||||
CFLAGS=-Os -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow \
|
|
||||||
- -Wpointer-arith -Wcast-qual -Winline -I.
|
|
||||||
+ -Wpointer-arith -Wcast-qual -Winline -I. -ggdb3
|
|
||||||
#CFLAGS=-O2 -W -Wall -Wstrict-prototypes -I.
|
|
||||||
DEPFLAGS=-MMD
|
|
||||||
XCFLAGS=$(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS) $(WELIB_FLAG) $(WEDEF_FLAG)
|
|
||||||
@@ -137,6 +137,8 @@ ifrename: ifrename.o $(IWLIB)
|
|
||||||
|
|
||||||
macaddr: macaddr.o $(IWLIB)
|
|
||||||
|
|
||||||
+wifi2udp: wifi2udp.o $(IWLIB)
|
|
||||||
+
|
|
||||||
iwmulticall: iwmulticall.o
|
|
||||||
$(CC) $(LDFLAGS) $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LIBS)
|
|
||||||
|
|
||||||
Index: wireless_tools.30/wifi2udp.c
|
|
||||||
===================================================================
|
|
||||||
--- /dev/null
|
|
||||||
+++ wireless_tools.30/wifi2udp.c
|
|
||||||
@@ -0,0 +1,149 @@
|
|
||||||
+
|
|
||||||
+#include <unistd.h>
|
|
||||||
+#include <stdio.h>
|
|
||||||
+#include <time.h>
|
|
||||||
+#include <iwlib.h>
|
|
||||||
+
|
|
||||||
+#include <sys/socket.h>
|
|
||||||
+
|
|
||||||
+static int verbose = 0;
|
|
||||||
+static int delay = 10;
|
|
||||||
+
|
|
||||||
+static void escape_essid(const char *src, char *dst, ssize_t len)
|
|
||||||
+{
|
|
||||||
+ int i, j;
|
|
||||||
+
|
|
||||||
+ for (i = 0, j = 0; j < len; i++, j++) {
|
|
||||||
+ if (src[i] == '"') {
|
|
||||||
+ dst[j] = '\\';
|
|
||||||
+ j++;
|
|
||||||
+ if (j == len)
|
|
||||||
+ break;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ dst[j] = src[i];
|
|
||||||
+
|
|
||||||
+ if (!src[i])
|
|
||||||
+ return;
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void scan_wifi(char *iface, const char *oduiface, const char *server, int port)
|
|
||||||
+{
|
|
||||||
+ int sock, rc;
|
|
||||||
+ iwrange range;
|
|
||||||
+ struct ifreq buf;
|
|
||||||
+ char mac[20];
|
|
||||||
+
|
|
||||||
+ struct sockaddr_in remote;
|
|
||||||
+ struct hostent *hp;
|
|
||||||
+
|
|
||||||
+ hp = gethostbyname(server);
|
|
||||||
+ if (!hp) {
|
|
||||||
+ printf("Could not resolve %s\n", server);
|
|
||||||
+ exit(-1);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ remote.sin_family = AF_INET;
|
|
||||||
+ memcpy(&remote.sin_addr, hp->h_addr, hp->h_length);
|
|
||||||
+ remote.sin_port = htons(port);
|
|
||||||
+
|
|
||||||
+ /* Retrieve MAC address of Wifi card */
|
|
||||||
+ sock = socket(PF_INET, SOCK_DGRAM, 0);
|
|
||||||
+ memset(&buf, 0, sizeof(buf));
|
|
||||||
+
|
|
||||||
+ strcpy(buf.ifr_name, oduiface);
|
|
||||||
+ ioctl(sock, SIOCGIFHWADDR, &buf);
|
|
||||||
+ iw_sawap_ntop(&buf.ifr_hwaddr, mac);
|
|
||||||
+
|
|
||||||
+ sock = iw_sockets_open();
|
|
||||||
+
|
|
||||||
+ rc = iw_get_range_info(sock, iface, &range);
|
|
||||||
+ if (rc < 0) {
|
|
||||||
+ printf("iw_get_range_info() returned %i\n", rc);
|
|
||||||
+ exit(2);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ while (1) {
|
|
||||||
+ time_t now;
|
|
||||||
+ wireless_scan_head head;
|
|
||||||
+ wireless_scan *result;
|
|
||||||
+ /* Scan for wireless networks */
|
|
||||||
+ rc = iw_scan(sock, iface, range.we_version_compiled, &head);
|
|
||||||
+ if (rc < 0) {
|
|
||||||
+ printf("iw_scan() returned %i\n", rc);
|
|
||||||
+ exit(2);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ now = time(NULL);
|
|
||||||
+
|
|
||||||
+ /* Print the results */
|
|
||||||
+ result = head.result;
|
|
||||||
+ while (NULL != result) {
|
|
||||||
+ char bssid[20];
|
|
||||||
+ char line[1024];
|
|
||||||
+ char essid_escaped[50];
|
|
||||||
+ wireless_scan *old_result;
|
|
||||||
+ iw_sawap_ntop(&result->ap_addr, bssid);
|
|
||||||
+
|
|
||||||
+ escape_essid(result->b.essid, essid_escaped, 50);
|
|
||||||
+ snprintf(line, 1024, "WIFI,%li,%s,\"%s\",%s,%0.0f,%i\r\n", now, mac, essid_escaped, bssid, result->b.freq/1000000, (int8_t)result->stats.qual.level);
|
|
||||||
+ if (verbose)
|
|
||||||
+ printf("%s", line);
|
|
||||||
+ rc = sendto(sock, line, strlen(line), 0, (struct sockaddr*)&remote, sizeof(remote));
|
|
||||||
+ if (rc == -1)
|
|
||||||
+ printf("Failed to send message: %s\n", strerror(errno));
|
|
||||||
+ old_result = result;
|
|
||||||
+ result = result->next;
|
|
||||||
+ free(old_result);
|
|
||||||
+ }
|
|
||||||
+ sleep(delay);
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void usage(void)
|
|
||||||
+{
|
|
||||||
+ printf("Usage: prog [options] host [port]\n");
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+int main(int argc, char *argv[])
|
|
||||||
+{
|
|
||||||
+ int option;
|
|
||||||
+ char *wifiiface = NULL, *ifacename = NULL, *server;
|
|
||||||
+ int port = 20001;
|
|
||||||
+
|
|
||||||
+ while ((option = getopt(argc, argv, "?hvw:i:d:")) != -1) {
|
|
||||||
+ switch (option) {
|
|
||||||
+ case 'v':
|
|
||||||
+ verbose = 1;
|
|
||||||
+ break;
|
|
||||||
+ case 'w':
|
|
||||||
+ wifiiface = optarg;
|
|
||||||
+ break;
|
|
||||||
+ case 'i':
|
|
||||||
+ ifacename = optarg;
|
|
||||||
+ break;
|
|
||||||
+ case 'd':
|
|
||||||
+ delay = atoi(optarg);
|
|
||||||
+ break;
|
|
||||||
+ case '?':
|
|
||||||
+ case 'h':
|
|
||||||
+ usage();
|
|
||||||
+ exit(1);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ if (optind < argc) {
|
|
||||||
+ server = argv[optind];
|
|
||||||
+ optind++;
|
|
||||||
+ } else {
|
|
||||||
+ usage();
|
|
||||||
+ exit(-1);
|
|
||||||
+ }
|
|
||||||
+ if (optind < argc)
|
|
||||||
+ port = atoi(argv[optind]);
|
|
||||||
+
|
|
||||||
+ scan_wifi(wifiiface, ifacename, server, port);
|
|
||||||
+
|
|
||||||
+ return 0;
|
|
||||||
+}
|
|
|
@ -1,9 +0,0 @@
|
||||||
[Unit]
|
|
||||||
Description=WIFI scan service
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
EnvironmentFile=/etc/default/odu_gps.conf
|
|
||||||
ExecStartPre=/sbin/ifconfig wlan0 up
|
|
||||||
ExecStart=/usr/sbin/wifi2udp -w wlan0 -i eth0 ${UDP_SINK}
|
|
||||||
Restart=always
|
|
||||||
RestartSec=2
|
|
|
@ -1,21 +0,0 @@
|
||||||
THISDIR := "${@os.path.dirname(bb.data.getVar('FILE', d, True))}"
|
|
||||||
FILESPATH =. "${@base_set_filespath(["${THISDIR}/files"], d)}:"
|
|
||||||
|
|
||||||
PRINC="8"
|
|
||||||
|
|
||||||
SRC_URI += "file://0001-Add-wifi2udp-program.patch \
|
|
||||||
file://wifi2udp.service"
|
|
||||||
|
|
||||||
PACKAGES =+ "wireless-tools-wifi2udp"
|
|
||||||
|
|
||||||
FILES_wireless-tools-wifi2udp = "${sbindir}/wifi2udp \
|
|
||||||
${systemd_unitdir}/system/wifi2udp.service \
|
|
||||||
${systemd_unitdir}/system/multi-user.target.wants/wifi2udp.service"
|
|
||||||
|
|
||||||
do_install_append() {
|
|
||||||
install -m 0755 wifi2udp ${D}${sbindir}/wifi2udp
|
|
||||||
install -d ${D}${systemd_unitdir}/system/
|
|
||||||
install -m 0644 ${WORKDIR}/wifi2udp.service ${D}${systemd_unitdir}/system/
|
|
||||||
install -d ${D}${systemd_unitdir}/system/multi-user.target.wants/
|
|
||||||
ln -sf ../wifi2udp.service ${D}${systemd_unitdir}/system/multi-user.target.wants/
|
|
||||||
}
|
|
|
@ -1 +0,0 @@
|
||||||
require recipes-fixes/wireless-tools/${PN}_sysmocom.inc
|
|
Loading…
Reference in New Issue