extra: removed
|
|
@ -1,2 +0,0 @@
|
|||
This folder contains packages that we are unsure
|
||||
whether they can be deleted or are needed.
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
#
|
||||
# Copyright (C) 2006-2010 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_RELEASE:=1
|
||||
PKG_VERSION:=1
|
||||
PKG_SOURCE_URL:=git://git.carnivore.it/users/common/af_alg.git
|
||||
PKG_SOURCE_VERSION:=1851bbb010c38878c83729be844f168192059189
|
||||
|
||||
PKG_NAME:=af_alg
|
||||
PKG_VERSION:=0.1
|
||||
|
||||
DEPENDS:=libopenssl
|
||||
|
||||
export BUILD_DIR
|
||||
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
|
||||
|
||||
TARGET_LDFLAGS+= \
|
||||
-Wl,-rpath-link=$(STAGING_DIR)/usr/lib
|
||||
MAKE_FLAGS += TARGET="$(target)"
|
||||
TARGET_CFLAGS += -Dtarget_$(target)=1 -Wall
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
|
||||
define Package/af_alg
|
||||
CATEGORY:=Libraries
|
||||
TITLE:=Openssl af_alg engine
|
||||
URL:=
|
||||
endef
|
||||
|
||||
define Package/af_alg/description
|
||||
Openssl af_alg engine
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
$(MAKE_VARS) \
|
||||
$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/$(MAKE_PATH) \
|
||||
$(MAKE_FLAGS)
|
||||
endef
|
||||
|
||||
define Package/af_alg/install
|
||||
$(INSTALL_DIR) $(1)/usr
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(INSTALL_DIR) $(1)/usr/lib/engines
|
||||
cp $(PKG_BUILD_DIR)/libaf_alg.so $(1)/usr/lib/engines/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,af_alg))
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
--- a/Makefile 2014-02-17 13:00:44.161670649 +0100
|
||||
+++ b/Makefile 2014-02-17 13:00:51.633670316 +0100
|
||||
@@ -24,7 +24,7 @@
|
||||
LDFLAGS =
|
||||
|
||||
SPEC_LDFLAGS = \
|
||||
- -lcrypto
|
||||
+ -lcrypt
|
||||
|
||||
CC = cc
|
||||
LD = $(CC)
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
menu "Configuration"
|
||||
depends on PACKAGE_compcache
|
||||
|
||||
config COMPCACHE_ENABLE
|
||||
bool "enabled on boot"
|
||||
default n
|
||||
help
|
||||
Enables compressed ram swap devices.
|
||||
|
||||
config COMPCACHE_RAM_REPORTED
|
||||
string "swap space reported to kernel in kb"
|
||||
default "2048"
|
||||
help
|
||||
This is the amount of memory that will be reported
|
||||
to the kernel as swap. The real ram in use will differ,
|
||||
because of lzo compression.
|
||||
Example:
|
||||
16 MB = 2048 KB
|
||||
32 MB = 4098 KB
|
||||
|
||||
config COMPCACHE_BACKUP_DEV
|
||||
string "Backup device for compcache"
|
||||
default ""
|
||||
help
|
||||
Compcache will use this as a backup device for swap.
|
||||
Example:
|
||||
/dev/sda5
|
||||
|
||||
endmenu
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
#
|
||||
# Copyright (C) 2009-2010 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_NAME:=compcache
|
||||
PKG_VERSION:=0.6.2
|
||||
PKG_RELEASE:=2
|
||||
PKG_SOURCE_URL:=http://compcache.googlecode.com/files/
|
||||
PKG_MD5SUM:=27aec78dc50e34fb800c74e879057743
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define KernelPackage/ramzswap
|
||||
SUBMENU:=Other modules
|
||||
DEPENDS:=@BUSYBOX_CONFIG_SWAPONOFF
|
||||
TITLE:=Driver for compressed ram swap device
|
||||
VERSION:=$(LINUX_VERSION)-$(BOARD)-$(LINUX_RELEASE)+$(PKG_RELEASE)
|
||||
FILES:=$(PKG_BUILD_DIR)/ramzswap.ko \
|
||||
$(PKG_BUILD_DIR)/sub-projects/compression/lzo-kmod/lzo1x.ko
|
||||
URL:=http://code.google.com/p/compcache/
|
||||
endef
|
||||
|
||||
define Package/compcache
|
||||
SECTION:=util
|
||||
CATEGORY:=Utilities
|
||||
DEPENDS:=+kmod-ramzswap
|
||||
TITLE:=Compressed ram swap device
|
||||
URL:=http://code.google.com/p/compcache/
|
||||
MENU:=1
|
||||
endef
|
||||
|
||||
include $(INCLUDE_DIR)/kernel-defaults.mk
|
||||
|
||||
LZO = sub-projects/compression/lzo-kmod
|
||||
RZSC = sub-projects/rzscontrol
|
||||
|
||||
BUILDFLAGS:=-DCONFIG_RAMZSWAP_STATS \
|
||||
-I$(PKG_BUILD_DIR)/$(LZO) \
|
||||
-Wall
|
||||
|
||||
RZSCFLAGS:=-I$(PKG_BUILD_DIR)/$(RZSC)/../include \
|
||||
-I$(PKG_BUILD_DIR)/$(RZSC)/../..
|
||||
|
||||
define Build/Compile
|
||||
$(MAKE) $(KERNEL_MAKEOPTS) EXTRA_CFLAGS="$(BUILDFLAGS)" M="$(PKG_BUILD_DIR)" modules
|
||||
$(TARGET_CC) $(TARGET_CFLAGS) $(RZSCFLAGS) $(PKG_BUILD_DIR)/$(RZSC)/rzscontrol.c -o $(PKG_BUILD_DIR)/rzscontrol
|
||||
endef
|
||||
|
||||
define Package/compcache/install
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_DATA) ./files/compcache.config $(1)/etc/config/compcache
|
||||
$(SED) 's,%ENABLED%,$(if $(CONFIG_COMPCACHE_ENABLE),1,0),g' \
|
||||
-e 's,%RAM_REPORTED%,$(call qstrip,$(CONFIG_COMPCACHE_RAM_REPORTED)),g' \
|
||||
-e 's,%BACKUP_DEV%,$(call qstrip,$(CONFIG_COMPCACHE_BACKUP_DEV)),g' \
|
||||
$(1)/etc/config/compcache
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/compcache.init $(1)/etc/init.d/compcache
|
||||
$(INSTALL_DIR) $(1)/sbin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/rzscontrol $(1)/sbin/rzscontrol
|
||||
endef
|
||||
|
||||
define Package/compcache/config
|
||||
source "$(SOURCE)/Config.in"
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,compcache))
|
||||
$(eval $(call KernelPackage,ramzswap))
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
config compcache
|
||||
option 'enabled' '%ENABLED%'
|
||||
option 'size_kbytes' '%RAM_REPORTED%'
|
||||
option 'backup_dev' '%BACKUP_DEV%'
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2008 OpenWrt.org
|
||||
START=14
|
||||
|
||||
load_modules() {
|
||||
local section="$1"
|
||||
config_get "size_kbytes" "$section" "size_kbytes"
|
||||
config_get "backup_dev" "$section" "backup_dev"
|
||||
#CC_PARAM_STR="memlimit_kb=$1 backing_dev=$BACKING_DEV"
|
||||
config_get_bool "enabled" "$section" "enabled" '1'
|
||||
if [ "$enabled" -gt 0 ]; then
|
||||
if [ "`cat /proc/swaps | grep 'ramzswap0'`" != "" ]; then
|
||||
echo "compcache already loaded"
|
||||
else
|
||||
if [ "$backup_dev" != "" ]; then
|
||||
params_set="memlimit_kb=$size_kbytes backing_swap=$backup_dev"
|
||||
else
|
||||
params_set="disksize_kb=$size_kbytes"
|
||||
fi
|
||||
if [ "`lsmod | grep 'ramzswap'`" == "" ]; then
|
||||
insmod lzo1x
|
||||
insmod ramzswap $params_set
|
||||
sleep 2
|
||||
swapon /dev/ramzswap0
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
remove_modules() {
|
||||
local section="$1"
|
||||
config_get_bool "enabled" "$section" "enabled" '1'
|
||||
if [ "$enabled" -gt 0 ]; then
|
||||
[ "`cat /proc/swaps | grep 'ramzswap0'`" != "" ] && swapoff /dev/ramzswap0
|
||||
[ "`lsmod | grep 'ramzswap'`" != "" ] && rmmod ramzswap &> /dev/null
|
||||
[ "`lsmod | grep 'lzo1x'`" != "" ] && rmmod lzo1x &> /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
start() {
|
||||
config_load "compcache"
|
||||
config_foreach load_modules "compcache"
|
||||
}
|
||||
|
||||
stop() {
|
||||
config_load "compcache"
|
||||
config_foreach remove_modules "compcache"
|
||||
}
|
||||
|
|
@ -1,647 +0,0 @@
|
|||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -1,14 +1,17 @@
|
||||
KERNEL_BUILD_PATH ?= "/lib/modules/$(shell uname -r)/build"
|
||||
|
||||
XVM = sub-projects/allocators/xvmalloc-kmod
|
||||
+LZO = sub-projects/compression/lzo-kmod
|
||||
EXTRA_CFLAGS := -DCONFIG_RAMZSWAP_STATS \
|
||||
-Wall
|
||||
|
||||
-obj-m += ramzswap.o
|
||||
+obj-m += ramzswap.o $(LZO)/lzo1x.o
|
||||
ramzswap-objs := ramzswap_drv.o $(XVM)/xvmalloc.o
|
||||
+
|
||||
|
||||
all:
|
||||
make -C $(KERNEL_BUILD_PATH) M=$(PWD) modules
|
||||
+ make -C $(KERNEL_BUILD_PATH) M=$(PWD)/$(LZO) modules
|
||||
make -C sub-projects/rzscontrol
|
||||
|
||||
doc:
|
||||
@@ -16,5 +19,6 @@ doc:
|
||||
|
||||
clean:
|
||||
make -C $(KERNEL_BUILD_PATH) M=$(PWD) clean
|
||||
+ make -C $(KERNEL_BUILD_PATH) M=$(PWD)/$(LZO) clean
|
||||
make -C sub-projects/rzscontrol clean
|
||||
@rm -rf *.ko
|
||||
--- a/ramzswap_drv.c
|
||||
+++ b/ramzswap_drv.c
|
||||
@@ -23,13 +23,13 @@
|
||||
#include <linux/device.h>
|
||||
#include <linux/genhd.h>
|
||||
#include <linux/highmem.h>
|
||||
-#include <linux/lzo.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/swap.h>
|
||||
#include <linux/swapops.h>
|
||||
#include <linux/vmalloc.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
+#include "lzo.h"
|
||||
#include "compat.h"
|
||||
#include "ramzswap_drv.h"
|
||||
|
||||
--- /dev/null
|
||||
+++ b/sub-projects/compression/lzo-kmod/lzo1x.c
|
||||
@@ -0,0 +1,7 @@
|
||||
+#include <linux/module.h>
|
||||
+
|
||||
+#include "lzo1x_compress.c"
|
||||
+#include "lzo1x_decompress.c"
|
||||
+
|
||||
+MODULE_LICENSE("GPL");
|
||||
+MODULE_DESCRIPTION("LZO1X Lib");
|
||||
--- /dev/null
|
||||
+++ b/sub-projects/compression/lzo-kmod/lzo1x_compress.c
|
||||
@@ -0,0 +1,227 @@
|
||||
+/*
|
||||
+ * LZO1X Compressor from MiniLZO
|
||||
+ *
|
||||
+ * Copyright (C) 1996-2005 Markus F.X.J. Oberhumer <markus@oberhumer.com>
|
||||
+ *
|
||||
+ * The full LZO package can be found at:
|
||||
+ * http://www.oberhumer.com/opensource/lzo/
|
||||
+ *
|
||||
+ * Changed for kernel use by:
|
||||
+ * Nitin Gupta <nitingupta910@gmail.com>
|
||||
+ * Richard Purdie <rpurdie@openedhand.com>
|
||||
+ */
|
||||
+
|
||||
+#include <linux/module.h>
|
||||
+#include <linux/kernel.h>
|
||||
+#include <asm/unaligned.h>
|
||||
+
|
||||
+#include "lzodefs.h"
|
||||
+#include "lzo.h"
|
||||
+
|
||||
+static noinline size_t
|
||||
+_lzo1x_1_do_compress(const unsigned char *in, size_t in_len,
|
||||
+ unsigned char *out, size_t *out_len, void *wrkmem)
|
||||
+{
|
||||
+ const unsigned char * const in_end = in + in_len;
|
||||
+ const unsigned char * const ip_end = in + in_len - M2_MAX_LEN - 5;
|
||||
+ const unsigned char ** const dict = wrkmem;
|
||||
+ const unsigned char *ip = in, *ii = ip;
|
||||
+ const unsigned char *end, *m, *m_pos;
|
||||
+ size_t m_off, m_len, dindex;
|
||||
+ unsigned char *op = out;
|
||||
+
|
||||
+ ip += 4;
|
||||
+
|
||||
+ for (;;) {
|
||||
+ dindex = ((size_t)(0x21 * DX3(ip, 5, 5, 6)) >> 5) & D_MASK;
|
||||
+ m_pos = dict[dindex];
|
||||
+
|
||||
+ if (m_pos < in)
|
||||
+ goto literal;
|
||||
+
|
||||
+ if (ip == m_pos || ((size_t)(ip - m_pos) > M4_MAX_OFFSET))
|
||||
+ goto literal;
|
||||
+
|
||||
+ m_off = ip - m_pos;
|
||||
+ if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3])
|
||||
+ goto try_match;
|
||||
+
|
||||
+ dindex = (dindex & (D_MASK & 0x7ff)) ^ (D_HIGH | 0x1f);
|
||||
+ m_pos = dict[dindex];
|
||||
+
|
||||
+ if (m_pos < in)
|
||||
+ goto literal;
|
||||
+
|
||||
+ if (ip == m_pos || ((size_t)(ip - m_pos) > M4_MAX_OFFSET))
|
||||
+ goto literal;
|
||||
+
|
||||
+ m_off = ip - m_pos;
|
||||
+ if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3])
|
||||
+ goto try_match;
|
||||
+
|
||||
+ goto literal;
|
||||
+
|
||||
+try_match:
|
||||
+ if (get_unaligned((const unsigned short *)m_pos)
|
||||
+ == get_unaligned((const unsigned short *)ip)) {
|
||||
+ if (likely(m_pos[2] == ip[2]))
|
||||
+ goto match;
|
||||
+ }
|
||||
+
|
||||
+literal:
|
||||
+ dict[dindex] = ip;
|
||||
+ ++ip;
|
||||
+ if (unlikely(ip >= ip_end))
|
||||
+ break;
|
||||
+ continue;
|
||||
+
|
||||
+match:
|
||||
+ dict[dindex] = ip;
|
||||
+ if (ip != ii) {
|
||||
+ size_t t = ip - ii;
|
||||
+
|
||||
+ if (t <= 3) {
|
||||
+ op[-2] |= t;
|
||||
+ } else if (t <= 18) {
|
||||
+ *op++ = (t - 3);
|
||||
+ } else {
|
||||
+ size_t tt = t - 18;
|
||||
+
|
||||
+ *op++ = 0;
|
||||
+ while (tt > 255) {
|
||||
+ tt -= 255;
|
||||
+ *op++ = 0;
|
||||
+ }
|
||||
+ *op++ = tt;
|
||||
+ }
|
||||
+ do {
|
||||
+ *op++ = *ii++;
|
||||
+ } while (--t > 0);
|
||||
+ }
|
||||
+
|
||||
+ ip += 3;
|
||||
+ if (m_pos[3] != *ip++ || m_pos[4] != *ip++
|
||||
+ || m_pos[5] != *ip++ || m_pos[6] != *ip++
|
||||
+ || m_pos[7] != *ip++ || m_pos[8] != *ip++) {
|
||||
+ --ip;
|
||||
+ m_len = ip - ii;
|
||||
+
|
||||
+ if (m_off <= M2_MAX_OFFSET) {
|
||||
+ m_off -= 1;
|
||||
+ *op++ = (((m_len - 1) << 5)
|
||||
+ | ((m_off & 7) << 2));
|
||||
+ *op++ = (m_off >> 3);
|
||||
+ } else if (m_off <= M3_MAX_OFFSET) {
|
||||
+ m_off -= 1;
|
||||
+ *op++ = (M3_MARKER | (m_len - 2));
|
||||
+ goto m3_m4_offset;
|
||||
+ } else {
|
||||
+ m_off -= 0x4000;
|
||||
+
|
||||
+ *op++ = (M4_MARKER | ((m_off & 0x4000) >> 11)
|
||||
+ | (m_len - 2));
|
||||
+ goto m3_m4_offset;
|
||||
+ }
|
||||
+ } else {
|
||||
+ end = in_end;
|
||||
+ m = m_pos + M2_MAX_LEN + 1;
|
||||
+
|
||||
+ while (ip < end && *m == *ip) {
|
||||
+ m++;
|
||||
+ ip++;
|
||||
+ }
|
||||
+ m_len = ip - ii;
|
||||
+
|
||||
+ if (m_off <= M3_MAX_OFFSET) {
|
||||
+ m_off -= 1;
|
||||
+ if (m_len <= 33) {
|
||||
+ *op++ = (M3_MARKER | (m_len - 2));
|
||||
+ } else {
|
||||
+ m_len -= 33;
|
||||
+ *op++ = M3_MARKER | 0;
|
||||
+ goto m3_m4_len;
|
||||
+ }
|
||||
+ } else {
|
||||
+ m_off -= 0x4000;
|
||||
+ if (m_len <= M4_MAX_LEN) {
|
||||
+ *op++ = (M4_MARKER
|
||||
+ | ((m_off & 0x4000) >> 11)
|
||||
+ | (m_len - 2));
|
||||
+ } else {
|
||||
+ m_len -= M4_MAX_LEN;
|
||||
+ *op++ = (M4_MARKER
|
||||
+ | ((m_off & 0x4000) >> 11));
|
||||
+m3_m4_len:
|
||||
+ while (m_len > 255) {
|
||||
+ m_len -= 255;
|
||||
+ *op++ = 0;
|
||||
+ }
|
||||
+
|
||||
+ *op++ = (m_len);
|
||||
+ }
|
||||
+ }
|
||||
+m3_m4_offset:
|
||||
+ *op++ = ((m_off & 63) << 2);
|
||||
+ *op++ = (m_off >> 6);
|
||||
+ }
|
||||
+
|
||||
+ ii = ip;
|
||||
+ if (unlikely(ip >= ip_end))
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ *out_len = op - out;
|
||||
+ return in_end - ii;
|
||||
+}
|
||||
+
|
||||
+int lzo1x_1_compress(const unsigned char *in, size_t in_len, unsigned char *out,
|
||||
+ size_t *out_len, void *wrkmem)
|
||||
+{
|
||||
+ const unsigned char *ii;
|
||||
+ unsigned char *op = out;
|
||||
+ size_t t;
|
||||
+
|
||||
+ if (unlikely(in_len <= M2_MAX_LEN + 5)) {
|
||||
+ t = in_len;
|
||||
+ } else {
|
||||
+ t = _lzo1x_1_do_compress(in, in_len, op, out_len, wrkmem);
|
||||
+ op += *out_len;
|
||||
+ }
|
||||
+
|
||||
+ if (t > 0) {
|
||||
+ ii = in + in_len - t;
|
||||
+
|
||||
+ if (op == out && t <= 238) {
|
||||
+ *op++ = (17 + t);
|
||||
+ } else if (t <= 3) {
|
||||
+ op[-2] |= t;
|
||||
+ } else if (t <= 18) {
|
||||
+ *op++ = (t - 3);
|
||||
+ } else {
|
||||
+ size_t tt = t - 18;
|
||||
+
|
||||
+ *op++ = 0;
|
||||
+ while (tt > 255) {
|
||||
+ tt -= 255;
|
||||
+ *op++ = 0;
|
||||
+ }
|
||||
+
|
||||
+ *op++ = tt;
|
||||
+ }
|
||||
+ do {
|
||||
+ *op++ = *ii++;
|
||||
+ } while (--t > 0);
|
||||
+ }
|
||||
+
|
||||
+ *op++ = M4_MARKER | 1;
|
||||
+ *op++ = 0;
|
||||
+ *op++ = 0;
|
||||
+
|
||||
+ *out_len = op - out;
|
||||
+ return LZO_E_OK;
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(lzo1x_1_compress);
|
||||
+
|
||||
+MODULE_LICENSE("GPL");
|
||||
+MODULE_DESCRIPTION("LZO1X-1 Compressor");
|
||||
+
|
||||
--- /dev/null
|
||||
+++ b/sub-projects/compression/lzo-kmod/lzo1x_decompress.c
|
||||
@@ -0,0 +1,255 @@
|
||||
+/*
|
||||
+ * LZO1X Decompressor from MiniLZO
|
||||
+ *
|
||||
+ * Copyright (C) 1996-2005 Markus F.X.J. Oberhumer <markus@oberhumer.com>
|
||||
+ *
|
||||
+ * The full LZO package can be found at:
|
||||
+ * http://www.oberhumer.com/opensource/lzo/
|
||||
+ *
|
||||
+ * Changed for kernel use by:
|
||||
+ * Nitin Gupta <nitingupta910@gmail.com>
|
||||
+ * Richard Purdie <rpurdie@openedhand.com>
|
||||
+ */
|
||||
+
|
||||
+#include <linux/module.h>
|
||||
+#include <linux/kernel.h>
|
||||
+#include <asm/byteorder.h>
|
||||
+#include <asm/unaligned.h>
|
||||
+
|
||||
+#include "lzodefs.h"
|
||||
+#include "lzo.h"
|
||||
+
|
||||
+#define HAVE_IP(x, ip_end, ip) ((size_t)(ip_end - ip) < (x))
|
||||
+#define HAVE_OP(x, op_end, op) ((size_t)(op_end - op) < (x))
|
||||
+#define HAVE_LB(m_pos, out, op) (m_pos < out || m_pos >= op)
|
||||
+
|
||||
+#define COPY4(dst, src) \
|
||||
+ put_unaligned(get_unaligned((const u32 *)(src)), (u32 *)(dst))
|
||||
+
|
||||
+int lzo1x_decompress_safe(const unsigned char *in, size_t in_len,
|
||||
+ unsigned char *out, size_t *out_len)
|
||||
+{
|
||||
+ const unsigned char * const ip_end = in + in_len;
|
||||
+ unsigned char * const op_end = out + *out_len;
|
||||
+ const unsigned char *ip = in, *m_pos;
|
||||
+ unsigned char *op = out;
|
||||
+ size_t t;
|
||||
+
|
||||
+ *out_len = 0;
|
||||
+
|
||||
+ if (*ip > 17) {
|
||||
+ t = *ip++ - 17;
|
||||
+ if (t < 4)
|
||||
+ goto match_next;
|
||||
+ if (HAVE_OP(t, op_end, op))
|
||||
+ goto output_overrun;
|
||||
+ if (HAVE_IP(t + 1, ip_end, ip))
|
||||
+ goto input_overrun;
|
||||
+ do {
|
||||
+ *op++ = *ip++;
|
||||
+ } while (--t > 0);
|
||||
+ goto first_literal_run;
|
||||
+ }
|
||||
+
|
||||
+ while ((ip < ip_end)) {
|
||||
+ t = *ip++;
|
||||
+ if (t >= 16)
|
||||
+ goto match;
|
||||
+ if (t == 0) {
|
||||
+ if (HAVE_IP(1, ip_end, ip))
|
||||
+ goto input_overrun;
|
||||
+ while (*ip == 0) {
|
||||
+ t += 255;
|
||||
+ ip++;
|
||||
+ if (HAVE_IP(1, ip_end, ip))
|
||||
+ goto input_overrun;
|
||||
+ }
|
||||
+ t += 15 + *ip++;
|
||||
+ }
|
||||
+ if (HAVE_OP(t + 3, op_end, op))
|
||||
+ goto output_overrun;
|
||||
+ if (HAVE_IP(t + 4, ip_end, ip))
|
||||
+ goto input_overrun;
|
||||
+
|
||||
+ COPY4(op, ip);
|
||||
+ op += 4;
|
||||
+ ip += 4;
|
||||
+ if (--t > 0) {
|
||||
+ if (t >= 4) {
|
||||
+ do {
|
||||
+ COPY4(op, ip);
|
||||
+ op += 4;
|
||||
+ ip += 4;
|
||||
+ t -= 4;
|
||||
+ } while (t >= 4);
|
||||
+ if (t > 0) {
|
||||
+ do {
|
||||
+ *op++ = *ip++;
|
||||
+ } while (--t > 0);
|
||||
+ }
|
||||
+ } else {
|
||||
+ do {
|
||||
+ *op++ = *ip++;
|
||||
+ } while (--t > 0);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+first_literal_run:
|
||||
+ t = *ip++;
|
||||
+ if (t >= 16)
|
||||
+ goto match;
|
||||
+ m_pos = op - (1 + M2_MAX_OFFSET);
|
||||
+ m_pos -= t >> 2;
|
||||
+ m_pos -= *ip++ << 2;
|
||||
+
|
||||
+ if (HAVE_LB(m_pos, out, op))
|
||||
+ goto lookbehind_overrun;
|
||||
+
|
||||
+ if (HAVE_OP(3, op_end, op))
|
||||
+ goto output_overrun;
|
||||
+ *op++ = *m_pos++;
|
||||
+ *op++ = *m_pos++;
|
||||
+ *op++ = *m_pos;
|
||||
+
|
||||
+ goto match_done;
|
||||
+
|
||||
+ do {
|
||||
+match:
|
||||
+ if (t >= 64) {
|
||||
+ m_pos = op - 1;
|
||||
+ m_pos -= (t >> 2) & 7;
|
||||
+ m_pos -= *ip++ << 3;
|
||||
+ t = (t >> 5) - 1;
|
||||
+ if (HAVE_LB(m_pos, out, op))
|
||||
+ goto lookbehind_overrun;
|
||||
+ if (HAVE_OP(t + 3 - 1, op_end, op))
|
||||
+ goto output_overrun;
|
||||
+ goto copy_match;
|
||||
+ } else if (t >= 32) {
|
||||
+ t &= 31;
|
||||
+ if (t == 0) {
|
||||
+ if (HAVE_IP(1, ip_end, ip))
|
||||
+ goto input_overrun;
|
||||
+ while (*ip == 0) {
|
||||
+ t += 255;
|
||||
+ ip++;
|
||||
+ if (HAVE_IP(1, ip_end, ip))
|
||||
+ goto input_overrun;
|
||||
+ }
|
||||
+ t += 31 + *ip++;
|
||||
+ }
|
||||
+ m_pos = op - 1;
|
||||
+ m_pos -= le16_to_cpu(get_unaligned(
|
||||
+ (const unsigned short *)ip)) >> 2;
|
||||
+ ip += 2;
|
||||
+ } else if (t >= 16) {
|
||||
+ m_pos = op;
|
||||
+ m_pos -= (t & 8) << 11;
|
||||
+
|
||||
+ t &= 7;
|
||||
+ if (t == 0) {
|
||||
+ if (HAVE_IP(1, ip_end, ip))
|
||||
+ goto input_overrun;
|
||||
+ while (*ip == 0) {
|
||||
+ t += 255;
|
||||
+ ip++;
|
||||
+ if (HAVE_IP(1, ip_end, ip))
|
||||
+ goto input_overrun;
|
||||
+ }
|
||||
+ t += 7 + *ip++;
|
||||
+ }
|
||||
+ m_pos -= le16_to_cpu(get_unaligned(
|
||||
+ (const unsigned short *)ip)) >> 2;
|
||||
+ ip += 2;
|
||||
+ if (m_pos == op)
|
||||
+ goto eof_found;
|
||||
+ m_pos -= 0x4000;
|
||||
+ } else {
|
||||
+ m_pos = op - 1;
|
||||
+ m_pos -= t >> 2;
|
||||
+ m_pos -= *ip++ << 2;
|
||||
+
|
||||
+ if (HAVE_LB(m_pos, out, op))
|
||||
+ goto lookbehind_overrun;
|
||||
+ if (HAVE_OP(2, op_end, op))
|
||||
+ goto output_overrun;
|
||||
+
|
||||
+ *op++ = *m_pos++;
|
||||
+ *op++ = *m_pos;
|
||||
+ goto match_done;
|
||||
+ }
|
||||
+
|
||||
+ if (HAVE_LB(m_pos, out, op))
|
||||
+ goto lookbehind_overrun;
|
||||
+ if (HAVE_OP(t + 3 - 1, op_end, op))
|
||||
+ goto output_overrun;
|
||||
+
|
||||
+ if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4) {
|
||||
+ COPY4(op, m_pos);
|
||||
+ op += 4;
|
||||
+ m_pos += 4;
|
||||
+ t -= 4 - (3 - 1);
|
||||
+ do {
|
||||
+ COPY4(op, m_pos);
|
||||
+ op += 4;
|
||||
+ m_pos += 4;
|
||||
+ t -= 4;
|
||||
+ } while (t >= 4);
|
||||
+ if (t > 0)
|
||||
+ do {
|
||||
+ *op++ = *m_pos++;
|
||||
+ } while (--t > 0);
|
||||
+ } else {
|
||||
+copy_match:
|
||||
+ *op++ = *m_pos++;
|
||||
+ *op++ = *m_pos++;
|
||||
+ do {
|
||||
+ *op++ = *m_pos++;
|
||||
+ } while (--t > 0);
|
||||
+ }
|
||||
+match_done:
|
||||
+ t = ip[-2] & 3;
|
||||
+ if (t == 0)
|
||||
+ break;
|
||||
+match_next:
|
||||
+ if (HAVE_OP(t, op_end, op))
|
||||
+ goto output_overrun;
|
||||
+ if (HAVE_IP(t + 1, ip_end, ip))
|
||||
+ goto input_overrun;
|
||||
+
|
||||
+ *op++ = *ip++;
|
||||
+ if (t > 1) {
|
||||
+ *op++ = *ip++;
|
||||
+ if (t > 2)
|
||||
+ *op++ = *ip++;
|
||||
+ }
|
||||
+
|
||||
+ t = *ip++;
|
||||
+ } while (ip < ip_end);
|
||||
+ }
|
||||
+
|
||||
+ *out_len = op - out;
|
||||
+ return LZO_E_EOF_NOT_FOUND;
|
||||
+
|
||||
+eof_found:
|
||||
+ *out_len = op - out;
|
||||
+ return (ip == ip_end ? LZO_E_OK :
|
||||
+ (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN));
|
||||
+input_overrun:
|
||||
+ *out_len = op - out;
|
||||
+ return LZO_E_INPUT_OVERRUN;
|
||||
+
|
||||
+output_overrun:
|
||||
+ *out_len = op - out;
|
||||
+ return LZO_E_OUTPUT_OVERRUN;
|
||||
+
|
||||
+lookbehind_overrun:
|
||||
+ *out_len = op - out;
|
||||
+ return LZO_E_LOOKBEHIND_OVERRUN;
|
||||
+}
|
||||
+
|
||||
+EXPORT_SYMBOL_GPL(lzo1x_decompress_safe);
|
||||
+
|
||||
+MODULE_LICENSE("GPL");
|
||||
+MODULE_DESCRIPTION("LZO1X Decompressor");
|
||||
+
|
||||
--- /dev/null
|
||||
+++ b/sub-projects/compression/lzo-kmod/lzodefs.h
|
||||
@@ -0,0 +1,43 @@
|
||||
+/*
|
||||
+ * lzodefs.h -- architecture, OS and compiler specific defines
|
||||
+ *
|
||||
+ * Copyright (C) 1996-2005 Markus F.X.J. Oberhumer <markus@oberhumer.com>
|
||||
+ *
|
||||
+ * The full LZO package can be found at:
|
||||
+ * http://www.oberhumer.com/opensource/lzo/
|
||||
+ *
|
||||
+ * Changed for kernel use by:
|
||||
+ * Nitin Gupta <nitingupta910@gmail.com>
|
||||
+ * Richard Purdie <rpurdie@openedhand.com>
|
||||
+ */
|
||||
+
|
||||
+#define LZO_VERSION 0x2020
|
||||
+#define LZO_VERSION_STRING "2.02"
|
||||
+#define LZO_VERSION_DATE "Oct 17 2005"
|
||||
+
|
||||
+#define M1_MAX_OFFSET 0x0400
|
||||
+#define M2_MAX_OFFSET 0x0800
|
||||
+#define M3_MAX_OFFSET 0x4000
|
||||
+#define M4_MAX_OFFSET 0xbfff
|
||||
+
|
||||
+#define M1_MIN_LEN 2
|
||||
+#define M1_MAX_LEN 2
|
||||
+#define M2_MIN_LEN 3
|
||||
+#define M2_MAX_LEN 8
|
||||
+#define M3_MIN_LEN 3
|
||||
+#define M3_MAX_LEN 33
|
||||
+#define M4_MIN_LEN 3
|
||||
+#define M4_MAX_LEN 9
|
||||
+
|
||||
+#define M1_MARKER 0
|
||||
+#define M2_MARKER 64
|
||||
+#define M3_MARKER 32
|
||||
+#define M4_MARKER 16
|
||||
+
|
||||
+#define D_BITS 14
|
||||
+#define D_MASK ((1u << D_BITS) - 1)
|
||||
+#define D_HIGH ((D_MASK >> 1) + 1)
|
||||
+
|
||||
+#define DX2(p, s1, s2) (((((size_t)((p)[2]) << (s2)) ^ (p)[1]) \
|
||||
+ << (s1)) ^ (p)[0])
|
||||
+#define DX3(p, s1, s2, s3) ((DX2((p)+1, s2, s3) << (s1)) ^ (p)[0])
|
||||
--- /dev/null
|
||||
+++ b/sub-projects/compression/lzo-kmod/lzo.h
|
||||
@@ -0,0 +1,44 @@
|
||||
+#ifndef __LZO_H__
|
||||
+#define __LZO_H__
|
||||
+/*
|
||||
+ * LZO Public Kernel Interface
|
||||
+ * A mini subset of the LZO real-time data compression library
|
||||
+ *
|
||||
+ * Copyright (C) 1996-2005 Markus F.X.J. Oberhumer <markus@oberhumer.com>
|
||||
+ *
|
||||
+ * The full LZO package can be found at:
|
||||
+ * http://www.oberhumer.com/opensource/lzo/
|
||||
+ *
|
||||
+ * Changed for kernel use by:
|
||||
+ * Nitin Gupta <nitingupta910@gmail.com>
|
||||
+ * Richard Purdie <rpurdie@openedhand.com>
|
||||
+ */
|
||||
+
|
||||
+#define LZO1X_MEM_COMPRESS (16384 * sizeof(unsigned char *))
|
||||
+#define LZO1X_1_MEM_COMPRESS LZO1X_MEM_COMPRESS
|
||||
+
|
||||
+#define lzo1x_worst_compress(x) ((x) + ((x) / 16) + 64 + 3)
|
||||
+
|
||||
+/* This requires 'workmem' of size LZO1X_1_MEM_COMPRESS */
|
||||
+int lzo1x_1_compress(const unsigned char *src, size_t src_len,
|
||||
+ unsigned char *dst, size_t *dst_len, void *wrkmem);
|
||||
+
|
||||
+/* safe decompression with overrun testing */
|
||||
+int lzo1x_decompress_safe(const unsigned char *src, size_t src_len,
|
||||
+ unsigned char *dst, size_t *dst_len);
|
||||
+
|
||||
+/*
|
||||
+ * Return values (< 0 = Error)
|
||||
+ */
|
||||
+#define LZO_E_OK 0
|
||||
+#define LZO_E_ERROR (-1)
|
||||
+#define LZO_E_OUT_OF_MEMORY (-2)
|
||||
+#define LZO_E_NOT_COMPRESSIBLE (-3)
|
||||
+#define LZO_E_INPUT_OVERRUN (-4)
|
||||
+#define LZO_E_OUTPUT_OVERRUN (-5)
|
||||
+#define LZO_E_LOOKBEHIND_OVERRUN (-6)
|
||||
+#define LZO_E_EOF_NOT_FOUND (-7)
|
||||
+#define LZO_E_INPUT_NOT_CONSUMED (-8)
|
||||
+#define LZO_E_NOT_YET_IMPLEMENTED (-9)
|
||||
+
|
||||
+#endif
|
||||
--- /dev/null
|
||||
+++ b/sub-projects/compression/lzo-kmod/Makefile
|
||||
@@ -0,0 +1,8 @@
|
||||
+obj-m += lzo1x_compress.o lzo1x_decompress.o
|
||||
+
|
||||
+all:
|
||||
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
|
||||
+
|
||||
+clean:
|
||||
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
|
||||
+
|
||||
|
|
@ -1,181 +0,0 @@
|
|||
--- a/sub-projects/compression/lzo-kmod/lzo1x_compress.c
|
||||
+++ b/sub-projects/compression/lzo-kmod/lzo1x_compress.c
|
||||
@@ -62,8 +62,12 @@ _lzo1x_1_do_compress(const unsigned char
|
||||
goto literal;
|
||||
|
||||
try_match:
|
||||
+#ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
|
||||
if (get_unaligned((const unsigned short *)m_pos)
|
||||
== get_unaligned((const unsigned short *)ip)) {
|
||||
+#else
|
||||
+ if (m_pos[0] == ip[0] && m_pos[1] == ip[1]) {
|
||||
+#endif
|
||||
if (likely(m_pos[2] == ip[2]))
|
||||
goto match;
|
||||
}
|
||||
@@ -94,9 +98,14 @@ match:
|
||||
}
|
||||
*op++ = tt;
|
||||
}
|
||||
- do {
|
||||
- *op++ = *ii++;
|
||||
- } while (--t > 0);
|
||||
+ if (t >= 2 * 4) {
|
||||
+ memcpy(op, ii, t);
|
||||
+ op += t;
|
||||
+ ii += t;
|
||||
+ } else
|
||||
+ do {
|
||||
+ *op++ = *ii++;
|
||||
+ } while (--t > 0);
|
||||
}
|
||||
|
||||
ip += 3;
|
||||
@@ -208,9 +217,14 @@ int lzo1x_1_compress(const unsigned char
|
||||
|
||||
*op++ = tt;
|
||||
}
|
||||
- do {
|
||||
- *op++ = *ii++;
|
||||
- } while (--t > 0);
|
||||
+ if (t >= 2 * 4) {
|
||||
+ memcpy(op, ii, t);
|
||||
+ op += t;
|
||||
+ ii += t;
|
||||
+ } else
|
||||
+ do {
|
||||
+ *op++ = *ii++;
|
||||
+ } while (--t > 0);
|
||||
}
|
||||
|
||||
*op++ = M4_MARKER | 1;
|
||||
@@ -224,4 +238,3 @@ EXPORT_SYMBOL_GPL(lzo1x_1_compress);
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_DESCRIPTION("LZO1X-1 Compressor");
|
||||
-
|
||||
--- a/sub-projects/compression/lzo-kmod/lzo1x_decompress.c
|
||||
+++ b/sub-projects/compression/lzo-kmod/lzo1x_decompress.c
|
||||
@@ -45,10 +45,7 @@ int lzo1x_decompress_safe(const unsigned
|
||||
goto output_overrun;
|
||||
if (HAVE_IP(t + 1, ip_end, ip))
|
||||
goto input_overrun;
|
||||
- do {
|
||||
- *op++ = *ip++;
|
||||
- } while (--t > 0);
|
||||
- goto first_literal_run;
|
||||
+ goto prep_first_literal_run;
|
||||
}
|
||||
|
||||
while ((ip < ip_end)) {
|
||||
@@ -71,30 +68,27 @@ int lzo1x_decompress_safe(const unsigned
|
||||
if (HAVE_IP(t + 4, ip_end, ip))
|
||||
goto input_overrun;
|
||||
|
||||
- COPY4(op, ip);
|
||||
- op += 4;
|
||||
- ip += 4;
|
||||
- if (--t > 0) {
|
||||
- if (t >= 4) {
|
||||
- do {
|
||||
- COPY4(op, ip);
|
||||
- op += 4;
|
||||
- ip += 4;
|
||||
- t -= 4;
|
||||
- } while (t >= 4);
|
||||
- if (t > 0) {
|
||||
- do {
|
||||
- *op++ = *ip++;
|
||||
- } while (--t > 0);
|
||||
- }
|
||||
- } else {
|
||||
+ t += (4 - 1);
|
||||
+ if (t >= 2 * 4) {
|
||||
+ memcpy(op, ip, t);
|
||||
+ op += t;
|
||||
+ ip += t;
|
||||
+ } else {
|
||||
+ do {
|
||||
+ COPY4(op, ip);
|
||||
+ op += 4;
|
||||
+ ip += 4;
|
||||
+ t -= 4;
|
||||
+ } while (t >= 4);
|
||||
+ if (t > 0) {
|
||||
+prep_first_literal_run:
|
||||
do {
|
||||
*op++ = *ip++;
|
||||
} while (--t > 0);
|
||||
}
|
||||
}
|
||||
|
||||
-first_literal_run:
|
||||
+//first_literal_run:
|
||||
t = *ip++;
|
||||
if (t >= 16)
|
||||
goto match;
|
||||
@@ -139,8 +133,7 @@ match:
|
||||
t += 31 + *ip++;
|
||||
}
|
||||
m_pos = op - 1;
|
||||
- m_pos -= le16_to_cpu(get_unaligned(
|
||||
- (const unsigned short *)ip)) >> 2;
|
||||
+ m_pos -= get_unaligned_le16(ip) >> 2;
|
||||
ip += 2;
|
||||
} else if (t >= 16) {
|
||||
m_pos = op;
|
||||
@@ -158,8 +151,7 @@ match:
|
||||
}
|
||||
t += 7 + *ip++;
|
||||
}
|
||||
- m_pos -= le16_to_cpu(get_unaligned(
|
||||
- (const unsigned short *)ip)) >> 2;
|
||||
+ m_pos -= get_unaligned_le16(ip) >> 2;
|
||||
ip += 2;
|
||||
if (m_pos == op)
|
||||
goto eof_found;
|
||||
@@ -184,21 +176,33 @@ match:
|
||||
if (HAVE_OP(t + 3 - 1, op_end, op))
|
||||
goto output_overrun;
|
||||
|
||||
- if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4) {
|
||||
- COPY4(op, m_pos);
|
||||
- op += 4;
|
||||
- m_pos += 4;
|
||||
- t -= 4 - (3 - 1);
|
||||
- do {
|
||||
+ if (t >= 2 * 4 - (3 - 1)) {
|
||||
+ /*
|
||||
+ * Assume memcpy don't copy
|
||||
+ * more than 32 bytes at once
|
||||
+ */
|
||||
+ if ((op - m_pos) >= 32) {
|
||||
+ t += (3 - 1);
|
||||
+ memcpy(op, m_pos, t);
|
||||
+ op += t;
|
||||
+ m_pos += t;
|
||||
+ } else if ((op - m_pos) >= 4) {
|
||||
COPY4(op, m_pos);
|
||||
op += 4;
|
||||
m_pos += 4;
|
||||
- t -= 4;
|
||||
- } while (t >= 4);
|
||||
- if (t > 0)
|
||||
+ t -= 4 - (3 - 1);
|
||||
do {
|
||||
- *op++ = *m_pos++;
|
||||
- } while (--t > 0);
|
||||
+ COPY4(op, m_pos);
|
||||
+ op += 4;
|
||||
+ m_pos += 4;
|
||||
+ t -= 4;
|
||||
+ } while (t >= 4);
|
||||
+ if (t > 0)
|
||||
+ do {
|
||||
+ *op++ = *m_pos++;
|
||||
+ } while (--t > 0);
|
||||
+ } else
|
||||
+ goto copy_match;
|
||||
} else {
|
||||
copy_match:
|
||||
*op++ = *m_pos++;
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
--- a/ramzswap_drv.c
|
||||
+++ b/ramzswap_drv.c
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <linux/device.h>
|
||||
#include <linux/genhd.h>
|
||||
#include <linux/highmem.h>
|
||||
+#include <linux/slab.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/swap.h>
|
||||
#include <linux/swapops.h>
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
Index: compcache-0.6.2/ramzswap_drv.c
|
||||
===================================================================
|
||||
--- compcache-0.6.2.orig/ramzswap_drv.c 2012-07-25 01:02:39.000000000 +0200
|
||||
+++ compcache-0.6.2/ramzswap_drv.c 2012-07-25 01:04:29.270750850 +0200
|
||||
@@ -525,7 +525,7 @@
|
||||
|
||||
if (S_ISBLK(inode->i_mode)) {
|
||||
bdev = I_BDEV(inode);
|
||||
- ret = bd_claim(bdev, setup_backing_swap);
|
||||
+ ret = blkdev_get(bdev, FMODE_READ | FMODE_WRITE | FMODE_EXCL, setup_backing_swap);
|
||||
if (ret < 0) {
|
||||
bdev = NULL;
|
||||
goto bad_param;
|
||||
@@ -557,7 +557,7 @@
|
||||
|
||||
bad_param:
|
||||
if (bdev)
|
||||
- bd_release(bdev);
|
||||
+ blkdev_put(bdev, FMODE_READ | FMODE_WRITE | FMODE_EXCL);
|
||||
filp_close(swap_file, NULL);
|
||||
|
||||
out:
|
||||
@@ -1097,7 +1097,7 @@
|
||||
/* Close backing swap device, if present */
|
||||
if (rzs->backing_swap) {
|
||||
if (is_backing_blkdev)
|
||||
- bd_release(rzs->backing_swap);
|
||||
+ blkdev_put(rzs->backing_swap, FMODE_READ | FMODE_WRITE | FMODE_EXCL);
|
||||
filp_close(rzs->swap_file, NULL);
|
||||
rzs->backing_swap = NULL;
|
||||
memset(rzs->backing_swap_name, 0, MAX_SWAP_NAME_LEN);
|
||||
|
|
@ -1,74 +0,0 @@
|
|||
#
|
||||
# Copyright (C) 2009-2012 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_NAME:=crda
|
||||
PKG_RELEASE:=1
|
||||
PKG_VERSION:=1.1.2
|
||||
PKG_SOURCE_URL:=http://wireless.kernel.org/download/crda
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
|
||||
PKG_MD5SUM:=5226f65aebacf94baaf820f8b4e06df4
|
||||
|
||||
PKG_REGULATORY_NAME:=regulatory
|
||||
PKG_REGULATORY_VERSION:=2011.04.28
|
||||
PKG_REGULATORY_SOURCE_URL:=http://wireless.kernel.org/download/wireless-regdb/regulatory.bins
|
||||
PKG_REGULATORY_SOURCE:=$(PKG_REGULATORY_VERSION)-$(PKG_REGULATORY_NAME).bin
|
||||
PKG_REGULATORY_MD5SUM:=1535e98bcaba732e2f8e8f62dac6f369
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/crda
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=Central Regulatory Domain Agent (CRDA)
|
||||
DEPENDS:=+libnl-tiny
|
||||
URL:=http://wireless.kernel.org/en/developers/Regulatory/CRDA
|
||||
endef
|
||||
|
||||
define Download/wireless-regdb
|
||||
FILE:=$(PKG_REGULATORY_SOURCE)
|
||||
URL:=$(PKG_REGULATORY_SOURCE_URL)
|
||||
VERSION:=$(PKG_REGULATORY_VERSION)
|
||||
MD5SUM:=$(PKG_REGULATORY_MD5SUM)
|
||||
endef
|
||||
$(eval $(call Download,wireless-regdb))
|
||||
|
||||
define Package/crda/description
|
||||
This is the Central Regulatory Domain Agent for Linux. It serves one
|
||||
purpose: tell Linux kernel what to enforce. In essence it is a udev
|
||||
helper for communication between the kernel and userspace. You only
|
||||
need to run this manually for debugging purposes. For manual changing
|
||||
of regulatory domains use iw (iw reg set) or wpa_supplicant (feature
|
||||
yet to be added).
|
||||
endef
|
||||
|
||||
TARGET_CPPFLAGS := \
|
||||
-I$(STAGING_DIR)/usr/include/libnl-tiny \
|
||||
-D_GNU_SOURCE \
|
||||
$(TARGET_CPPFLAGS)
|
||||
|
||||
MAKE_FLAGS += \
|
||||
NL1FOUND="" NL2FOUND=Y \
|
||||
NLLIBNAME="libnl-tiny" \
|
||||
NLLIBS="-lnl-tiny -lm" \
|
||||
REG_BIN="$(DL_DIR)/$(PKG_REGULATORY_SOURCE)" \
|
||||
crda
|
||||
|
||||
define Package/crda/install
|
||||
$(INSTALL_DIR) $(1)/sbin
|
||||
$(INSTALL_DIR) $(1)/etc/hotplug.d
|
||||
$(INSTALL_DIR) $(1)/etc/hotplug.d/platform
|
||||
$(INSTALL_DIR) $(1)/usr/lib/crda
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/crda $(1)/sbin/
|
||||
$(INSTALL_DATA) ./files/hotplug.rule $(1)/etc/hotplug.d/platform/10-regulatory
|
||||
$(INSTALL_DATA) $(DL_DIR)/$(PKG_REGULATORY_SOURCE) $(1)/usr/lib/crda/regulatory.bin
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,crda))
|
||||
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
#!/bin/sh
|
||||
# Copyright (C) 2009 OpenWrt.org
|
||||
|
||||
[ change = "$ACTION" -a regulatory.0 = "$DEVICENAME" ] && {
|
||||
/sbin/crda
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -35,7 +35,9 @@ LDLIBS += `pkg-config --libs openssl`
|
||||
|
||||
reglib.o: keys-ssl.c
|
||||
|
||||
-else
|
||||
+endif
|
||||
+
|
||||
+ifeq ($(USE_GCRYPT),1)
|
||||
CFLAGS += -DUSE_GCRYPT
|
||||
LDLIBS += -lgcrypt
|
||||
|
||||
|
|
@ -1,70 +0,0 @@
|
|||
#
|
||||
# Copyright (C) 2006-2010 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=goldfish-qemu
|
||||
PKG_REV:=2b8ea29e2bd12f876a4d06647e6077bf72de567e
|
||||
PKG_VERSION:=20090429
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=git://android.git.kernel.org/platform/external/qemu
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_VERSION:=$(PKG_REV)
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
PKG_TARGETS:=bin
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/goldfish-qemu
|
||||
SECTION:=emulator
|
||||
CATEGORY:=Emulators
|
||||
DEPENDS:=@TARGET_goldfish
|
||||
TITLE:=A modified version of the Google Android Emulator
|
||||
URL:=http://www.android.com/
|
||||
endef
|
||||
|
||||
LIBSDL_PATCHED:=sdl-1.2.12-android-20080919
|
||||
|
||||
define Download/libsdl-patched
|
||||
FILE:=$(LIBSDL_PATCHED).tar.gz
|
||||
URL:=http://android.git.kernel.org/pub
|
||||
MD5SUM:=22df8cbb2ecb811938eba8410e861650
|
||||
endef
|
||||
$(eval $(call Download,libsdl-patched))
|
||||
|
||||
Build/Exports=
|
||||
|
||||
define Build/Prepare
|
||||
$(call Build/Prepare/Default)
|
||||
zcat $(DL_DIR)/$(LIBSDL_PATCHED).tar.gz | tar x -C $(PKG_BUILD_DIR)
|
||||
endef
|
||||
|
||||
define Build/Configure
|
||||
[ -x $(PKG_BUILD_DIR)/libsdl/bin/sdl-config ] || ( \
|
||||
cd $(PKG_BUILD_DIR)/$(LIBSDL_PATCHED); \
|
||||
./android-configure --prefix=$(PKG_BUILD_DIR)/libsdl; \
|
||||
make all install; \
|
||||
)
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
(cd $(PKG_BUILD_DIR); \
|
||||
[ -f $(PKG_BUILD_DIR)/objs/config.make ] || \
|
||||
./android-configure.sh --sdl-config=$(PKG_BUILD_DIR)/libsdl/bin/sdl-config \
|
||||
)
|
||||
$(MAKE) -C $(PKG_BUILD_DIR)
|
||||
endef
|
||||
|
||||
define Package/goldfish-qemu/install
|
||||
$(INSTALL_DIR) $(1)
|
||||
$(CP) $(PKG_BUILD_DIR)/objs/emulator $(1)/
|
||||
$(CP) ./skins $(1)/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,goldfish-qemu))
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
--- a/android-configure.sh
|
||||
+++ b/android-configure.sh
|
||||
@@ -656,6 +656,9 @@ case "$CPU" in
|
||||
*) HOST_CPU=$CPU
|
||||
;;
|
||||
esac
|
||||
+case "$OS" in
|
||||
+ darwin*) echo "#define _BSD 1" >> $config_h;;
|
||||
+esac
|
||||
echo "#define HOST_$HOST_CPU 1" >> $config_h
|
||||
log "Generate : $config_h"
|
||||
|
||||
--- a/android/utils/display-quartz.m
|
||||
+++ b/android/utils/display-quartz.m
|
||||
@@ -34,6 +34,7 @@ get_monitor_resolution( int *px_dpi, in
|
||||
int
|
||||
get_nearest_monitor_rect( int *x, int *y, int *width, int *height )
|
||||
{
|
||||
+#if 0
|
||||
SDL_SysWMinfo info;
|
||||
NSWindow* window;
|
||||
|
||||
@@ -108,4 +109,7 @@ get_nearest_monitor_rect( int *x, int
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
+#else
|
||||
+ return -1;
|
||||
+#endif
|
||||
};
|
||||
|
|
@ -1,233 +0,0 @@
|
|||
--- a/android/cmdline-option.c
|
||||
+++ b/android/cmdline-option.c
|
||||
@@ -50,16 +50,6 @@ android_parse_options( int *pargc, char
|
||||
char arg2_tab[64], *arg2 = arg2_tab;
|
||||
int nn;
|
||||
|
||||
- /* process @<name> as a special exception meaning
|
||||
- * '-avd <name>'
|
||||
- */
|
||||
- if (aread[0][0] == '@') {
|
||||
- opt->avd = aread[0]+1;
|
||||
- nargs--;
|
||||
- aread++;
|
||||
- continue;
|
||||
- }
|
||||
-
|
||||
/* anything that isn't an option past this points
|
||||
* exits the loop
|
||||
*/
|
||||
--- a/android/cmdline-options.h
|
||||
+++ b/android/cmdline-options.h
|
||||
@@ -60,21 +60,16 @@
|
||||
*/
|
||||
|
||||
CFG_PARAM( sysdir, "<dir>", "search for system disk images in <dir>" )
|
||||
-CFG_PARAM( system, "<file>", "read initial system image from <file>" )
|
||||
-CFG_PARAM( datadir, "<dir>", "write user data into <dir>" )
|
||||
-CFG_PARAM( kernel, "<file>", "use specific emulated kernel" )
|
||||
-CFG_PARAM( ramdisk, "<file>", "ramdisk image (default <system>/ramdisk.img" )
|
||||
-CFG_PARAM( image, "<file>", "obsolete, use -system <file> instead" )
|
||||
-CFG_PARAM( init_data, "<file>", "initial data image (default <system>/userdata.img" )
|
||||
-CFG_PARAM( initdata, "<file>", "same as '-init-data <file>'" )
|
||||
-CFG_PARAM( data, "<file>", "data image (default <datadir>/userdata-qemu.img" )
|
||||
+CFG_PARAM( system, "<file>", "read system image from <file>, default: <system>/system.img" )
|
||||
+CFG_PARAM( data, "<file>", "data image, default: <system>/data.img" )
|
||||
+CFG_PARAM( kernel, "<file>", "use specific emulated kernel, default: kernel.bin" )
|
||||
+CFG_PARAM( ramdisk, "<file>", "ramdisk image (default <system>/ramdisk.bin" )
|
||||
CFG_PARAM( partition_size, "<size>", "system/data partition size in MBs" )
|
||||
CFG_PARAM( cache, "<file>", "cache partition image (default is temporary file)" )
|
||||
CFG_FLAG ( no_cache, "disable the cache partition" )
|
||||
CFG_FLAG ( nocache, "same as -no-cache" )
|
||||
OPT_PARAM( sdcard, "<file>", "SD card image (default <system>/sdcard.img")
|
||||
OPT_FLAG ( wipe_data, "reset the use data image (copy it from initdata)" )
|
||||
-CFG_PARAM( avd, "<name>", "use a specific android virtual device" )
|
||||
CFG_PARAM( skindir, "<dir>", "search skins in <dir> (default <system>/skins)" )
|
||||
CFG_PARAM( skin, "<name>", "select a given skin" )
|
||||
CFG_FLAG ( no_skin, "don't use any emulator skin" )
|
||||
--- a/android/main.c
|
||||
+++ b/android/main.c
|
||||
@@ -1606,6 +1606,7 @@ report_console( const char* proto_port,
|
||||
* containing 'fileName'. this is *not* the full
|
||||
* path to 'fileName'.
|
||||
*/
|
||||
+
|
||||
static char*
|
||||
_getSdkImagePath( const char* fileName )
|
||||
{
|
||||
@@ -1617,8 +1618,6 @@ _getSdkImagePath( const char* fileName
|
||||
|
||||
static const char* const searchPaths[] = {
|
||||
"", /* program's directory */
|
||||
- "/lib/images", /* this is for SDK 1.0 */
|
||||
- "/../platforms/android-1.1/images", /* this is for SDK 1.1 */
|
||||
NULL
|
||||
};
|
||||
|
||||
@@ -1841,25 +1840,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
- /* legacy support: we used to use -system <dir> and -image <file>
|
||||
- * instead of -sysdir <dir> and -system <file>, so handle this by checking
|
||||
- * whether the options point to directories or files.
|
||||
- */
|
||||
- if (opts->image != NULL) {
|
||||
- if (opts->system != NULL) {
|
||||
- if (opts->sysdir != NULL) {
|
||||
- derror( "You can't use -sysdir, -system and -image at the same time.\n"
|
||||
- "You should probably use '-sysdir <path> -system <file>'.\n" );
|
||||
- exit(2);
|
||||
- }
|
||||
- }
|
||||
- dwarning( "Please note that -image is obsolete and that -system is now used to point\n"
|
||||
- "to the system image. Next time, try using '-sysdir <path> -system <file>' instead.\n" );
|
||||
- opts->sysdir = opts->system;
|
||||
- opts->system = opts->image;
|
||||
- opts->image = NULL;
|
||||
- }
|
||||
- else if (opts->system != NULL && path_is_dir(opts->system)) {
|
||||
+ if (opts->system != NULL && path_is_dir(opts->system)) {
|
||||
if (opts->sysdir != NULL) {
|
||||
derror( "Option -system should now be followed by a file path, not a directory one.\n"
|
||||
"Please use '-sysdir <path>' to point to the system directory.\n" );
|
||||
@@ -1885,49 +1866,11 @@ int main(int argc, char **argv)
|
||||
if (opts->noskin)
|
||||
opts->no_skin = opts->noskin;
|
||||
|
||||
- if (opts->initdata) {
|
||||
- opts->init_data = opts->initdata;
|
||||
- opts->initdata = NULL;
|
||||
- }
|
||||
-
|
||||
- /* If no AVD name was given, try to find the top of the
|
||||
- * Android build tree
|
||||
- */
|
||||
- if (opts->avd == NULL) {
|
||||
- do {
|
||||
- char* out = getenv("ANDROID_PRODUCT_OUT");
|
||||
-
|
||||
- if (out == NULL || out[0] == 0)
|
||||
- break;
|
||||
-
|
||||
- if (!path_exists(out)) {
|
||||
- derror("Can't access ANDROID_PRODUCT_OUT as '%s'\n"
|
||||
- "You need to build the Android system before launching the emulator",
|
||||
- out);
|
||||
- exit(2);
|
||||
- }
|
||||
-
|
||||
- android_build_root = path_parent( out, 4 );
|
||||
- if (android_build_root == NULL || !path_exists(android_build_root)) {
|
||||
- derror("Can't find the Android build root from '%s'\n"
|
||||
- "Please check the definition of the ANDROID_PRODUCT_OUT variable.\n"
|
||||
- "It should point to your product-specific build output directory.\n",
|
||||
- out );
|
||||
- exit(2);
|
||||
- }
|
||||
- android_build_out = out;
|
||||
- D( "found Android build root: %s", android_build_root );
|
||||
- D( "found Android build out: %s", android_build_out );
|
||||
- } while (0);
|
||||
- }
|
||||
/* if no virtual device name is given, and we're not in the
|
||||
* Android build system, we'll need to perform some auto-detection
|
||||
* magic :-)
|
||||
*/
|
||||
- if (opts->avd == NULL && !android_build_out)
|
||||
{
|
||||
- char dataDirIsSystem = 0;
|
||||
-
|
||||
if (!opts->sysdir) {
|
||||
opts->sysdir = _getSdkImagePath("system.img");
|
||||
if (!opts->sysdir) {
|
||||
@@ -1945,47 +1888,30 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (!opts->system) {
|
||||
- opts->system = _getSdkSystemImage(opts->sysdir, "-image", "system.img");
|
||||
- D("autoconfig: -image %s", opts->image);
|
||||
+ opts->system = _getSdkSystemImage(opts->sysdir, "-system", "system.img");
|
||||
+ D("autoconfig: -system %s", opts->system);
|
||||
}
|
||||
|
||||
if (!opts->kernel) {
|
||||
- opts->kernel = _getSdkSystemImage(opts->sysdir, "-kernel", "kernel-qemu");
|
||||
+ opts->kernel = _getSdkSystemImage(opts->sysdir, "-kernel", "kernel.bin");
|
||||
D("autoconfig: -kernel %s", opts->kernel);
|
||||
}
|
||||
|
||||
if (!opts->ramdisk) {
|
||||
- opts->ramdisk = _getSdkSystemImage(opts->sysdir, "-ramdisk", "ramdisk.img");
|
||||
+ opts->ramdisk = _getSdkSystemImage(opts->sysdir, "-ramdisk", "ramdisk.bin");
|
||||
D("autoconfig: -ramdisk %s", opts->ramdisk);
|
||||
}
|
||||
|
||||
- /* if no data directory is specified, use the system directory */
|
||||
- if (!opts->datadir) {
|
||||
- opts->datadir = qemu_strdup(opts->sysdir);
|
||||
- dataDirIsSystem = 1;
|
||||
- D("autoconfig: -datadir %s", opts->sysdir);
|
||||
- }
|
||||
-
|
||||
if (!opts->data) {
|
||||
/* check for userdata-qemu.img in the data directory */
|
||||
- bufprint(tmp, tmpend, "%s/userdata-qemu.img", opts->datadir);
|
||||
- if (!path_exists(tmp)) {
|
||||
- derror(
|
||||
- "You did not provide the name of an Android Virtual Device\n"
|
||||
- "with the '-avd <name>' option. Read -help-avd for more information.\n\n"
|
||||
-
|
||||
- "If you *really* want to *NOT* run an AVD, consider using '-data <file>'\n"
|
||||
- "to specify a data partition image file (I hope you know what you're doing).\n"
|
||||
- );
|
||||
- exit(2);
|
||||
- }
|
||||
+ bufprint(tmp, tmpend, "%s/data.img", opts->sysdir);
|
||||
|
||||
opts->data = qemu_strdup(tmp);
|
||||
D("autoconfig: -data %s", opts->data);
|
||||
}
|
||||
|
||||
- if (!opts->sdcard && opts->datadir) {
|
||||
- bufprint(tmp, tmpend, "%s/sdcard.img", opts->datadir);
|
||||
+ if (!opts->sdcard && opts->sysdir) {
|
||||
+ bufprint(tmp, tmpend, "%s/sdcard.img", opts->sysdir);
|
||||
if (path_exists(tmp)) {
|
||||
opts->sdcard = qemu_strdup(tmp);
|
||||
D("autoconfig: -sdcard %s", opts->sdcard);
|
||||
@@ -2029,19 +1955,6 @@ int main(int argc, char **argv)
|
||||
android_avdParams->skinName = opts->skin;
|
||||
android_avdParams->skinRootPath = opts->skindir;
|
||||
|
||||
- /* setup the virtual device differently depending on whether
|
||||
- * we are in the Android build system or not
|
||||
- */
|
||||
- if (opts->avd != NULL)
|
||||
- {
|
||||
- android_avdInfo = avdInfo_new( opts->avd, android_avdParams );
|
||||
- if (android_avdInfo == NULL) {
|
||||
- /* an error message has already been printed */
|
||||
- dprint("could not find virtual device named '%s'", opts->avd);
|
||||
- exit(1);
|
||||
- }
|
||||
- }
|
||||
- else
|
||||
{
|
||||
if (!android_build_out) {
|
||||
android_build_out = android_build_root = opts->sysdir;
|
||||
--- a/android/avd/info.c
|
||||
+++ b/android/avd/info.c
|
||||
@@ -1233,10 +1233,8 @@ _getBuildImagePaths( AvdInfo* i, AvdInf
|
||||
** take care of checking the state
|
||||
**/
|
||||
imageLoader_set ( l, AVD_IMAGE_INITSYSTEM );
|
||||
- imageLoader_load( l, IMAGE_REQUIRED | IMAGE_DONT_LOCK );
|
||||
-
|
||||
- /* force the system image to read-only status */
|
||||
- l->pState[0] = IMAGE_STATE_READONLY;
|
||||
+ l->pState[0] = IMAGE_STATE_MUSTLOCK;
|
||||
+ imageLoader_load( l, IMAGE_REQUIRED );
|
||||
|
||||
/** cache partition handling
|
||||
**/
|
||||
|
Before Width: | Height: | Size: 3.4 KiB |
|
Before Width: | Height: | Size: 4 KiB |
|
Before Width: | Height: | Size: 4 KiB |
|
Before Width: | Height: | Size: 3.4 KiB |
|
Before Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 44 KiB |
|
Before Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 11 KiB |
|
|
@ -1,380 +0,0 @@
|
|||
parts {
|
||||
device {
|
||||
background {
|
||||
image device.png
|
||||
}
|
||||
display {
|
||||
width 320
|
||||
height 480
|
||||
x 31
|
||||
y 72
|
||||
}
|
||||
|
||||
buttons {
|
||||
soft-left {
|
||||
image menu.png
|
||||
x 147
|
||||
y 555
|
||||
}
|
||||
home {
|
||||
image home.png
|
||||
x 48
|
||||
y 590
|
||||
}
|
||||
back {
|
||||
image back.png
|
||||
x 286
|
||||
y 590
|
||||
}
|
||||
dpad-up {
|
||||
image arrow_up.png
|
||||
x 140
|
||||
y 595
|
||||
}
|
||||
dpad-down {
|
||||
image arrow_down.png
|
||||
x 140
|
||||
y 656
|
||||
}
|
||||
dpad-left {
|
||||
image arrow_left.png
|
||||
x 111
|
||||
y 598
|
||||
}
|
||||
dpad-right {
|
||||
image arrow_right.png
|
||||
x 222
|
||||
y 598
|
||||
}
|
||||
dpad-center {
|
||||
image select.png
|
||||
x 142
|
||||
y 626
|
||||
}
|
||||
phone-dial {
|
||||
image send.png
|
||||
x 48
|
||||
y 646
|
||||
}
|
||||
phone-hangup {
|
||||
image end.png
|
||||
x 286
|
||||
y 646
|
||||
}
|
||||
|
||||
power {
|
||||
image power.png
|
||||
x -38
|
||||
y 52
|
||||
}
|
||||
|
||||
volume-up {
|
||||
image volume_up.png
|
||||
x 362
|
||||
y 260
|
||||
}
|
||||
|
||||
volume-down {
|
||||
image volume_down.png
|
||||
x 362
|
||||
y 310
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
keyboard {
|
||||
background {
|
||||
image keyboard.png
|
||||
}
|
||||
buttons {
|
||||
1 {
|
||||
image key.png
|
||||
x 0
|
||||
y 0
|
||||
}
|
||||
2 {
|
||||
image key.png
|
||||
x 37
|
||||
y 0
|
||||
}
|
||||
3 {
|
||||
image key.png
|
||||
x 74
|
||||
y 0
|
||||
}
|
||||
4 {
|
||||
image key.png
|
||||
x 111
|
||||
y 0
|
||||
}
|
||||
5 {
|
||||
image key.png
|
||||
x 148
|
||||
y 0
|
||||
}
|
||||
6 {
|
||||
image key.png
|
||||
x 185
|
||||
y 0
|
||||
}
|
||||
7 {
|
||||
image key.png
|
||||
x 222
|
||||
y 0
|
||||
}
|
||||
8 {
|
||||
image key.png
|
||||
x 259
|
||||
y 0
|
||||
}
|
||||
9 {
|
||||
image key.png
|
||||
x 296
|
||||
y 0
|
||||
}
|
||||
0 {
|
||||
image key.png
|
||||
x 333
|
||||
y 0
|
||||
}
|
||||
|
||||
q {
|
||||
image key.png
|
||||
x 0
|
||||
y 36
|
||||
}
|
||||
w {
|
||||
image key.png
|
||||
x 37
|
||||
y 36
|
||||
}
|
||||
e {
|
||||
image key.png
|
||||
x 74
|
||||
y 36
|
||||
}
|
||||
r {
|
||||
image key.png
|
||||
x 111
|
||||
y 36
|
||||
}
|
||||
t {
|
||||
image key.png
|
||||
x 148
|
||||
y 36
|
||||
}
|
||||
y {
|
||||
image key.png
|
||||
x 185
|
||||
y 36
|
||||
}
|
||||
u {
|
||||
image key.png
|
||||
x 222
|
||||
y 36
|
||||
}
|
||||
i {
|
||||
image key.png
|
||||
x 259
|
||||
y 36
|
||||
}
|
||||
o {
|
||||
image key.png
|
||||
x 296
|
||||
y 36
|
||||
}
|
||||
p {
|
||||
image key.png
|
||||
x 333
|
||||
y 36
|
||||
}
|
||||
|
||||
a {
|
||||
image key.png
|
||||
x 0
|
||||
y 72
|
||||
}
|
||||
s {
|
||||
image key.png
|
||||
x 37
|
||||
y 72
|
||||
}
|
||||
d {
|
||||
image key.png
|
||||
x 74
|
||||
y 72
|
||||
}
|
||||
f {
|
||||
image key.png
|
||||
x 111
|
||||
y 72
|
||||
}
|
||||
g {
|
||||
image key.png
|
||||
x 148
|
||||
y 72
|
||||
}
|
||||
h {
|
||||
image key.png
|
||||
x 185
|
||||
y 72
|
||||
}
|
||||
j {
|
||||
image key.png
|
||||
x 222
|
||||
y 72
|
||||
}
|
||||
k {
|
||||
image key.png
|
||||
x 259
|
||||
y 72
|
||||
}
|
||||
l {
|
||||
image key.png
|
||||
x 296
|
||||
y 72
|
||||
}
|
||||
DEL {
|
||||
image key.png
|
||||
x 333
|
||||
y 72
|
||||
}
|
||||
|
||||
CAP {
|
||||
image key.png
|
||||
x 0
|
||||
y 108
|
||||
}
|
||||
z {
|
||||
image key.png
|
||||
x 37
|
||||
y 108
|
||||
}
|
||||
x {
|
||||
image key.png
|
||||
x 74
|
||||
y 108
|
||||
}
|
||||
c {
|
||||
image key.png
|
||||
x 111
|
||||
y 108
|
||||
}
|
||||
v {
|
||||
image key.png
|
||||
x 148
|
||||
y 108
|
||||
}
|
||||
b {
|
||||
image key.png
|
||||
x 185
|
||||
y 108
|
||||
}
|
||||
n {
|
||||
image key.png
|
||||
x 222
|
||||
y 108
|
||||
}
|
||||
m {
|
||||
image key.png
|
||||
x 259
|
||||
y 108
|
||||
}
|
||||
PERIOD {
|
||||
image key.png
|
||||
x 296
|
||||
y 108
|
||||
}
|
||||
ENTER {
|
||||
image key.png
|
||||
x 333
|
||||
y 108
|
||||
}
|
||||
|
||||
ALT {
|
||||
image key.png
|
||||
x 0
|
||||
y 144
|
||||
}
|
||||
SYM {
|
||||
image key.png
|
||||
x 37
|
||||
y 144
|
||||
}
|
||||
AT {
|
||||
image key.png
|
||||
x 74
|
||||
y 144
|
||||
}
|
||||
SPACE {
|
||||
image spacebar.png
|
||||
x 111
|
||||
y 144
|
||||
}
|
||||
SLASH {
|
||||
image key.png
|
||||
x 259
|
||||
y 144
|
||||
}
|
||||
COMMA {
|
||||
image key.png
|
||||
x 296
|
||||
y 144
|
||||
}
|
||||
ALT2 {
|
||||
image key.png
|
||||
x 333
|
||||
y 144
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
layouts {
|
||||
portrait {
|
||||
width 900
|
||||
height 730
|
||||
color 0xe0e0e0
|
||||
event EV_SW:0:1
|
||||
|
||||
part1 {
|
||||
name device
|
||||
x 40
|
||||
y -18
|
||||
}
|
||||
part2 {
|
||||
name keyboard
|
||||
x 480
|
||||
y 200
|
||||
}
|
||||
}
|
||||
|
||||
landscape {
|
||||
width 900
|
||||
height 670
|
||||
color 0xe0e0e0
|
||||
event EV_SW:0:0
|
||||
|
||||
part1 {
|
||||
name device
|
||||
x 50
|
||||
y 440
|
||||
rotation 3
|
||||
}
|
||||
part2 {
|
||||
name keyboard
|
||||
x 250
|
||||
y 470
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
keyboard {
|
||||
charmap qwerty2
|
||||
}
|
||||
|
||||
network {
|
||||
speed full
|
||||
delay none
|
||||
}
|
||||
|
Before Width: | Height: | Size: 3 KiB |
|
Before Width: | Height: | Size: 3.7 KiB |
|
Before Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 3.8 KiB |
|
|
@ -1,43 +0,0 @@
|
|||
#
|
||||
# Copyright (C) 2008 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_NAME:=gpioctl
|
||||
PKG_RELEASE:=1
|
||||
PKG_VERSION:=1.0
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/gpioctl
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=Tool for controlling gpio pins
|
||||
DEPENDS:=@GPIO_SUPPORT
|
||||
endef
|
||||
|
||||
define Package/gpioctl/description
|
||||
Tool for controlling gpio pins
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
mkdir -p $(PKG_BUILD_DIR)
|
||||
$(CP) ./src/* $(PKG_BUILD_DIR)/
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
$(MAKE) -C $(PKG_BUILD_DIR) \
|
||||
$(TARGET_CONFIGURE_OPTS) CFLAGS="$(TARGET_CFLAGS) -I$(LINUX_DIR)/include"
|
||||
endef
|
||||
|
||||
define Package/gpioctl/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/gpioctl $(1)/usr/bin/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,gpioctl))
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
PROGS = gpioctl
|
||||
|
||||
INSTDIR = $(prefix)/usr/bin
|
||||
INSTMODE = 0755
|
||||
INSTOWNER = root
|
||||
INSTGROUP = root
|
||||
|
||||
OBJS = main.o
|
||||
|
||||
all: $(PROGS)
|
||||
$(PROGS): $(OBJS)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS) -o $@
|
||||
$(STRIP) $@
|
||||
|
||||
%.o: %.c
|
||||
$(CC) -c $(CFLAGS) $^ -o $@
|
||||
|
||||
install: $(PROGS)
|
||||
$(INSTALL) -d $(INSTDIR)
|
||||
$(INSTALL) -m $(INSTMODE) -o $(INSTOWNER) -g $(INSTGROUP) $(PROGS) $(INSTDIR)
|
||||
|
||||
clean:
|
||||
rm -f $(PROGS) *.o core
|
||||
|
||||
|
|
@ -1,76 +0,0 @@
|
|||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 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; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307USA
|
||||
*
|
||||
* Feedback, Bugs... blogic@openwrt.org
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <linux/gpio_dev.h>
|
||||
#include <linux/ioctl.h>
|
||||
|
||||
void
|
||||
print_usage()
|
||||
{
|
||||
printf("gpioctl dirin|dirout|get|set|clear gpio\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int gpio_pin;
|
||||
int fd;
|
||||
int result = 0;
|
||||
|
||||
if (argc != 3)
|
||||
{
|
||||
print_usage();
|
||||
}
|
||||
|
||||
if ((fd = open("/dev/gpio", O_RDWR)) < 0)
|
||||
{
|
||||
printf("Error whilst opening /dev/gpio\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
gpio_pin = atoi(argv[2]);
|
||||
|
||||
printf("using gpio pin %d\n", gpio_pin);
|
||||
|
||||
if (!strcmp(argv[1], "dirin"))
|
||||
{
|
||||
ioctl(fd, GPIO_DIR_IN, gpio_pin);
|
||||
} else if (!strcmp(argv[1], "dirout"))
|
||||
{
|
||||
ioctl(fd, GPIO_DIR_OUT, gpio_pin);
|
||||
} else if (!strcmp(argv[1], "get"))
|
||||
{
|
||||
result = ioctl(fd, GPIO_GET, gpio_pin);
|
||||
printf("Pin %d is %s\n", gpio_pin, (result ? "HIGH" : "LOW"));
|
||||
} else if (!strcmp(argv[1], "set"))
|
||||
{
|
||||
ioctl(fd, GPIO_SET, gpio_pin);
|
||||
} else if (!strcmp(argv[1], "clear"))
|
||||
{
|
||||
ioctl(fd, GPIO_CLEAR, gpio_pin);
|
||||
} else print_usage();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
@ -1,111 +0,0 @@
|
|||
#
|
||||
# Copyright (C) 2006-2010 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_NAME:=grub
|
||||
PKG_VERSION:=0.97
|
||||
PKG_RELEASE:=3
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=ftp://alpha.gnu.org/gnu/grub
|
||||
PKG_MD5SUM:=cd3f3eb54446be6003156158d51f4884
|
||||
|
||||
PKG_BUILD_DEPENDS:= grub/host
|
||||
PKG_INSTALL:=1
|
||||
|
||||
include $(INCLUDE_DIR)/host-build.mk
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/grub
|
||||
SUBMENU:=Boot Loaders
|
||||
CATEGORY:=Utilities
|
||||
SECTION:=utils
|
||||
TITLE:=GRand Unified Bootloader
|
||||
URL:=http://www.gnu.org/software/grub/
|
||||
DEPENDS:=@TARGET_x86
|
||||
endef
|
||||
|
||||
|
||||
MY_CONFIGURE_ARGS += \
|
||||
--disable-auto-linux-mem-opt \
|
||||
--disable-hercules \
|
||||
--without-curses \
|
||||
|
||||
MY_CONFIGURE_VARS += \
|
||||
grub_cv_prog_objcopy_absolute=yes \
|
||||
|
||||
CONFIGURE_ARGS += $(MY_CONFIGURE_ARGS)
|
||||
|
||||
CONFIGURE_VARS += $(MY_CONFIGURE_VARS)
|
||||
|
||||
ifeq ($(HOST_OS),Darwin)
|
||||
HOST_CFLAGS += $(call host-cc-option,-m32)
|
||||
HOST_CFLAGS += $(call host-cc-option,-fnested-functions)
|
||||
endif
|
||||
|
||||
ifeq ($(HOST_OS),FreeBSD)
|
||||
ifeq ($(HOST_ARCH),amd64)
|
||||
HOST_CFLAGS += $(call host-cc-option,-m32)
|
||||
HOST_CFLAGS += $(call host-cc-option,-B/usr/lib32)
|
||||
HOST_CFLAGS += $(call host-cc-option,-L/usr/lib32)
|
||||
endif
|
||||
endif
|
||||
|
||||
HOST_CFLAGS += $(call host-cc-option,-fno-stack-protector)
|
||||
HOST_CFLAGS += $(call host-cc-option,-U_FORTIFY_SOURCE)
|
||||
|
||||
HOST_CONFIGURE_ARGS += $(MY_CONFIGURE_ARGS) \
|
||||
--sbindir="$(STAGING_DIR_HOST)/bin" \
|
||||
--disable-graphics \
|
||||
|
||||
HOST_CONFIGURE_VARS += $(MY_CONFIGURE_VARS)
|
||||
|
||||
define Host/Configure
|
||||
(cd $(HOST_BUILD_DIR); aclocal && autoconf && automake)
|
||||
$(call Host/Configure/Default)
|
||||
endef
|
||||
|
||||
ifeq ($(HOST_OS),Darwin)
|
||||
define Host/Compile
|
||||
$(MAKE) -C $(HOST_BUILD_DIR)/lib
|
||||
$(MAKE) -C $(HOST_BUILD_DIR)/stage2 libgrub.a
|
||||
$(MAKE) -C $(HOST_BUILD_DIR)/grub
|
||||
endef
|
||||
define Host/Install
|
||||
$(MAKE) -C $(HOST_BUILD_DIR)/grub install
|
||||
endef
|
||||
endif
|
||||
|
||||
define Build/InstallDev
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/grub $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
define Package/grub/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/bin/* $(1)/usr/bin/
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/* $(1)/usr/lib/
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/sbin/* $(1)/usr/sbin/
|
||||
endef
|
||||
|
||||
ifeq ($(HOST_ARCH),x86_64)
|
||||
define Require/working-gcc-m32
|
||||
echo 'int main(int argc, char **argv) { return 0; }' | \
|
||||
gcc -x c -o $(TMP_DIR)/a.out - -m32 -lc
|
||||
endef
|
||||
endif
|
||||
|
||||
$(eval $(call Require,working-gcc-m32, \
|
||||
Please install 32 bit development files. (gcc-multilib on Debian/Ubuntu, gcc.i686, libgcc.i686, and glibc-devel.i686 on CentOS/Fedora/RHEL) \
|
||||
))
|
||||
|
||||
$(eval $(call HostBuild))
|
||||
$(eval $(call BuildPackage,grub))
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
--- a/stage1/Makefile.in
|
||||
+++ b/stage1/Makefile.in
|
||||
@@ -427,7 +427,7 @@ uninstall-am: uninstall-info-am uninstal
|
||||
uninstall-nodist_pkglibDATA
|
||||
|
||||
.exec:
|
||||
- $(OBJCOPY) -O binary $< $@
|
||||
+ $(OBJCOPY) -O binary -R .comment -R .note -R .note.gnu.build-id $< $@
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
||||
--- a/stage2/Makefile.in
|
||||
+++ b/stage2/Makefile.in
|
||||
@@ -3244,7 +3244,7 @@ pxegrub: pxeloader diskless
|
||||
-rm -f $@
|
||||
cat $^ > $@
|
||||
.exec:
|
||||
- $(OBJCOPY) -O binary $< $@
|
||||
+ $(OBJCOPY) -O binary -R .comment -R .note -R .note.gnu.build-id $< $@
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
||||
|
|
@ -1,267 +0,0 @@
|
|||
--- a/stage2/fsys_ext2fs.c
|
||||
+++ b/stage2/fsys_ext2fs.c
|
||||
@@ -51,6 +51,9 @@ typedef unsigned int __u32;
|
||||
#define EXT2_TIND_BLOCK (EXT2_DIND_BLOCK + 1)
|
||||
#define EXT2_N_BLOCKS (EXT2_TIND_BLOCK + 1)
|
||||
|
||||
+/* Inode flags */
|
||||
+#define EXT4_EXTENTS_FL 0x00080000 /* Inode uses extents */
|
||||
+
|
||||
/* include/linux/ext2_fs.h */
|
||||
struct ext2_super_block
|
||||
{
|
||||
@@ -191,6 +194,42 @@ struct ext2_dir_entry
|
||||
#define EXT2_DIR_REC_LEN(name_len) (((name_len) + 8 + EXT2_DIR_ROUND) & \
|
||||
~EXT2_DIR_ROUND)
|
||||
|
||||
+/* linux/ext4_fs_extents.h */
|
||||
+/*
|
||||
+ * This is the extent on-disk structure.
|
||||
+ * It's used at the bottom of the tree.
|
||||
+ */
|
||||
+struct ext4_extent {
|
||||
+ __u32 ee_block; /* first logical block extent covers */
|
||||
+ __u16 ee_len; /* number of blocks covered by extent */
|
||||
+ __u16 ee_start_hi; /* high 16 bits of physical block */
|
||||
+ __u32 ee_start; /* low 32 bits of physical block */
|
||||
+};
|
||||
+
|
||||
+/*
|
||||
+ * This is index on-disk structure.
|
||||
+ * It's used at all the levels except the bottom.
|
||||
+ */
|
||||
+struct ext4_extent_idx {
|
||||
+ __u32 ei_block; /* index covers logical blocks from 'block' */
|
||||
+ __u32 ei_leaf; /* pointer to the physical block of the next *
|
||||
+ * level. leaf or next index could be there */
|
||||
+ __u16 ei_leaf_hi; /* high 16 bits of physical block */
|
||||
+ __u16 ei_unused;
|
||||
+};
|
||||
+
|
||||
+/*
|
||||
+ * Each block (leaves and indexes), even inode-stored has header.
|
||||
+ */
|
||||
+struct ext4_extent_header {
|
||||
+ __u16 eh_magic; /* probably will support different formats */
|
||||
+ __u16 eh_entries; /* number of valid entries */
|
||||
+ __u16 eh_max; /* capacity of store in entries */
|
||||
+ __u16 eh_depth; /* has tree real underlying blocks? */
|
||||
+ __u32 eh_generation; /* generation of the tree */
|
||||
+};
|
||||
+
|
||||
+#define EXT4_EXT_MAGIC 0xf30a
|
||||
|
||||
/* ext2/super.c */
|
||||
#define log2(n) ffz(~(n))
|
||||
@@ -279,6 +318,27 @@ ext2_rdfsb (int fsblock, int buffer)
|
||||
EXT2_BLOCK_SIZE (SUPERBLOCK), (char *) buffer);
|
||||
}
|
||||
|
||||
+/* Walk through extents index tree to find the good leaf */
|
||||
+static struct ext4_extent_header *
|
||||
+ext4_recurse_extent_index(struct ext4_extent_header *extent_block, int logical_block)
|
||||
+{
|
||||
+ int i;
|
||||
+ struct ext4_extent_idx *index = (struct ext4_extent_idx *) (extent_block + 1);
|
||||
+ if (extent_block->eh_magic != EXT4_EXT_MAGIC)
|
||||
+ return NULL;
|
||||
+ if (extent_block->eh_depth == 0)
|
||||
+ return extent_block;
|
||||
+ for (i = 0; i < extent_block->eh_entries; i++)
|
||||
+ {
|
||||
+ if (logical_block < index[i].ei_block)
|
||||
+ break;
|
||||
+ }
|
||||
+ if (i == 0 || !ext2_rdfsb(index[i-1].ei_leaf, DATABLOCK1))
|
||||
+ return NULL;
|
||||
+ return (ext4_recurse_extent_index((struct ext4_extent_header *) DATABLOCK1, logical_block));
|
||||
+}
|
||||
+
|
||||
+
|
||||
/* from
|
||||
ext2/inode.c:ext2_bmap()
|
||||
*/
|
||||
@@ -287,7 +347,6 @@ ext2_rdfsb (int fsblock, int buffer)
|
||||
static int
|
||||
ext2fs_block_map (int logical_block)
|
||||
{
|
||||
-
|
||||
#ifdef E2DEBUG
|
||||
unsigned char *i;
|
||||
for (i = (unsigned char *) INODE;
|
||||
@@ -308,82 +367,106 @@ ext2fs_block_map (int logical_block)
|
||||
printf ("logical block %d\n", logical_block);
|
||||
#endif /* E2DEBUG */
|
||||
|
||||
- /* if it is directly pointed to by the inode, return that physical addr */
|
||||
- if (logical_block < EXT2_NDIR_BLOCKS)
|
||||
+ if (!(INODE->i_flags & EXT4_EXTENTS_FL))
|
||||
{
|
||||
-#ifdef E2DEBUG
|
||||
- printf ("returning %d\n", (unsigned char *) (INODE->i_block[logical_block]));
|
||||
- printf ("returning %d\n", INODE->i_block[logical_block]);
|
||||
-#endif /* E2DEBUG */
|
||||
- return INODE->i_block[logical_block];
|
||||
- }
|
||||
- /* else */
|
||||
- logical_block -= EXT2_NDIR_BLOCKS;
|
||||
- /* try the indirect block */
|
||||
- if (logical_block < EXT2_ADDR_PER_BLOCK (SUPERBLOCK))
|
||||
- {
|
||||
- if (mapblock1 != 1
|
||||
- && !ext2_rdfsb (INODE->i_block[EXT2_IND_BLOCK], DATABLOCK1))
|
||||
- {
|
||||
- errnum = ERR_FSYS_CORRUPT;
|
||||
- return -1;
|
||||
- }
|
||||
- mapblock1 = 1;
|
||||
- return ((__u32 *) DATABLOCK1)[logical_block];
|
||||
- }
|
||||
- /* else */
|
||||
- logical_block -= EXT2_ADDR_PER_BLOCK (SUPERBLOCK);
|
||||
- /* now try the double indirect block */
|
||||
- if (logical_block < (1 << (EXT2_ADDR_PER_BLOCK_BITS (SUPERBLOCK) * 2)))
|
||||
- {
|
||||
- int bnum;
|
||||
- if (mapblock1 != 2
|
||||
- && !ext2_rdfsb (INODE->i_block[EXT2_DIND_BLOCK], DATABLOCK1))
|
||||
- {
|
||||
- errnum = ERR_FSYS_CORRUPT;
|
||||
- return -1;
|
||||
- }
|
||||
- mapblock1 = 2;
|
||||
- if ((bnum = (((__u32 *) DATABLOCK1)
|
||||
- [logical_block >> EXT2_ADDR_PER_BLOCK_BITS (SUPERBLOCK)]))
|
||||
- != mapblock2
|
||||
- && !ext2_rdfsb (bnum, DATABLOCK2))
|
||||
- {
|
||||
- errnum = ERR_FSYS_CORRUPT;
|
||||
- return -1;
|
||||
- }
|
||||
- mapblock2 = bnum;
|
||||
+ /* if it is directly pointed to by the inode, return that physical addr */
|
||||
+ if (logical_block < EXT2_NDIR_BLOCKS)
|
||||
+ {
|
||||
+#ifdef E2DEBUG
|
||||
+ printf ("returning %d\n", (unsigned char *) (INODE->i_block[logical_block]));
|
||||
+ printf ("returning %d\n", INODE->i_block[logical_block]);
|
||||
+#endif /* E2DEBUG */
|
||||
+ return INODE->i_block[logical_block];
|
||||
+ }
|
||||
+ /* else */
|
||||
+ logical_block -= EXT2_NDIR_BLOCKS;
|
||||
+ /* try the indirect block */
|
||||
+ if (logical_block < EXT2_ADDR_PER_BLOCK (SUPERBLOCK))
|
||||
+ {
|
||||
+ if (mapblock1 != 1 && !ext2_rdfsb (INODE->i_block[EXT2_IND_BLOCK], DATABLOCK1))
|
||||
+ {
|
||||
+ errnum = ERR_FSYS_CORRUPT;
|
||||
+ return -1;
|
||||
+ }
|
||||
+ mapblock1 = 1;
|
||||
+ return ((__u32 *) DATABLOCK1)[logical_block];
|
||||
+ }
|
||||
+ /* else */
|
||||
+ logical_block -= EXT2_ADDR_PER_BLOCK (SUPERBLOCK);
|
||||
+ /* now try the double indirect block */
|
||||
+ if (logical_block < (1 << (EXT2_ADDR_PER_BLOCK_BITS (SUPERBLOCK) * 2)))
|
||||
+ {
|
||||
+ int bnum;
|
||||
+ if (mapblock1 != 2 && !ext2_rdfsb (INODE->i_block[EXT2_DIND_BLOCK], DATABLOCK1))
|
||||
+ {
|
||||
+ errnum = ERR_FSYS_CORRUPT;
|
||||
+ return -1;
|
||||
+ }
|
||||
+ mapblock1 = 2;
|
||||
+ if ((bnum = (((__u32 *) DATABLOCK1)
|
||||
+ [logical_block >> EXT2_ADDR_PER_BLOCK_BITS (SUPERBLOCK)]))
|
||||
+ != mapblock2
|
||||
+ && !ext2_rdfsb (bnum, DATABLOCK2))
|
||||
+ {
|
||||
+ errnum = ERR_FSYS_CORRUPT;
|
||||
+ return -1;
|
||||
+ }
|
||||
+ mapblock2 = bnum;
|
||||
+ return ((__u32 *) DATABLOCK2)
|
||||
+ [logical_block & (EXT2_ADDR_PER_BLOCK (SUPERBLOCK) - 1)];
|
||||
+ }
|
||||
+ /* else */
|
||||
+ mapblock2 = -1;
|
||||
+ logical_block -= (1 << (EXT2_ADDR_PER_BLOCK_BITS (SUPERBLOCK) * 2));
|
||||
+ if (mapblock1 != 3
|
||||
+ && !ext2_rdfsb (INODE->i_block[EXT2_TIND_BLOCK], DATABLOCK1))
|
||||
+ {
|
||||
+ errnum = ERR_FSYS_CORRUPT;
|
||||
+ return -1;
|
||||
+ }
|
||||
+ mapblock1 = 3;
|
||||
+ if (!ext2_rdfsb (((__u32 *) DATABLOCK1)
|
||||
+ [logical_block >> (EXT2_ADDR_PER_BLOCK_BITS (SUPERBLOCK)
|
||||
+ * 2)],
|
||||
+ DATABLOCK2))
|
||||
+ {
|
||||
+ errnum = ERR_FSYS_CORRUPT;
|
||||
+ return -1;
|
||||
+ }
|
||||
+ if (!ext2_rdfsb (((__u32 *) DATABLOCK2)
|
||||
+ [(logical_block >> EXT2_ADDR_PER_BLOCK_BITS (SUPERBLOCK))
|
||||
+ & (EXT2_ADDR_PER_BLOCK (SUPERBLOCK) - 1)],
|
||||
+ DATABLOCK2))
|
||||
+ {
|
||||
+ errnum = ERR_FSYS_CORRUPT;
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
return ((__u32 *) DATABLOCK2)
|
||||
- [logical_block & (EXT2_ADDR_PER_BLOCK (SUPERBLOCK) - 1)];
|
||||
+ [logical_block & (EXT2_ADDR_PER_BLOCK (SUPERBLOCK) - 1)];
|
||||
}
|
||||
- /* else */
|
||||
- mapblock2 = -1;
|
||||
- logical_block -= (1 << (EXT2_ADDR_PER_BLOCK_BITS (SUPERBLOCK) * 2));
|
||||
- if (mapblock1 != 3
|
||||
- && !ext2_rdfsb (INODE->i_block[EXT2_TIND_BLOCK], DATABLOCK1))
|
||||
- {
|
||||
- errnum = ERR_FSYS_CORRUPT;
|
||||
- return -1;
|
||||
- }
|
||||
- mapblock1 = 3;
|
||||
- if (!ext2_rdfsb (((__u32 *) DATABLOCK1)
|
||||
- [logical_block >> (EXT2_ADDR_PER_BLOCK_BITS (SUPERBLOCK)
|
||||
- * 2)],
|
||||
- DATABLOCK2))
|
||||
- {
|
||||
- errnum = ERR_FSYS_CORRUPT;
|
||||
- return -1;
|
||||
- }
|
||||
- if (!ext2_rdfsb (((__u32 *) DATABLOCK2)
|
||||
- [(logical_block >> EXT2_ADDR_PER_BLOCK_BITS (SUPERBLOCK))
|
||||
- & (EXT2_ADDR_PER_BLOCK (SUPERBLOCK) - 1)],
|
||||
- DATABLOCK2))
|
||||
+ /* inode is in extents format */
|
||||
+ else
|
||||
{
|
||||
+ int i;
|
||||
+ struct ext4_extent_header *extent_hdr =
|
||||
+ ext4_recurse_extent_index((struct ext4_extent_header *) INODE->i_block, logical_block);
|
||||
+ struct ext4_extent *extent = (struct ext4_extent *) (extent_hdr + 1);
|
||||
+ if ( extent_hdr == NULL || extent_hdr->eh_magic != EXT4_EXT_MAGIC)
|
||||
+ {
|
||||
+ errnum = ERR_FSYS_CORRUPT;
|
||||
+ return -1;
|
||||
+ }
|
||||
+ for (i = 0; i<extent_hdr->eh_entries; i++)
|
||||
+ {
|
||||
+ if (extent[i].ee_block <= logical_block && logical_block < extent[i].ee_block + extent[i].ee_len && !(extent[i].ee_len>>15))
|
||||
+ return (logical_block - extent[i].ee_block + extent[i].ee_start);
|
||||
+ }
|
||||
+ /* We should not arrive here */
|
||||
+
|
||||
errnum = ERR_FSYS_CORRUPT;
|
||||
return -1;
|
||||
}
|
||||
- return ((__u32 *) DATABLOCK2)
|
||||
- [logical_block & (EXT2_ADDR_PER_BLOCK (SUPERBLOCK) - 1)];
|
||||
}
|
||||
|
||||
/* preconditions: all preconds of ext2fs_block_map */
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
From 8858927ddc6797489cad322fc2d2134aeae543cd Mon Sep 17 00:00:00 2001
|
||||
From: Arnaud Lacombe <lacombar@gmail.com>
|
||||
Date: Sun, 11 Dec 2011 16:44:02 -0500
|
||||
Subject: [PATCH] add-stage2-ldscripts
|
||||
|
||||
---
|
||||
stage2/Makefile.am | 2 +-
|
||||
stage2/Makefile.in | 2 +-
|
||||
stage2/stage2.ldscripts | 30 ++++++++++++++++++++++++++++++
|
||||
3 files changed, 32 insertions(+), 2 deletions(-)
|
||||
create mode 100644 stage2/stage2.ldscripts
|
||||
|
||||
diff --git a/stage2/Makefile.am b/stage2/Makefile.am
|
||||
index f8e6d42..ea28a4d 100644
|
||||
--- a/stage2/Makefile.am
|
||||
+++ b/stage2/Makefile.am
|
||||
@@ -55,7 +55,7 @@ noinst_PROGRAMS = pre_stage2.exec start.exec start_eltorito.exec \
|
||||
endif
|
||||
MOSTLYCLEANFILES = $(noinst_PROGRAMS)
|
||||
|
||||
-PRE_STAGE2_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,8200
|
||||
+PRE_STAGE2_LINK = -nostdlib -Wl,-N -Wl,-Tstage2.ldscripts
|
||||
START_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,8000
|
||||
NBLOADER_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,0
|
||||
PXELOADER_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,7C00
|
||||
diff --git a/stage2/Makefile.in b/stage2/Makefile.in
|
||||
index d0062bd..7bee2d5 100644
|
||||
--- a/stage2/Makefile.in
|
||||
+++ b/stage2/Makefile.in
|
||||
@@ -468,7 +468,7 @@ libgrub_a_CFLAGS = $(GRUB_CFLAGS) -I$(top_srcdir)/lib \
|
||||
@DISKLESS_SUPPORT_FALSE@noinst_DATA = pre_stage2 start start_eltorito
|
||||
@DISKLESS_SUPPORT_TRUE@noinst_DATA = pre_stage2 start start_eltorito nbloader pxeloader diskless
|
||||
MOSTLYCLEANFILES = $(noinst_PROGRAMS)
|
||||
-PRE_STAGE2_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,8200
|
||||
+PRE_STAGE2_LINK = -nostdlib -Wl,-N -Wl,-Tstage2.ldscripts
|
||||
START_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,8000
|
||||
NBLOADER_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,0
|
||||
PXELOADER_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,7C00
|
||||
diff --git a/stage2/stage2.ldscripts b/stage2/stage2.ldscripts
|
||||
new file mode 100644
|
||||
index 0000000..2c8b8e1
|
||||
--- /dev/null
|
||||
+++ b/stage2/stage2.ldscripts
|
||||
@@ -0,0 +1,30 @@
|
||||
+/* Script for -N: mix text and data on same page; don't align data */
|
||||
+OUTPUT_FORMAT("elf32-i386", "elf32-i386",
|
||||
+ "elf32-i386")
|
||||
+OUTPUT_ARCH(i386)
|
||||
+ENTRY(_start)
|
||||
+SECTIONS
|
||||
+{
|
||||
+ . = 0x8200;
|
||||
+ .text :
|
||||
+ {
|
||||
+ _start = .;
|
||||
+ *(.text .text.* )
|
||||
+ }
|
||||
+ .rodata : { *(.rodata .rodata.* ) }
|
||||
+ /* Adjust the address for the data segment. We want to adjust up to
|
||||
+ the same address within the page on the next page up. */
|
||||
+ . = .;
|
||||
+ .data : { *(.data .data.* ) }
|
||||
+ __bss_start = .;
|
||||
+ .bss :
|
||||
+ {
|
||||
+ *(.bss .bss.* )
|
||||
+ *(COMMON)
|
||||
+ . = ALIGN(. != 0 ? 32 / 8 : 1);
|
||||
+ }
|
||||
+ . = ALIGN(32 / 8);
|
||||
+ . = ALIGN(32 / 8);
|
||||
+ _end = .; PROVIDE (end = .);
|
||||
+ .comment 0 : { *(.comment) }
|
||||
+}
|
||||
--
|
||||
1.7.6.153.g78432
|
||||
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
--- a/stage1/Makefile.am
|
||||
+++ b/stage1/Makefile.am
|
||||
@@ -1,7 +1,7 @@
|
||||
pkglibdir = $(libdir)/$(PACKAGE)/$(host_cpu)-$(host_vendor)
|
||||
-nodist_pkglib_DATA = stage1
|
||||
+nodist_pkgdata_DATA = stage1
|
||||
|
||||
-CLEANFILES = $(nodist_pkglib_DATA)
|
||||
+CLEANFILES = $(nodist_pkgdata_DATA)
|
||||
|
||||
# We can't use builtins or standard includes.
|
||||
AM_CCASFLAGS = $(STAGE1_CFLAGS) -fno-builtin -nostdinc
|
||||
--- a/stage2/Makefile.am
|
||||
+++ b/stage2/Makefile.am
|
||||
@@ -32,7 +32,7 @@ pkglibdir = $(libdir)/$(PACKAGE)/$(host_
|
||||
EXTRA_PROGRAMS = nbloader.exec pxeloader.exec diskless.exec
|
||||
|
||||
if DISKLESS_SUPPORT
|
||||
-pkglib_DATA = stage2 stage2_eltorito e2fs_stage1_5 fat_stage1_5 \
|
||||
+pkgdata_DATA = stage2 stage2_eltorito e2fs_stage1_5 fat_stage1_5 \
|
||||
ffs_stage1_5 iso9660_stage1_5 jfs_stage1_5 minix_stage1_5 \
|
||||
reiserfs_stage1_5 ufs2_stage1_5 vstafs_stage1_5 xfs_stage1_5 \
|
||||
nbgrub pxegrub
|
||||
@@ -43,7 +43,7 @@ noinst_PROGRAMS = pre_stage2.exec start.
|
||||
reiserfs_stage1_5.exec ufs2_stage1_5.exec vstafs_stage1_5.exec \
|
||||
xfs_stage1_5.exec nbloader.exec pxeloader.exec diskless.exec
|
||||
else
|
||||
-pkglib_DATA = stage2 stage2_eltorito e2fs_stage1_5 fat_stage1_5 \
|
||||
+pkgdata_DATA = stage2 stage2_eltorito e2fs_stage1_5 fat_stage1_5 \
|
||||
ffs_stage1_5 iso9660_stage1_5 jfs_stage1_5 minix_stage1_5 \
|
||||
reiserfs_stage1_5 ufs2_stage1_5 vstafs_stage1_5 xfs_stage1_5
|
||||
noinst_DATA = pre_stage2 start start_eltorito
|
||||
@@ -112,7 +112,7 @@ else
|
||||
BUILT_SOURCES = stage2_size.h
|
||||
endif
|
||||
|
||||
-CLEANFILES = $(pkglib_DATA) $(noinst_DATA) $(BUILT_SOURCES)
|
||||
+CLEANFILES = $(pkgdata_DATA) $(noinst_DATA) $(BUILT_SOURCES)
|
||||
|
||||
stage2_size.h: pre_stage2
|
||||
-rm -f stage2_size.h
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -56,6 +56,8 @@ fi
|
||||
|
||||
AC_CHECK_TOOL(CC, gcc)
|
||||
AC_PROG_CC
|
||||
+AM_PROG_CC_C_O
|
||||
+AM_PROG_AS
|
||||
# We need this for older versions of Autoconf.
|
||||
_AM_DEPENDENCIES(CC)
|
||||
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -177,26 +177,22 @@ grub_ASM_ABSOLUTE_WITHOUT_ASTERISK
|
||||
|
||||
grub_CHECK_START_SYMBOL
|
||||
grub_CHECK_USCORE_START_SYMBOL
|
||||
-if test "x$grub_cv_check_start_symbol" != "xyes" \
|
||||
- -a "x$grub_cv_check_uscore_start_symbol" != "xyes"; then
|
||||
- AC_MSG_ERROR([Neither start nor _start is defined])
|
||||
-fi
|
||||
|
||||
grub_CHECK_USCORE_USCORE_BSS_START_SYMBOL
|
||||
grub_CHECK_USCORE_EDATA_SYMBOL
|
||||
grub_CHECK_EDATA_SYMBOL
|
||||
-if test "x$grub_cv_check_uscore_uscore_bss_start_symbol" != "xyes" \
|
||||
- -a "x$grub_cv_check_uscore_edata_symbol" != "xyes" \
|
||||
- -a "x$grub_cv_check_edata_symbol" != "xyes"; then
|
||||
- AC_MSG_ERROR([None of __bss_start, _edata, edata defined])
|
||||
-fi
|
||||
+# if test "x$grub_cv_check_uscore_uscore_bss_start_symbol" != "xyes" \
|
||||
+# -a "x$grub_cv_check_uscore_edata_symbol" != "xyes" \
|
||||
+# -a "x$grub_cv_check_edata_symbol" != "xyes"; then
|
||||
+# AC_MSG_ERROR([None of __bss_start, _edata, edata defined])
|
||||
+# fi
|
||||
|
||||
grub_CHECK_END_SYMBOL
|
||||
grub_CHECK_USCORE_END_SYMBOL
|
||||
-if test "x$grub_cv_check_end_symbol" != "xyes" \
|
||||
- -a "x$grub_cv_check_uscore_end_symbol" != "xyes"; then
|
||||
- AC_MSG_ERROR([Neither end nor _end is defined])
|
||||
-fi
|
||||
+#if test "x$grub_cv_check_end_symbol" != "xyes" \
|
||||
+# -a "x$grub_cv_check_uscore_end_symbol" != "xyes"; then
|
||||
+# AC_MSG_ERROR([Neither end nor _end is defined])
|
||||
+#fi
|
||||
|
||||
# Check for curses libraries.
|
||||
AC_ARG_WITH(curses,
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
--- a/stage2/asm.S
|
||||
+++ b/stage2/asm.S
|
||||
@@ -95,14 +95,16 @@ VARIABLE(stage2_id)
|
||||
VARIABLE(force_lba)
|
||||
.byte 0
|
||||
VARIABLE(version_string)
|
||||
- .string VERSION
|
||||
+ .ascii VERSION
|
||||
+ .byte 0
|
||||
VARIABLE(config_file)
|
||||
#ifndef STAGE1_5
|
||||
- .string "/boot/grub/menu.lst"
|
||||
+ .ascii "/boot/grub/menu.lst"
|
||||
#else /* STAGE1_5 */
|
||||
.long 0xffffffff
|
||||
- .string "/boot/grub/stage2"
|
||||
+ .ascii "/boot/grub/stage2"
|
||||
#endif /* STAGE1_5 */
|
||||
+ .byte 0
|
||||
|
||||
/*
|
||||
* Leave some breathing room for the config file name.
|
||||
@@ -762,7 +764,9 @@ ENTRY(chain_stage1)
|
||||
call EXT_C(prot_to_real)
|
||||
.code16
|
||||
|
||||
-#ifdef ABSOLUTE_WITHOUT_ASTERISK
|
||||
+#ifdef __APPLE__
|
||||
+ DATA32 ADDR32 ljmp offset
|
||||
+#elif defined(ABSOLUTE_WITHOUT_ASTERISK)
|
||||
DATA32 ADDR32 ljmp (offset)
|
||||
#else
|
||||
DATA32 ADDR32 ljmp *(offset)
|
||||
--- a/stage2/char_io.c
|
||||
+++ b/stage2/char_io.c
|
||||
@@ -1345,5 +1345,12 @@ grub_strcpy (char *dest, const char *src
|
||||
#ifndef GRUB_UTIL
|
||||
# undef memcpy
|
||||
/* GCC emits references to memcpy() for struct copies etc. */
|
||||
+#ifdef __APPLE__
|
||||
+void *memcpy (void *dest, const void *src, int n)
|
||||
+{
|
||||
+ return grub_memmove(dest, src, n);
|
||||
+}
|
||||
+#else
|
||||
void *memcpy (void *dest, const void *src, int n) __attribute__ ((alias ("grub_memmove")));
|
||||
#endif
|
||||
+#endif
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
--- a/stage2/fsys_iso9660.c
|
||||
+++ b/stage2/fsys_iso9660.c
|
||||
@@ -83,10 +83,7 @@ iso9660_devread (int sector, int byte_of
|
||||
|
||||
sector += (byte_offset >> sector_size_lg2);
|
||||
byte_offset &= (buf_geom.sector_size - 1);
|
||||
- asm volatile ("shl%L0 %1,%0"
|
||||
- : "=r"(sector)
|
||||
- : "Ic"((int8_t)(ISO_SECTOR_BITS - sector_size_lg2)),
|
||||
- "0"(sector));
|
||||
+ sector <<= ISO_SECTOR_BITS - sector_size_lg2;
|
||||
|
||||
#if !defined(STAGE1_5)
|
||||
if (disk_read_hook && debug)
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
#
|
||||
# Copyright (C) 2011-2012 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=jansson
|
||||
PKG_VERSION:=2.4
|
||||
PKG_RELEASE:=2
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=http://www.digip.org/jansson/releases/
|
||||
PKG_MD5SUM:=c4629b89bf0432f3158c461e88fe0113
|
||||
|
||||
PKG_INSTALL:=1
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/jansson
|
||||
SECTION:=libs
|
||||
CATEGORY:=Libraries
|
||||
TITLE:=JSON library
|
||||
endef
|
||||
|
||||
TARGET_CFLAGS += $(FPIC)
|
||||
|
||||
define Build/InstallDev
|
||||
$(INSTALL_DIR) $(1)/usr/{lib,include}
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libjansson* $(1)/usr/lib
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
|
||||
endef
|
||||
|
||||
define Package/jansson/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libjansson*so* $(1)/usr/lib/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,jansson))
|
||||
|
|
@ -1,73 +0,0 @@
|
|||
#
|
||||
# Copyright (C) 2012 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
OWSIP_VERSION=2012-02-14
|
||||
OWSIP_RELEASE=1
|
||||
|
||||
PKG_NAME:=owsip
|
||||
PKG_VERSION:=$(OWSIP_VERSION)$(if $(OWSIP_RELEASE),.$(OWSIP_RELEASE))
|
||||
PKG_RELEASE:=1
|
||||
PKG_REV:=da53a53db28b47ca1714ffba72d0df5bea357706
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=git://nbd.name/owsip.git
|
||||
PKG_SOURCE_SUBDIR:=owsip-$(PKG_VERSION)
|
||||
PKG_SOURCE_VERSION:=$(PKG_REV)
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_MIRROR_MD5SUM:=74b0ab930321c4f85f220ff3852e210a
|
||||
|
||||
include $(INCLUDE_DIR)/ltqtapi.mk
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/owsip-template
|
||||
SUBMENU:=Telephony
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=owsip using $(2)
|
||||
VARIANT:=$(1)
|
||||
DEPENDS:=+librt +libuci +libubox +pjsip-$(1) $(3)
|
||||
endef
|
||||
|
||||
Package/owsip-oss=$(call Package/owsip-template,oss,OSS,BROKEN)
|
||||
Package/owsip-ltq-tapi=$(call Package/owsip-template,ltq-tapi,Lantiq VMMC,$(LTQ_TAPI_DEPENDS) +kmod-ltq-kpi2udp)
|
||||
|
||||
define Package/owsip-$(BUILD_VARIANT)/description
|
||||
OpenWrt sip daemon - $(BUILD_VARIANT)
|
||||
endef
|
||||
|
||||
USE_LOCAL=$(shell ls ./src/ 2>/dev/null >/dev/null && echo 1)
|
||||
ifneq ($(USE_LOCAL),)
|
||||
define Build/Prepare
|
||||
$(CP) ./src/* $(PKG_BUILD_DIR)/
|
||||
endef
|
||||
endif
|
||||
|
||||
EXTRA_CFLAGS=-I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include \
|
||||
-I$(STAGING_DIR)/usr/pjsip-$(BUILD_VARIANT)/include
|
||||
EXTRA_LDFLAGS=-L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/usr/pjsip-$(BUILD_VARIANT)/lib
|
||||
|
||||
define Build/Compile
|
||||
PKG_CONFIG_PATH=$(STAGING_DIR)/usr/pjsip-$(BUILD_VARIANT)/lib/pkgconfig \
|
||||
BACKEND=$(BUILD_VARIANT) CFLAGS="$(EXTRA_CFLAGS)" LDFLAGS="$(EXTRA_LDFLAGS)" $(MAKE) -C $(PKG_BUILD_DIR) $(TARGET_CONFIGURE_OPTS)
|
||||
endef
|
||||
|
||||
define Package/owsip-$(BUILD_VARIANT)/conffiles
|
||||
/etc/config/telephony.conf
|
||||
endef
|
||||
|
||||
define Package/owsip-$(BUILD_VARIANT)/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin $(1)/etc/init.d $(1)/etc/config $(1)/etc/uci-defaults
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/owsip_ua $(1)/usr/bin
|
||||
$(INSTALL_BIN) ./files/telephony.init $(1)/etc/init.d/telephony
|
||||
$(INSTALL_DATA) ./files/telephony.conf $(1)/etc/config/telephony
|
||||
$(INSTALL_DATA) ./files/telephony.defaults $(1)/etc/uci-defaults/telephony
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,owsip-oss))
|
||||
$(eval $(call BuildPackage,owsip-ltq-tapi))
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
config general general
|
||||
option name owsip
|
||||
option backend ltq_tapi
|
||||
option ossdev 0
|
||||
option log_level 3
|
||||
option interface nas0
|
||||
option local_port 5060
|
||||
option rtp_port 4000
|
||||
option locale germany
|
||||
|
||||
config stun stun
|
||||
option host stun.myrealm.com
|
||||
option port 3478
|
||||
|
||||
config account example1
|
||||
option realm myrealm1.com
|
||||
option username myuser1
|
||||
option password mypass1
|
||||
option disabled 1
|
||||
|
||||
config account example2
|
||||
option realm myrealm2.com
|
||||
option username myuser2
|
||||
option password mypass2
|
||||
option disabled 1
|
||||
|
||||
config contact
|
||||
option desc "example contact description"
|
||||
option code "example"
|
||||
option dial "0123456789"
|
||||
option type realm
|
||||
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Copyright (C) 2011 OpenWrt.org
|
||||
# based on ar71xx
|
||||
#
|
||||
|
||||
COMMIT_TELEPHONY=0
|
||||
|
||||
set_relay() {
|
||||
local cfg="relay_$1"
|
||||
local gpio=$1
|
||||
local val=$2
|
||||
|
||||
uci -q get telephony.$cfg && return 0
|
||||
|
||||
uci batch <<EOF
|
||||
set telephony.$cfg='relay'
|
||||
set telephony.$cfg.gpio='$gpio'
|
||||
set telephony.$cfg.value='$val'
|
||||
EOF
|
||||
COMMIT_TELEPHONY=1
|
||||
}
|
||||
|
||||
set_port() {
|
||||
local cfg="port$1"
|
||||
local id=$1
|
||||
local led=$2
|
||||
|
||||
uci -q get telephony.$cfg && return 0
|
||||
|
||||
uci batch <<EOF
|
||||
set telephony.$cfg='port'
|
||||
set telephony.$cfg.id='$id'
|
||||
set telephony.$cfg.led='$led'
|
||||
set telephony.$cfg.noring='0'
|
||||
set telephony.$cfg.nodial='0'
|
||||
EOF
|
||||
COMMIT_TELEPHONY=1
|
||||
}
|
||||
|
||||
. /lib/lantiq.sh
|
||||
|
||||
board=$(lantiq_board_name)
|
||||
|
||||
case "$board" in
|
||||
ARV7525PW)
|
||||
set_relay 31 1
|
||||
set_port 0 "soc:green:fxs1"
|
||||
#set_port 1 "soc:green:fxs2"
|
||||
;;
|
||||
esac
|
||||
|
||||
[ "$COMMIT_TELEPHONY" == "1" ] && uci commit telephony
|
||||
|
||||
exit 0
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
START=80
|
||||
|
||||
SERVICE_WRITE_PID=1
|
||||
SERVICE_DAEMONIZE=1
|
||||
SERVICE_PID_FILE=/var/run/owsip.pid
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
relay_set () {
|
||||
local cfg="$1"
|
||||
local gpio value
|
||||
|
||||
config_get gpio "$cfg" gpio
|
||||
config_get value "$cfg" value
|
||||
[ -n "gpio" ] || return 0
|
||||
[ ! -f "/sys/class/gpio/gpio$gpio/direction" ] &&
|
||||
echo "$gpio" > /sys/class/gpio/export
|
||||
[ -f "/sys/class/gpio/gpio$gpio/direction" ] && {
|
||||
echo "out" > /sys/class/gpio/gpio$gpio/direction
|
||||
echo "$value" > /sys/class/gpio/gpio$gpio/value
|
||||
}
|
||||
}
|
||||
|
||||
start() {
|
||||
config_load telephony
|
||||
config_foreach relay_set relay
|
||||
service_start /usr/bin/owsip_ua
|
||||
}
|
||||
|
||||
stop() {
|
||||
service_stop /usr/bin/owsip_ua
|
||||
}
|
||||
|
|
@ -1,101 +0,0 @@
|
|||
#
|
||||
# Copyright (C) 2010-2012 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=pjsip
|
||||
PKG_VERSION:=1.14.2
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=pjproject-$(PKG_VERSION).tar.bz2
|
||||
PKG_SOURCE_URL:=http://www.pjsip.org/release/$(PKG_VERSION)/
|
||||
PKG_MD5SUM:=05428502384c16e7abd85f047e6e2f6c
|
||||
|
||||
PKG_INSTALL:=1
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/pjproject-$(PKG_VERSION)
|
||||
|
||||
include $(INCLUDE_DIR)/ltqtapi.mk
|
||||
PKG_BUILD_DEPENDS:=$(LTQ_TAPI_BUILD_DEPENDS)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/pjsip-template
|
||||
SECTION:=lib
|
||||
CATEGORY:=Libraries
|
||||
URL:=http://www.pjsip.org/
|
||||
MAINTAINER:=John Crispin <blogic@openwrt.org>
|
||||
TITLE:=pjsip-$(1)
|
||||
VARIANT:=$(1)
|
||||
DEPENDS:=+libuuid $(2)
|
||||
endef
|
||||
|
||||
CONFIGURE_PREFIX=/usr/pjsip-$(BUILD_VARIANT)
|
||||
|
||||
ifeq ($(BUILD_VARIANT),oss)
|
||||
CONFIGURE_ARGS += \
|
||||
--disable-floating-point \
|
||||
--enable-g711-codec \
|
||||
--disable-l16-codec \
|
||||
--disable-g722-codec \
|
||||
--disable-g7221-codec \
|
||||
--disable-gsm-codec \
|
||||
--disable-ilbc-coder \
|
||||
--disable-libsamplerate \
|
||||
--disable-ipp \
|
||||
--disable-ssl \
|
||||
--enable-oss \
|
||||
--enable-sound
|
||||
endif
|
||||
|
||||
ifeq ($(BUILD_VARIANT),ltq-tapi)
|
||||
CONFIGURE_ARGS += \
|
||||
--disable-floating-point \
|
||||
--enable-g711-codec \
|
||||
--disable-l16-codec \
|
||||
--disable-g722-codec \
|
||||
--disable-g7221-codec \
|
||||
--disable-ilbc-coder \
|
||||
--disable-gsm-codec \
|
||||
--disable-libsamplerate \
|
||||
--disable-ipp \
|
||||
--disable-ssl \
|
||||
--enable-sound \
|
||||
--enable-ltq-tapi
|
||||
EXTRA_CFLAGS:=-I$(STAGING_DIR)/usr/include/drv_tapi -I$(STAGING_DIR)/usr/include/drv_vmmc
|
||||
endif
|
||||
|
||||
Package/pjsip-oss=$(call Package/pjsip-template,oss,BROKEN)
|
||||
Package/pjsip-ltq-tapi=$(call Package/pjsip-template,ltq-tapi,$(LTQ_TAPI_DEPENDS))
|
||||
|
||||
USE_LOCAL=$(shell ls ./src/ 2>/dev/null >/dev/null && echo 1)
|
||||
ifneq ($(USE_LOCAL),)
|
||||
define Build/Prepare
|
||||
$(CP) ./src/* $(PKG_BUILD_DIR)
|
||||
endef
|
||||
endif
|
||||
|
||||
define Build/Configure
|
||||
(cd $(PKG_BUILD_DIR); autoconf aconfigure.ac > aconfigure)
|
||||
$(call Build/Configure/Default)
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
+CFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS) $(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS)" \
|
||||
CXXFLAGS="$(TARGET_CFLAGS) $(EXTRA_CFLAGS) $(TARGET_CPPFLAGS) $(EXTRA_CPPFLAGS)" \
|
||||
LDFLAGS="$(TARGET_LDFLAGS) -lc $(LIBGCC_S) -lm" \
|
||||
$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/$(MAKE_PATH)
|
||||
endef
|
||||
|
||||
define Build/InstallDev
|
||||
$(INSTALL_DIR) $(1)/usr
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/pjsip-$(BUILD_VARIANT) $(1)/usr
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,pjsip-oss))
|
||||
$(eval $(call BuildPackage,pjsip-ltq-tapi))
|
||||
|
|
@ -1,78 +0,0 @@
|
|||
Index: pjproject-1.14.2/aconfigure.ac
|
||||
===================================================================
|
||||
--- pjproject-1.14.2.orig/aconfigure.ac 2012-04-27 03:22:15.000000000 +0200
|
||||
+++ pjproject-1.14.2/aconfigure.ac 2012-08-13 14:42:33.204641678 +0200
|
||||
@@ -48,9 +48,8 @@
|
||||
CROSS_COMPILE=`echo ${CC} | sed 's/gcc//'`
|
||||
fi
|
||||
|
||||
-if test "$AR" = ""; then AR="${CROSS_COMPILE}ar rv"; fi
|
||||
+AR="${AR} rv"
|
||||
AC_SUBST(AR)
|
||||
-if test "$LD" = ""; then LD="$CC"; fi
|
||||
AC_SUBST(LD)
|
||||
if test "$LDOUT" = ""; then LDOUT="-o "; fi
|
||||
AC_SUBST(LDOUT)
|
||||
@@ -584,13 +583,7 @@
|
||||
;;
|
||||
*)
|
||||
dnl # Check if ALSA is available
|
||||
- ac_pjmedia_snd=pa_unix
|
||||
- AC_CHECK_HEADER(alsa/version.h,
|
||||
- [AC_SUBST(ac_pa_use_alsa,1)
|
||||
- LIBS="$LIBS -lasound"
|
||||
- ],
|
||||
- [AC_SUBST(ac_pa_use_alsa,0)])
|
||||
- AC_MSG_RESULT([Checking sound device backend... unix])
|
||||
+ AC_SUBST(ac_pa_use_alsa,0)
|
||||
|
||||
dnl # Check if OSS is disabled
|
||||
AC_SUBST(ac_pa_use_oss,1)
|
||||
@@ -617,6 +610,15 @@
|
||||
fi]
|
||||
)
|
||||
|
||||
+AC_ARG_ENABLE(ltq_tapi,
|
||||
+ AC_HELP_STRING([--enable-ltq-tapi],
|
||||
+ [PJMEDIA will use ltq tapi backend]),
|
||||
+ [if test "$enable_ltq_tapi" = "yes"; then
|
||||
+ [ac_pjmedia_snd=ltqtapi]
|
||||
+ AC_MSG_RESULT([Checking if external sound is set... yes])
|
||||
+ fi]
|
||||
+ )
|
||||
+
|
||||
dnl # Include resampling small filter
|
||||
AC_SUBST(ac_no_small_filter)
|
||||
AC_ARG_ENABLE(small-filter,
|
||||
@@ -737,14 +739,6 @@
|
||||
AC_MSG_RESULT([Checking if iLBC codec is disabled...no]))
|
||||
|
||||
dnl # Include libsamplerate
|
||||
-AC_ARG_ENABLE(libsamplerate,
|
||||
- AC_HELP_STRING([--enable-libsamplerate],
|
||||
- [Link with libsamplerate when available. Note that PJMEDIA_RESAMPLE_IMP must also be configured]),
|
||||
- [ AC_CHECK_LIB(samplerate,src_new) ],
|
||||
- AC_MSG_RESULT([Skipping libsamplerate detection])
|
||||
- )
|
||||
-
|
||||
-dnl # Include libsamplerate
|
||||
AC_SUBST(ac_resample_dll)
|
||||
AC_ARG_ENABLE(resample_dll,
|
||||
AC_HELP_STRING([--enable-resample-dll],
|
||||
Index: pjproject-1.14.2/pjmedia/build/os-auto.mak.in
|
||||
===================================================================
|
||||
--- pjproject-1.14.2.orig/pjmedia/build/os-auto.mak.in 2011-10-14 06:15:15.000000000 +0200
|
||||
+++ pjproject-1.14.2/pjmedia/build/os-auto.mak.in 2012-08-13 14:40:47.680637171 +0200
|
||||
@@ -125,4 +125,11 @@
|
||||
export CFLAGS += -DPJMEDIA_AUDIO_DEV_HAS_PORTAUDIO=0 -DPJMEDIA_AUDIO_DEV_HAS_WMME=0
|
||||
endif
|
||||
|
||||
-
|
||||
+#
|
||||
+# Lantiq tapi backend
|
||||
+#
|
||||
+ifeq ($(AC_PJMEDIA_SND),ltqtapi)
|
||||
+export CFLAGS += -DPJMEDIA_AUDIO_DEV_HAS_PORTAUDIO=0 -DPJMEDIA_AUDIO_DEV_HAS_WMME=0
|
||||
+export PJMEDIA_AUDIODEV_OBJS += tapi_dev.o
|
||||
+export CFLAGS += -DPJMEDIA_AUDIO_DEV_HAS_TAPI_DEVICE=1
|
||||
+endif
|
||||
|
|
@ -1,207 +0,0 @@
|
|||
--- a/pjsip/include/pjsua-lib/pjsua.h
|
||||
+++ b/pjsip/include/pjsua-lib/pjsua.h
|
||||
@@ -1543,6 +1543,8 @@ PJ_DECL(pjmedia_endpt*) pjsua_get_pjmedi
|
||||
PJ_DECL(pj_pool_factory*) pjsua_get_pool_factory(void);
|
||||
|
||||
|
||||
+PJ_DECL(pj_status_t) pjsua_add_snd_port(int id, pjsua_conf_port_id *p_id);
|
||||
+
|
||||
|
||||
/*****************************************************************************
|
||||
* Utilities.
|
||||
--- a/pjsip/include/pjsua-lib/pjsua_internal.h
|
||||
+++ b/pjsip/include/pjsua-lib/pjsua_internal.h
|
||||
@@ -261,6 +261,8 @@ typedef struct pjsua_stun_resolve
|
||||
} pjsua_stun_resolve;
|
||||
|
||||
|
||||
+#define MAX_PORT 2
|
||||
+
|
||||
/**
|
||||
* Global pjsua application data.
|
||||
*/
|
||||
@@ -336,7 +338,7 @@ struct pjsua_data
|
||||
pj_bool_t aud_open_cnt;/**< How many # device is opened */
|
||||
pj_bool_t no_snd; /**< No sound (app will manage it) */
|
||||
pj_pool_t *snd_pool; /**< Sound's private pool. */
|
||||
- pjmedia_snd_port *snd_port; /**< Sound port. */
|
||||
+ pjmedia_snd_port *snd_port[MAX_PORT]; /**< Sound port. */
|
||||
pj_timer_entry snd_idle_timer;/**< Sound device idle timer. */
|
||||
pjmedia_master_port *null_snd; /**< Master port for null sound. */
|
||||
pjmedia_port *null_port; /**< Null port. */
|
||||
--- a/pjsip/src/pjsua-lib/pjsua_media.c
|
||||
+++ b/pjsip/src/pjsua-lib/pjsua_media.c
|
||||
@@ -588,7 +588,7 @@ static void check_snd_dev_idle()
|
||||
* It is idle when there is no port connection in the bridge and
|
||||
* there is no active call.
|
||||
*/
|
||||
- if ((pjsua_var.snd_port!=NULL || pjsua_var.null_snd!=NULL) &&
|
||||
+ if ((pjsua_var.snd_port[0]!=NULL || pjsua_var.null_snd!=NULL) &&
|
||||
pjsua_var.snd_idle_timer.id == PJ_FALSE &&
|
||||
pjmedia_conf_get_connect_count(pjsua_var.mconf) == 0 &&
|
||||
call_cnt == 0 &&
|
||||
@@ -2008,7 +2008,7 @@ PJ_DEF(pj_status_t) pjsua_conf_connect(
|
||||
pj_assert(status == PJ_SUCCESS);
|
||||
|
||||
/* Check if sound device is instantiated. */
|
||||
- need_reopen = (pjsua_var.snd_port==NULL && pjsua_var.null_snd==NULL &&
|
||||
+ need_reopen = (pjsua_var.snd_port[0]==NULL && pjsua_var.null_snd==NULL &&
|
||||
!pjsua_var.no_snd);
|
||||
|
||||
/* Check if sound device need to reopen because it needs to modify
|
||||
@@ -2072,7 +2072,7 @@ PJ_DEF(pj_status_t) pjsua_conf_connect(
|
||||
/* The bridge version */
|
||||
|
||||
/* Create sound port if none is instantiated */
|
||||
- if (pjsua_var.snd_port==NULL && pjsua_var.null_snd==NULL &&
|
||||
+ if (pjsua_var.snd_port[0]==NULL && pjsua_var.null_snd==NULL &&
|
||||
!pjsua_var.no_snd)
|
||||
{
|
||||
pj_status_t status;
|
||||
@@ -2686,9 +2686,9 @@ static pj_status_t update_initial_aud_pa
|
||||
pjmedia_aud_param param;
|
||||
pj_status_t status;
|
||||
|
||||
- PJ_ASSERT_RETURN(pjsua_var.snd_port != NULL, PJ_EBUG);
|
||||
+ PJ_ASSERT_RETURN(pjsua_var.snd_port[0] != NULL, PJ_EBUG);
|
||||
|
||||
- strm = pjmedia_snd_port_get_snd_stream(pjsua_var.snd_port);
|
||||
+ strm = pjmedia_snd_port_get_snd_stream(pjsua_var.snd_port[0]);
|
||||
|
||||
status = pjmedia_aud_stream_get_param(strm, ¶m);
|
||||
if (status != PJ_SUCCESS) {
|
||||
@@ -2754,7 +2754,7 @@ static pj_status_t open_snd_dev(pjmedia_
|
||||
1000 / param->base.clock_rate));
|
||||
|
||||
status = pjmedia_snd_port_create2( pjsua_var.snd_pool,
|
||||
- param, &pjsua_var.snd_port);
|
||||
+ param, &pjsua_var.snd_port[0]);
|
||||
if (status != PJ_SUCCESS)
|
||||
return status;
|
||||
|
||||
@@ -2812,13 +2812,13 @@ static pj_status_t open_snd_dev(pjmedia_
|
||||
}
|
||||
|
||||
/* Connect sound port to the bridge */
|
||||
- status = pjmedia_snd_port_connect(pjsua_var.snd_port,
|
||||
+ status = pjmedia_snd_port_connect(pjsua_var.snd_port[0],
|
||||
conf_port );
|
||||
if (status != PJ_SUCCESS) {
|
||||
pjsua_perror(THIS_FILE, "Unable to connect conference port to "
|
||||
"sound device", status);
|
||||
- pjmedia_snd_port_destroy(pjsua_var.snd_port);
|
||||
- pjsua_var.snd_port = NULL;
|
||||
+ pjmedia_snd_port_destroy(pjsua_var.snd_port[0]);
|
||||
+ pjsua_var.snd_port[0] = NULL;
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -2833,7 +2833,7 @@ static pj_status_t open_snd_dev(pjmedia_
|
||||
pjmedia_aud_param si;
|
||||
pj_str_t tmp;
|
||||
|
||||
- strm = pjmedia_snd_port_get_snd_stream(pjsua_var.snd_port);
|
||||
+ strm = pjmedia_snd_port_get_snd_stream(pjsua_var.snd_port[0]);
|
||||
status = pjmedia_aud_stream_get_param(strm, &si);
|
||||
if (status == PJ_SUCCESS)
|
||||
status = pjmedia_aud_dev_get_info(si.rec_id, &rec_info);
|
||||
@@ -2876,12 +2876,12 @@ static pj_status_t open_snd_dev(pjmedia_
|
||||
static void close_snd_dev(void)
|
||||
{
|
||||
/* Close sound device */
|
||||
- if (pjsua_var.snd_port) {
|
||||
+ if (pjsua_var.snd_port[0]) {
|
||||
pjmedia_aud_dev_info cap_info, play_info;
|
||||
pjmedia_aud_stream *strm;
|
||||
pjmedia_aud_param param;
|
||||
|
||||
- strm = pjmedia_snd_port_get_snd_stream(pjsua_var.snd_port);
|
||||
+ strm = pjmedia_snd_port_get_snd_stream(pjsua_var.snd_port[0]);
|
||||
pjmedia_aud_stream_get_param(strm, ¶m);
|
||||
|
||||
if (pjmedia_aud_dev_get_info(param.rec_id, &cap_info) != PJ_SUCCESS)
|
||||
@@ -2893,9 +2893,9 @@ static void close_snd_dev(void)
|
||||
"%s sound capture device",
|
||||
play_info.name, cap_info.name));
|
||||
|
||||
- pjmedia_snd_port_disconnect(pjsua_var.snd_port);
|
||||
- pjmedia_snd_port_destroy(pjsua_var.snd_port);
|
||||
- pjsua_var.snd_port = NULL;
|
||||
+ pjmedia_snd_port_disconnect(pjsua_var.snd_port[0]);
|
||||
+ pjmedia_snd_port_destroy(pjsua_var.snd_port[0]);
|
||||
+ pjsua_var.snd_port[0] = NULL;
|
||||
}
|
||||
|
||||
/* Close null sound device */
|
||||
@@ -2984,6 +2984,35 @@ PJ_DEF(pj_status_t) pjsua_set_snd_dev( i
|
||||
return PJ_SUCCESS;
|
||||
}
|
||||
|
||||
+PJ_DEF(pj_status_t) pjsua_add_snd_port(int id, pjsua_conf_port_id *p_id)
|
||||
+{
|
||||
+ unsigned alt_cr_cnt = 1;
|
||||
+ unsigned alt_cr = 0;
|
||||
+ pj_status_t status = -1;
|
||||
+ pjmedia_snd_port_param param;
|
||||
+ unsigned samples_per_frame;
|
||||
+ pjmedia_port *port;
|
||||
+ const pj_str_t name = pj_str("tapi2");
|
||||
+ alt_cr = pjsua_var.media_cfg.clock_rate;
|
||||
+ samples_per_frame = alt_cr *
|
||||
+ pjsua_var.media_cfg.audio_frame_ptime *
|
||||
+ pjsua_var.media_cfg.channel_count / 1000;
|
||||
+ status = create_aud_param(¶m.base,
|
||||
+ pjsua_var.play_dev,
|
||||
+ pjsua_var.cap_dev,
|
||||
+ alt_cr,
|
||||
+ pjsua_var.media_cfg.channel_count,
|
||||
+ samples_per_frame, 16);
|
||||
+ if (status != PJ_SUCCESS)
|
||||
+ return status;
|
||||
+ param.base.rec_id = id;
|
||||
+ param.base.play_id = id;
|
||||
+ param.options = 0;
|
||||
+ status = pjmedia_snd_port_create2(pjsua_var.snd_pool,
|
||||
+ ¶m, &pjsua_var.snd_port[id]);
|
||||
+ return PJ_SUCCESS;
|
||||
+}
|
||||
+
|
||||
|
||||
/*
|
||||
* Get currently active sound devices. If sound devices has not been created
|
||||
@@ -3088,7 +3117,7 @@ PJ_DEF(pj_status_t) pjsua_set_ec(unsigne
|
||||
pjsua_var.media_cfg.ec_options = options;
|
||||
|
||||
if (pjsua_var.snd_port)
|
||||
- status = pjmedia_snd_port_set_ec(pjsua_var.snd_port, pjsua_var.pool,
|
||||
+ status = pjmedia_snd_port_set_ec(pjsua_var.snd_port[0], pjsua_var.pool,
|
||||
tail_ms, options);
|
||||
|
||||
PJSUA_UNLOCK();
|
||||
@@ -3111,7 +3140,7 @@ PJ_DEF(pj_status_t) pjsua_get_ec_tail(un
|
||||
*/
|
||||
PJ_DEF(pj_bool_t) pjsua_snd_is_active(void)
|
||||
{
|
||||
- return pjsua_var.snd_port != NULL;
|
||||
+ return pjsua_var.snd_port[0] != NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -3135,7 +3164,7 @@ PJ_DEF(pj_status_t) pjsua_snd_set_settin
|
||||
if (pjsua_snd_is_active()) {
|
||||
pjmedia_aud_stream *strm;
|
||||
|
||||
- strm = pjmedia_snd_port_get_snd_stream(pjsua_var.snd_port);
|
||||
+ strm = pjmedia_snd_port_get_snd_stream(pjsua_var.snd_port[0]);
|
||||
status = pjmedia_aud_stream_set_cap(strm, cap, pval);
|
||||
} else {
|
||||
status = PJ_SUCCESS;
|
||||
@@ -3181,7 +3210,7 @@ PJ_DEF(pj_status_t) pjsua_snd_get_settin
|
||||
/* Sound is active, retrieve from device directly */
|
||||
pjmedia_aud_stream *strm;
|
||||
|
||||
- strm = pjmedia_snd_port_get_snd_stream(pjsua_var.snd_port);
|
||||
+ strm = pjmedia_snd_port_get_snd_stream(pjsua_var.snd_port[0]);
|
||||
status = pjmedia_aud_stream_get_cap(strm, cap, pval);
|
||||
} else {
|
||||
/* Otherwise retrieve from internal param */
|
||||
|
|
@ -1,70 +0,0 @@
|
|||
#
|
||||
# Copyright (C) 2008-2010 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=ps3-utils
|
||||
PKG_REV:=6488134e48cf2d6f2d6471ced8346ac8cb1b855a
|
||||
PKG_VERSION:=20090320
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.bz2
|
||||
PKG_SOURCE_URL:=git://git.kernel.org/pub/scm/linux/kernel/git/geoff/ps3-utils.git
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
PKG_SOURCE_VERSION:=$(PKG_REV)
|
||||
|
||||
PKG_FIXUP:=autoreconf
|
||||
PKG_INSTALL=1
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/ps3-utils
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=PS3 Linux Utilities
|
||||
URL:=http://kernel.org/pub/linux/kernel/people/geoff/cell/ps3-utils/
|
||||
MAINTAINER:=Geoff Levand <geoffrey.levand@am.sony.com>
|
||||
DEPENDS:=@TARGET_ps3||TARGET_ps3chk||TARGET_powerpc
|
||||
endef
|
||||
|
||||
define Package/ps3-utils/description
|
||||
The ps3-utils package is a set of system administration utilites for the
|
||||
PS3 game console.
|
||||
endef
|
||||
|
||||
define Build/Configure
|
||||
(cd $(PKG_BUILD_DIR) && $(BASH) -x ./bootstrap)
|
||||
$(call Build/Configure/Default)
|
||||
endef
|
||||
|
||||
define Build/InstallDev
|
||||
$(INSTALL_DIR) $(1)/usr/include
|
||||
$(INSTALL_DATA) \
|
||||
$(PKG_INSTALL_DIR)/usr/include/ps3*.h \
|
||||
$(1)/usr/include
|
||||
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(INSTALL_BIN) \
|
||||
$(PKG_INSTALL_DIR)/usr/lib/libps3-utils.{la,a,so*} \
|
||||
$(1)/usr/lib/
|
||||
endef
|
||||
|
||||
define Package/ps3-utils/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/ps3-boot-game-os $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/ps3-dump-bootloader $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/ps3-flash-util $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/ps3-video-mode $(1)/usr/bin
|
||||
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libps3-utils.so.* $(1)/usr/lib
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,ps3-utils))
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
#
|
||||
# Copyright (C) 2006-2010 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_NAME:=sierra-directip
|
||||
PKG_RELEASE:=10
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define KernelPackage/usb-sierrawireless-directip
|
||||
SUBMENU:=USB Support
|
||||
DEPENDS:=+kmod-usb-serial +kmod-usb-net
|
||||
TITLE:=Updated Sierra Wireless drivers for DirectIP
|
||||
FILES:= \
|
||||
$(PKG_BUILD_DIR)/sierra.ko \
|
||||
$(PKG_BUILD_DIR)/sierra_net.ko
|
||||
AUTOLOAD:=$(call AutoLoad,60,sierra sierra_net)
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
mkdir -p $(PKG_BUILD_DIR)
|
||||
$(CP) ./src/* $(PKG_BUILD_DIR)/
|
||||
$(Build/Patch)
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
$(MAKE) -C "$(LINUX_DIR)" \
|
||||
CROSS_COMPILE="$(TARGET_CROSS)" \
|
||||
ARCH="$(LINUX_KARCH)" \
|
||||
SUBDIRS="$(PKG_BUILD_DIR)" \
|
||||
EXTRA_CFLAGS="$(BUILDFLAGS)" \
|
||||
modules
|
||||
endef
|
||||
|
||||
$(eval $(call KernelPackage,usb-sierrawireless-directip))
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
--- a/sierra_net.c
|
||||
+++ b/sierra_net.c
|
||||
@@ -840,8 +840,8 @@ static int sierra_net_bind(struct usbnet
|
||||
init_timer(&priv->sync_timer);
|
||||
/* verify fw attributes */
|
||||
status = sierra_net_get_fw_attr(dev, &fwattr);
|
||||
- dev_dbg(&dev->udev->dev, "Fw attr: %x\n", fwattr);
|
||||
- if (status == sizeof(fwattr) && (fwattr & SWI_GET_FW_ATTR_APM)) {
|
||||
+ dev_dbg(&dev->udev->dev, "Fw attr: %x\n", cpu_to_le16(fwattr));
|
||||
+ if (status == sizeof(fwattr) && (cpu_to_le16(fwattr) & SWI_GET_FW_ATTR_APM)) {
|
||||
/*******************************************************************************
|
||||
* If you want the default /sys/bus/usb/devices/.../.../power/level to be forced
|
||||
* to auto, the following needs to be compiled in.
|
||||
@@ -856,7 +856,7 @@ static int sierra_net_bind(struct usbnet
|
||||
usb_disable_autosuspend(dev->udev);
|
||||
}
|
||||
/* test whether firmware supports DHCP */
|
||||
- if (!(status == sizeof(fwattr) && (fwattr & SWI_GET_FW_ATTR_MASK))) {
|
||||
+ if (!(status == sizeof(fwattr) && (cpu_to_le16(fwattr) & SWI_GET_FW_ATTR_MASK))) {
|
||||
/* found incompatible firmware version */
|
||||
dev_err(&dev->udev->dev, "Incompatible driver and firmware"
|
||||
" versions\n");
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
--- a/sierra_net.c
|
||||
+++ b/sierra_net.c
|
||||
@@ -858,10 +858,7 @@ static int sierra_net_bind(struct usbnet
|
||||
/* test whether firmware supports DHCP */
|
||||
if (!(status == sizeof(fwattr) && (cpu_to_le16(fwattr) & SWI_GET_FW_ATTR_MASK))) {
|
||||
/* found incompatible firmware version */
|
||||
- dev_err(&dev->udev->dev, "Incompatible driver and firmware"
|
||||
- " versions\n");
|
||||
- kfree(priv);
|
||||
- return -ENODEV;
|
||||
+ dev_err(&dev->udev->dev, "Warning: Firmware does not have DHCP support\n");
|
||||
}
|
||||
/* prepare sync message from template */
|
||||
memcpy(priv->sync_msg, sync_tmplate, sizeof(priv->sync_msg));
|
||||
|
|
@ -1 +0,0 @@
|
|||
obj-m := sierra.o sierra_net.o
|
||||
|
|
@ -1,143 +0,0 @@
|
|||
#
|
||||
# Copyright (C) 2008-2010 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_NAME:=wprobe
|
||||
PKG_VERSION:=1
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_BUILD_DEPENDS:=PACKAGE_wprobe-export:libipfix
|
||||
|
||||
PKG_CONFIG_DEPENDS = \
|
||||
CONFIG_PACKAGE_kmod-wprobe \
|
||||
CONFIG_PACKAGE_wprobe-export \
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
# XXX: build failure on cris
|
||||
# wprobe-lib.c:145: error: 'packed' attribute ignored for field of type 'struct <anonymous>'
|
||||
# wprobe-lib.c:149: error: 'packed' attribute ignored for field of type 'struct <anonymous>'
|
||||
|
||||
define Package/wprobe/Default
|
||||
DEPENDS:=@(!(TARGET_ps3||TARGET_pxcab||cris)||BROKEN)
|
||||
endef
|
||||
|
||||
define KernelPackage/wprobe
|
||||
$(call Package/wprobe/Default)
|
||||
SUBMENU:=Network Support
|
||||
TITLE:=Wireless driver probe infrastructure
|
||||
MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
|
||||
FILES:= \
|
||||
$(PKG_BUILD_DIR)/kernel/wprobe.ko
|
||||
AUTOLOAD:=$(call AutoLoad,01,wprobe)
|
||||
endef
|
||||
|
||||
define KernelPackage/wprobe/description
|
||||
A module that exports measurement data from wireless driver to user space
|
||||
endef
|
||||
|
||||
define Package/wprobe-util
|
||||
$(call Package/wprobe/Default)
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
DEPENDS+=+kmod-wprobe +libnl-tiny
|
||||
TITLE:=Wireless measurement utility
|
||||
endef
|
||||
|
||||
define Package/wprobe-util/description
|
||||
wprobe-util uses the wprobe kernel module to query
|
||||
wireless driver measurement data from an interface
|
||||
endef
|
||||
|
||||
define Package/wprobe-export
|
||||
$(call Package/wprobe/Default)
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
DEPENDS+=+wprobe-util
|
||||
TITLE:=Wireless measurement data exporter
|
||||
endef
|
||||
|
||||
define Package/wprobe-export/description
|
||||
wprobe-export uses the wprobe kernel module to export
|
||||
wireless driver measurement data via the IPFIX protocol
|
||||
endef
|
||||
|
||||
define Package/wprobe-export/conffiles
|
||||
/etc/config/wprobe
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
mkdir -p $(PKG_BUILD_DIR)
|
||||
$(CP) src/* $(PKG_BUILD_DIR)/
|
||||
endef
|
||||
|
||||
TARGET_CPPFLAGS := \
|
||||
-D_GNU_SOURCE \
|
||||
-I$(STAGING_DIR)/usr/include/libnl-tiny \
|
||||
$(TARGET_CPPFLAGS)
|
||||
|
||||
ifdef CONFIG_PACKAGE_kmod-wprobe
|
||||
define Build/Compile/kmod
|
||||
$(MAKE) -C $(LINUX_DIR) \
|
||||
CROSS_COMPILE="$(KERNEL_CROSS)" \
|
||||
ARCH="$(LINUX_KARCH)" \
|
||||
SUBDIRS="$(PKG_BUILD_DIR)/kernel" \
|
||||
KERNELDIR=$(LINUX_DIR) \
|
||||
CC="$(TARGET_CC)" \
|
||||
EXTRA_CFLAGS="-I$(PKG_BUILD_DIR)/kernel" \
|
||||
modules
|
||||
endef
|
||||
endif
|
||||
|
||||
define Build/Compile/lib
|
||||
$(MAKE) -C $(PKG_BUILD_DIR)/user \
|
||||
$(TARGET_CONFIGURE_OPTS) \
|
||||
CFLAGS="$(TARGET_CFLAGS)" \
|
||||
CPPFLAGS="$(TARGET_CPPFLAGS) -I$(PKG_BUILD_DIR)/kernel" \
|
||||
LDFLAGS="$(TARGET_LDFLAGS)" \
|
||||
HOST_OS=Linux \
|
||||
LIBNL="-lnl-tiny"
|
||||
endef
|
||||
|
||||
ifdef CONFIG_PACKAGE_wprobe-export
|
||||
define Build/Compile/exporter
|
||||
$(MAKE) -C $(PKG_BUILD_DIR)/exporter \
|
||||
$(TARGET_CONFIGURE_OPTS) \
|
||||
CFLAGS="$(TARGET_CFLAGS)" \
|
||||
CPPFLAGS="$(TARGET_CPPFLAGS) -I$(PKG_BUILD_DIR)/kernel -I$(PKG_BUILD_DIR)/user" \
|
||||
LDFLAGS="$(TARGET_LDFLAGS)" \
|
||||
LIBS="$(PKG_BUILD_DIR)/user/libwprobe.a $(STAGING_DIR)/usr/lib/libipfix.a $(STAGING_DIR)/usr/lib/libipfixmisc.a -lnl-tiny -lm"
|
||||
endef
|
||||
endif
|
||||
|
||||
define Build/Compile
|
||||
$(Build/Compile/kmod)
|
||||
$(Build/Compile/lib)
|
||||
$(Build/Compile/exporter)
|
||||
endef
|
||||
|
||||
define Build/InstallDev
|
||||
$(INSTALL_DIR) $(1)/usr/include/wprobe
|
||||
$(CP) $(PKG_BUILD_DIR)/kernel/linux $(1)/usr/include/wprobe
|
||||
endef
|
||||
|
||||
define Package/wprobe-util/install
|
||||
$(INSTALL_DIR) $(1)/sbin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/user/wprobe-util $(1)/sbin/
|
||||
endef
|
||||
|
||||
define Package/wprobe-export/install
|
||||
$(INSTALL_DIR) $(1)/sbin $(1)/etc/init.d $(1)/etc/config
|
||||
$(INSTALL_BIN) ./files/wprobe.init $(1)/etc/init.d/wprobe
|
||||
$(INSTALL_BIN) ./files/wprobe.config $(1)/etc/config/wprobe
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/exporter/wprobe-export $(1)/sbin/
|
||||
endef
|
||||
|
||||
$(eval $(call KernelPackage,wprobe))
|
||||
$(eval $(call BuildPackage,wprobe-util))
|
||||
$(eval $(call BuildPackage,wprobe-export))
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
config export
|
||||
# uncomment this line to enable ipfix export:
|
||||
# option type ipfix
|
||||
option ifname ath0
|
||||
option host ipfix-col
|
||||
option proto tcp
|
||||
|
||||
# enable public wprobe protocol access
|
||||
config export
|
||||
option type wprobe
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
START=90
|
||||
EXPORTER=/sbin/wprobe-export
|
||||
UTIL=/sbin/wprobe-util
|
||||
|
||||
wprobe_ssd() {
|
||||
local cmd="$1"; shift
|
||||
local type="$1"; shift
|
||||
local app="$1"; shift
|
||||
start-stop-daemon "$cmd" -p "/var/run/wprobe-$type.pid" -b ${app:+-x "$app"} -m -- "$@"
|
||||
}
|
||||
|
||||
stop_wprobe() {
|
||||
local type="$1"
|
||||
[ -f "/var/run/wprobe-$type.pid" ] && wprobe_ssd -K "$type"
|
||||
rm -f "/var/run/wprobe-$type.pid"
|
||||
}
|
||||
|
||||
config_wprobe() {
|
||||
config_get ifname "$cfg" ifname
|
||||
config_get interval "$cfg" interval
|
||||
[ -n "$interval" ] || interval=100
|
||||
$UTIL "$ifname" -i "$interval" 2>/dev/null >/dev/null
|
||||
}
|
||||
|
||||
start_proxy() {
|
||||
config_get port "$cfg" port
|
||||
wprobe_ssd -S proxy "$UTIL" -P -p "${port:-17990}"
|
||||
}
|
||||
|
||||
start_ipfix() {
|
||||
local cfg="$1"
|
||||
config_get ifname "$cfg" ifname
|
||||
config_get host "$cfg" host
|
||||
config_get port "$cfg" port
|
||||
config_get proto "$cfg" proto
|
||||
case "$proto" in
|
||||
sctp) proto="-s";;
|
||||
tcp) proto="-t";;
|
||||
udp) proto="-u";;
|
||||
*) proto="-t";;
|
||||
esac
|
||||
[ -z "$ifname" -o -z "$host" ] && {
|
||||
echo "wprobe-export: missing host or interface name in config $cfg"
|
||||
return
|
||||
}
|
||||
config_wprobe "$cfg"
|
||||
wprobe_ssd -S "export-$cfg" "$EXPORTER" "$proto" -i "$ifname" -c "$host" -p "${port:-4739}"
|
||||
}
|
||||
|
||||
start_export() {
|
||||
local cfg="$1"
|
||||
config_get export_type "$cfg" type
|
||||
case "$export_type" in
|
||||
ipfix) [ -x "$EXPORTER" ] && start_ipfix "$cfg";;
|
||||
wprobe) start_proxy "$cfg";;
|
||||
esac
|
||||
}
|
||||
|
||||
stop() {
|
||||
for f in /var/run/wprobe-*.pid; do
|
||||
CFG="${f%%.pid}"
|
||||
CFG="${CFG##/var/run/wprobe-}"
|
||||
stop_wprobe "$CFG"
|
||||
done
|
||||
}
|
||||
|
||||
start() {
|
||||
config_load wprobe
|
||||
config_foreach config_wprobe interface
|
||||
config_foreach start_export export
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
HOST_OS=$(shell uname)
|
||||
|
||||
CC=gcc
|
||||
AR=ar
|
||||
RANLIB=ranlib
|
||||
|
||||
WFLAGS = -Wall -Werror -Wno-format
|
||||
CFLAGS?=-O2
|
||||
CPPFLAGS=
|
||||
LDFLAGS=
|
||||
LIBS=
|
||||
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
include ../Makefile.inc
|
||||
CPPFLAGS += -I../kernel -I../user
|
||||
|
||||
wprobe-export: wprobe-export.c
|
||||
$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS)
|
||||
|
|
@ -1,304 +0,0 @@
|
|||
/*
|
||||
** exporter.c - example exporter
|
||||
**
|
||||
** Copyright Fraunhofer FOKUS
|
||||
**
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <ipfix_def.h>
|
||||
#include <ipfix_def_fokus.h>
|
||||
#include <ipfix_fields_fokus.h>
|
||||
|
||||
#include <ipfix.h>
|
||||
#include <mlog.h>
|
||||
#include <wprobe.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
static ipfix_datarecord_t g_data = { NULL, NULL, 0 };
|
||||
static int do_close = 0;
|
||||
|
||||
struct wprobe_mapping {
|
||||
int id;
|
||||
bool counter;
|
||||
const char *wprobe_id;
|
||||
struct wprobe_value *val;
|
||||
};
|
||||
|
||||
#ifndef ARRAY_SIZE
|
||||
#define ARRAY_SIZE(_array) (sizeof(_array) / sizeof((_array)[0]))
|
||||
#endif
|
||||
|
||||
#define WMAP(_id, _name, ...) \
|
||||
{ \
|
||||
.counter = false, \
|
||||
.id = IPFIX_FT_WPROBE_##_id##_N, \
|
||||
.wprobe_id = _name \
|
||||
, ## __VA_ARGS__ \
|
||||
}
|
||||
|
||||
#define WMAP_COUNTER(_id, _name, ...) \
|
||||
{ \
|
||||
.counter = true, \
|
||||
.id = IPFIX_FT_WPROBE_##_id, \
|
||||
.wprobe_id = _name \
|
||||
, ## __VA_ARGS__ \
|
||||
}
|
||||
|
||||
|
||||
#define WPROBE_OFFSET 2
|
||||
|
||||
static struct wprobe_mapping map_globals[] = {
|
||||
WMAP(NOISE, "noise"),
|
||||
WMAP(PHY_BUSY, "phy_busy"),
|
||||
WMAP(PHY_RX, "phy_rx"),
|
||||
WMAP(PHY_TX, "phy_tx"),
|
||||
WMAP_COUNTER(FRAMES, "frames"),
|
||||
WMAP_COUNTER(PROBEREQ, "probereq"),
|
||||
};
|
||||
|
||||
static struct wprobe_mapping map_perlink[] = {
|
||||
WMAP(IEEE_TX_RATE, "tx_rate"),
|
||||
WMAP(IEEE_RX_RATE, "rx_rate"),
|
||||
WMAP(RSSI, "rssi"),
|
||||
WMAP(SIGNAL, "signal"),
|
||||
WMAP(RETRANSMIT_200, "retransmit_200"),
|
||||
WMAP(RETRANSMIT_400, "retransmit_400"),
|
||||
WMAP(RETRANSMIT_800, "retransmit_800"),
|
||||
WMAP(RETRANSMIT_1600, "retransmit_1600"),
|
||||
};
|
||||
|
||||
static unsigned char link_local[6];
|
||||
static char link_default[6];
|
||||
static int nfields = 0;
|
||||
|
||||
#define FOKUS_USERID 12325
|
||||
|
||||
static void
|
||||
match_template(struct wprobe_mapping *map, int n, struct list_head *list)
|
||||
{
|
||||
struct wprobe_attribute *attr;
|
||||
int i, j, last = -1;
|
||||
|
||||
list_for_each_entry(attr, list, list) {
|
||||
for (i = 0; i < n; i++) {
|
||||
j = (last + 1 + i) % n;
|
||||
if (!strcmp(attr->name, map[j].wprobe_id))
|
||||
goto found;
|
||||
}
|
||||
continue;
|
||||
found:
|
||||
last = j;
|
||||
map[j].val = &attr->val;
|
||||
memset(&attr->val, 0, sizeof(attr->val));
|
||||
nfields++;
|
||||
}
|
||||
}
|
||||
|
||||
/* name: export_ipfix_get_template()
|
||||
*/
|
||||
static ipfix_template_t *
|
||||
prepare_template(ipfix_t *handle)
|
||||
{
|
||||
ipfix_template_t *t = NULL;
|
||||
int size = 3 * nfields + WPROBE_OFFSET;
|
||||
int i;
|
||||
|
||||
if (ipfix_new_data_template( handle, &t, size) < 0) {
|
||||
mlogf( 0, "ipfix_new_template() failed: %s\n", strerror(errno) );
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ipfix_add_field(handle, t, 0, IPFIX_FT_SOURCEMACADDRESS, 6);
|
||||
ipfix_add_field(handle, t, 0, IPFIX_FT_DESTINATIONMACADDRESS, 6);
|
||||
|
||||
g_data.lens = calloc(size, sizeof(g_data.lens[0]));
|
||||
g_data.lens[0] = 6;
|
||||
g_data.lens[1] = 6;
|
||||
for (i = WPROBE_OFFSET; i < size; i++)
|
||||
g_data.lens[i] = 4;
|
||||
|
||||
g_data.addrs = calloc(size, sizeof(g_data.addrs[0]));
|
||||
g_data.addrs[0] = link_local;
|
||||
g_data.maxfields = WPROBE_OFFSET;
|
||||
return t;
|
||||
}
|
||||
|
||||
static void
|
||||
add_template_fields(ipfix_t *handle, ipfix_template_t *t, struct wprobe_mapping *map, int n)
|
||||
{
|
||||
int f = g_data.maxfields;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
if (!map[i].val)
|
||||
continue;
|
||||
|
||||
if (map[i].counter)
|
||||
g_data.addrs[f++] = &map[i].val->U32;
|
||||
else
|
||||
g_data.addrs[f++] = &map[i].val->n;
|
||||
|
||||
if (ipfix_add_field( handle, t, FOKUS_USERID, map[i].id + 0, 4) < 0)
|
||||
exit(1);
|
||||
|
||||
if (map[i].counter)
|
||||
continue;
|
||||
|
||||
g_data.lens[f] = 8;
|
||||
g_data.addrs[f++] = &map[i].val->s;
|
||||
|
||||
g_data.lens[f] = 8;
|
||||
g_data.addrs[f++] = &map[i].val->ss;
|
||||
if (ipfix_add_field( handle, t, FOKUS_USERID, map[i].id + 1, 8) < 0)
|
||||
exit(1);
|
||||
if (ipfix_add_field( handle, t, FOKUS_USERID, map[i].id + 2, 8) < 0)
|
||||
exit(1);
|
||||
}
|
||||
g_data.maxfields = f;
|
||||
}
|
||||
|
||||
static void
|
||||
wprobe_dump_data(ipfix_t *ipfixh, ipfix_template_t *ipfixt, struct wprobe_iface *dev)
|
||||
{
|
||||
struct wprobe_link *link;
|
||||
|
||||
wprobe_update_links(dev);
|
||||
wprobe_request_data(dev, NULL);
|
||||
if (list_empty(&dev->links)) {
|
||||
g_data.addrs[1] = link_default;
|
||||
ipfix_export_array(ipfixh, ipfixt, g_data.maxfields, g_data.addrs, g_data.lens);
|
||||
ipfix_export_flush(ipfixh);
|
||||
}
|
||||
list_for_each_entry(link, &dev->links, list) {
|
||||
g_data.addrs[1] = link->addr;
|
||||
wprobe_request_data(dev, link->addr);
|
||||
ipfix_export_array(ipfixh, ipfixt, g_data.maxfields, g_data.addrs, g_data.lens);
|
||||
ipfix_export_flush(ipfixh);
|
||||
}
|
||||
}
|
||||
|
||||
int main ( int argc, char **argv )
|
||||
{
|
||||
struct wprobe_iface *dev = NULL;
|
||||
ipfix_template_t *ipfixt = NULL;
|
||||
ipfix_t *ipfixh = NULL;
|
||||
int protocol = IPFIX_PROTO_TCP;
|
||||
char *chost = NULL;
|
||||
char *ifname = NULL;
|
||||
int sourceid = 12345;
|
||||
int port = IPFIX_PORTNO;
|
||||
int verbose_level = 0;
|
||||
int opt, i = 10;
|
||||
char *err = NULL;
|
||||
|
||||
while ((opt = getopt(argc, argv, "hi:c:p:vstu")) != EOF) {
|
||||
switch (opt) {
|
||||
case 'p':
|
||||
if ((port=atoi(optarg)) <0) {
|
||||
fprintf( stderr, "Invalid -p argument!\n" );
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
case 'i':
|
||||
ifname = optarg;
|
||||
break;
|
||||
case 'c':
|
||||
chost = optarg;
|
||||
break;
|
||||
|
||||
case 's':
|
||||
protocol = IPFIX_PROTO_SCTP;
|
||||
break;
|
||||
|
||||
case 't':
|
||||
protocol = IPFIX_PROTO_TCP;
|
||||
break;
|
||||
|
||||
case 'u':
|
||||
protocol = IPFIX_PROTO_UDP;
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
verbose_level ++;
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
default:
|
||||
fprintf(stderr, "usage: %s [-hstuv] -i <interface> -c <collector> [-p portno]\n"
|
||||
" -h this help\n"
|
||||
" -i <interface> wprobe interface\n"
|
||||
" -c <collector> collector address\n"
|
||||
" -p <portno> collector port number (default=%d)\n"
|
||||
" -s send data via SCTP\n"
|
||||
" -t send data via TCP (default)\n"
|
||||
" -u send data via UDP\n"
|
||||
" -v increase verbose level\n\n",
|
||||
argv[0], IPFIX_PORTNO );
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (!ifname) {
|
||||
fprintf(stderr, "No interface specified\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!chost) {
|
||||
fprintf(stderr, "No collector specified\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
dev = wprobe_get_auto(ifname, &err);
|
||||
if (!dev || (list_empty(&dev->global_attr) && list_empty(&dev->link_attr))) {
|
||||
fprintf(stderr, "Cannot connect to wprobe on interface '%s': %s\n", ifname, (err ? err : "Unknown error"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
match_template(map_globals, ARRAY_SIZE(map_globals), &dev->global_attr);
|
||||
match_template(map_perlink, ARRAY_SIZE(map_perlink), &dev->link_attr);
|
||||
if (nfields == 0) {
|
||||
fprintf(stderr, "No usable attributes found\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
mlog_set_vlevel( verbose_level );
|
||||
if (ipfix_init() < 0) {
|
||||
fprintf( stderr, "cannot init ipfix module: %s\n", strerror(errno) );
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ipfix_add_vendor_information_elements(ipfix_ft_fokus);
|
||||
if (ipfix_open(&ipfixh, sourceid, IPFIX_VERSION) < 0) {
|
||||
fprintf( stderr, "ipfix_open() failed: %s\n", strerror(errno) );
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (ipfix_add_collector( ipfixh, chost, port, protocol ) < 0) {
|
||||
fprintf( stderr, "ipfix_add_collector(%s,%d) failed: %s\n",
|
||||
chost, port, strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
fprintf(stderr, "Local link address: %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
link_local[0], link_local[1], link_local[2],
|
||||
link_local[3], link_local[4], link_local[5]);
|
||||
|
||||
ipfixt = prepare_template(ipfixh);
|
||||
add_template_fields(ipfixh, ipfixt, map_globals, ARRAY_SIZE(map_globals));
|
||||
add_template_fields(ipfixh, ipfixt, map_perlink, ARRAY_SIZE(map_perlink));
|
||||
|
||||
while (!do_close) {
|
||||
sleep(1);
|
||||
wprobe_dump_data(ipfixh, ipfixt, dev);
|
||||
}
|
||||
|
||||
ipfix_delete_template( ipfixh, ipfixt );
|
||||
ipfix_close( ipfixh );
|
||||
ipfix_cleanup();
|
||||
exit(0);
|
||||
}
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
#include <inttypes.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/**
|
||||
* struct wprobe_value: data structure for attribute values
|
||||
* see kernel api netlink attributes for more information
|
||||
*/
|
||||
struct wprobe_value {
|
||||
/* attribute value */
|
||||
union data {
|
||||
const char *STRING;
|
||||
uint8_t U8;
|
||||
uint16_t U16;
|
||||
uint32_t U32;
|
||||
uint64_t U64;
|
||||
int8_t S8;
|
||||
int16_t S16;
|
||||
int32_t S32;
|
||||
int64_t S64;
|
||||
} data;
|
||||
/* statistics */
|
||||
int64_t s, ss;
|
||||
double avg, stdev;
|
||||
unsigned int n;
|
||||
void *usedata; /* Pointer to used data.something */
|
||||
};
|
||||
|
||||
struct exporter_data {
|
||||
int id; /* ipfix id */
|
||||
int userid; /* focus or global */
|
||||
int size; /* size in byte*/
|
||||
struct wprobe_value val;
|
||||
};
|
||||
|
|
@ -1 +0,0 @@
|
|||
To compile pfc you need at least libpcap version 1.0, as it requires proper radiotap header support
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
#!/usr/bin/perl
|
||||
use strict;
|
||||
|
||||
# helpers for custom packet format
|
||||
# bytes 0-7 are used by a dummy radiotap header
|
||||
my $WLAN_LEN = "radio[8:2]";
|
||||
my $SNR = "radio[10:1]";
|
||||
my $DEFAULT = undef;
|
||||
|
||||
my $MAGIC = "WPFF";
|
||||
my $VERSION = 1; # filter binary format version
|
||||
my $HDRLEN = 3; # assumed storage space for custom fields
|
||||
|
||||
my $output = "filter.bin";
|
||||
my $config = {
|
||||
"packetsize" => [
|
||||
[ "small", "$WLAN_LEN < 250" ],
|
||||
[ "medium", "$WLAN_LEN < 800" ],
|
||||
[ "big", $DEFAULT ],
|
||||
],
|
||||
"snr" => [
|
||||
[ "low", "$SNR < 10" ],
|
||||
[ "medium", "$SNR < 20" ],
|
||||
[ "high", $DEFAULT ],
|
||||
],
|
||||
"type" => [
|
||||
[ "beacon", "type mgt subtype beacon" ],
|
||||
[ "data", "type data subtype data" ],
|
||||
[ "qosdata", "type data subtype qos-data" ],
|
||||
[ "other", "$DEFAULT" ]
|
||||
]
|
||||
};
|
||||
|
||||
sub escape_q($) {
|
||||
my $str = shift;
|
||||
$str =~ s/'/'\\''/g;
|
||||
return $str;
|
||||
}
|
||||
|
||||
my $GROUPS = scalar(keys %$config);
|
||||
open OUTPUT, ">$output" or die "Cannot open output file: $!\n";
|
||||
print OUTPUT pack("a4CCn", $MAGIC, $VERSION, $HDRLEN, $GROUPS);
|
||||
|
||||
foreach my $groupname (keys %$config) {
|
||||
my $default = 0;
|
||||
my $group = $config->{$groupname};
|
||||
print OUTPUT pack("a32N", $groupname, scalar(@$group));
|
||||
foreach my $filter (@$group) {
|
||||
if (!$filter->[1]) {
|
||||
$default > 0 and print "Cannot add more than one default filter per group: $groupname -> ".$filter->[0]."\n";
|
||||
print OUTPUT pack("a32N", $filter->[0], 0);
|
||||
$default++;
|
||||
} else {
|
||||
open FILTER, "./pfc '".escape_q($filter->[0])."' '".escape_q($filter->[1])."' |"
|
||||
or die "Failed to run filter command for '".$filter->[0]."': $!\n";
|
||||
while (<FILTER>) {
|
||||
print OUTPUT $_;
|
||||
}
|
||||
close FILTER;
|
||||
$? and die "Filter '".$filter->[0]."' did not compile.\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
#include <arpa/inet.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <pcap.h>
|
||||
#include <pcap-bpf.h>
|
||||
|
||||
struct wprobe_filter_hdr {
|
||||
char name[32];
|
||||
uint32_t len;
|
||||
} hdr;
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
struct bpf_program filter;
|
||||
pcap_t *pc;
|
||||
int i;
|
||||
|
||||
if (argc != 3)
|
||||
{
|
||||
fprintf(stderr, "Usage: %s <name> <expression>\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
pc = pcap_open_dead(DLT_IEEE802_11_RADIO, 256);
|
||||
if (pcap_compile(pc, &filter, argv[2], 1, 0) != 0)
|
||||
{
|
||||
pcap_perror(pc, argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* fix up for linux */
|
||||
for (i = 0; i < filter.bf_len; i++) {
|
||||
struct bpf_insn *bi = &filter.bf_insns[i];
|
||||
switch(BPF_CLASS(bi->code)) {
|
||||
case BPF_RET:
|
||||
if (BPF_MODE(bi->code) == BPF_K) {
|
||||
if (bi->k != 0)
|
||||
bi->k = 65535;
|
||||
}
|
||||
break;
|
||||
}
|
||||
bi->code = ntohs(bi->code);
|
||||
bi->k = ntohl(bi->k);
|
||||
}
|
||||
|
||||
memset(&hdr, 0, sizeof(hdr));
|
||||
strncpy(hdr.name, argv[1], sizeof(hdr.name));
|
||||
hdr.len = htonl(filter.bf_len);
|
||||
fwrite(&hdr, sizeof(hdr), 1, stdout);
|
||||
fwrite(filter.bf_insns, 8, filter.bf_len, stdout);
|
||||
fflush(stdout);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
EXTRA_CFLAGS += -I.
|
||||
|
||||
obj-m := wprobe.o wprobe-dummy.o
|
||||
|
||||
wprobe-objs := wprobe-core.o
|
||||
|
|
@ -1,397 +0,0 @@
|
|||
/*
|
||||
* wprobe.h: API for the wireless probe interface
|
||||
* Copyright (C) 2008-2009 Felix Fietkau <nbd@openwrt.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __WPROBE_H
|
||||
#define __WPROBE_H
|
||||
|
||||
#ifdef __KERNEL__
|
||||
#include <linux/types.h>
|
||||
#include <linux/if_ether.h>
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/list.h>
|
||||
#include <linux/timer.h>
|
||||
#include <linux/filter.h>
|
||||
#include <net/genetlink.h>
|
||||
#endif
|
||||
|
||||
/**
|
||||
* enum wprobe_attr: netlink attribute list
|
||||
*
|
||||
* @WPROBE_ATTR_UNSPEC: unused
|
||||
*
|
||||
* @WPROBE_ATTR_INTERFACE: interface name to process query on (NLA_STRING)
|
||||
* @WPROBE_ATTR_MAC: mac address (used for wireless links) (NLA_STRING)
|
||||
* @WPROBE_ATTR_FLAGS: interface/link/attribute flags (see enum wprobe_flags) (NLA_U32)a
|
||||
* @WPROBE_ATTR_DURATION: sampling duration (in milliseconds) (NLA_MSECS)
|
||||
*
|
||||
* @WPROBE_ATTR_ID: attribute id (NLA_U32)
|
||||
* @WPROBE_ATTR_NAME: attribute name (NLA_STRING)
|
||||
* @WPROBE_ATTR_TYPE: attribute type (NLA_U8)
|
||||
*
|
||||
* attribute values:
|
||||
*
|
||||
* @WPROBE_VAL_STRING: string value (NLA_STRING)
|
||||
* @WPROBE_VAL_S8: signed 8-bit integer (NLA_U8)
|
||||
* @WPROBE_VAL_S16: signed 16-bit integer (NLA_U16)
|
||||
* @WPROBE_VAL_S32: signed 32-bit integer (NLA_U32)
|
||||
* @WPROBE_VAL_S64: signed 64-bit integer (NLA_U64)
|
||||
* @WPROBE_VAL_U8: unsigned 8-bit integer (NLA_U8)
|
||||
* @WPROBE_VAL_U16: unsigned 16-bit integer (NLA_U16)
|
||||
* @WPROBE_VAL_U32: unsigned 32-bit integer (NLA_U32)
|
||||
* @WPROBE_VAL_U64: unsigned 64-bit integer (NLA_U64)
|
||||
*
|
||||
* statistics:
|
||||
* @WPROBE_VAL_SUM: sum of all samples
|
||||
* @WPROBE_VAL_SUM_SQ: sum of all samples^2
|
||||
* @WPROBE_VAL_SAMPLES: number of samples
|
||||
* @WPROBE_VAL_SCALE_TIME: last time the samples were scaled down
|
||||
*
|
||||
* configuration:
|
||||
* @WPROBE_ATTR_INTERVAL: (measurement interval in milliseconds) (NLA_MSECS)
|
||||
* @WPROBE_ATTR_SAMPLES_MIN: minimum samples to keep during inactivity (NLA_U32)
|
||||
* @WPROBE_ATTR_SAMPLES_MAX: maximum samples to keep before scaling down (NLA_U32)
|
||||
* @WPROBE_ATTR_SAMPLES_SCALE_M: multiplier for scaling down samples (NLA_U32)
|
||||
* @WPROBE_ATTR_SAMPLES_SCALE_D: divisor for scaling down samples (NLA_U32)
|
||||
*
|
||||
* @WPROBE_ATTR_LAST: unused
|
||||
*/
|
||||
enum wprobe_attr {
|
||||
/* query attributes */
|
||||
WPROBE_ATTR_UNSPEC,
|
||||
WPROBE_ATTR_INTERFACE,
|
||||
WPROBE_ATTR_MAC,
|
||||
WPROBE_ATTR_FLAGS,
|
||||
|
||||
/* response data */
|
||||
WPROBE_ATTR_ID,
|
||||
WPROBE_ATTR_NAME,
|
||||
WPROBE_ATTR_TYPE,
|
||||
WPROBE_ATTR_DURATION,
|
||||
|
||||
/* value type attributes */
|
||||
WPROBE_VAL_STRING,
|
||||
WPROBE_VAL_S8,
|
||||
WPROBE_VAL_S16,
|
||||
WPROBE_VAL_S32,
|
||||
WPROBE_VAL_S64,
|
||||
WPROBE_VAL_U8,
|
||||
WPROBE_VAL_U16,
|
||||
WPROBE_VAL_U32,
|
||||
WPROBE_VAL_U64,
|
||||
|
||||
/* aggregates for statistics */
|
||||
WPROBE_VAL_SUM,
|
||||
WPROBE_VAL_SUM_SQ,
|
||||
WPROBE_VAL_SAMPLES,
|
||||
WPROBE_VAL_SCALE_TIME,
|
||||
|
||||
/* config attributes */
|
||||
WPROBE_ATTR_INTERVAL,
|
||||
WPROBE_ATTR_SAMPLES_MIN,
|
||||
WPROBE_ATTR_SAMPLES_MAX,
|
||||
WPROBE_ATTR_SAMPLES_SCALE_M,
|
||||
WPROBE_ATTR_SAMPLES_SCALE_D,
|
||||
WPROBE_ATTR_FILTER,
|
||||
|
||||
WPROBE_ATTR_FILTER_GROUP,
|
||||
WPROBE_ATTR_RXCOUNT,
|
||||
WPROBE_ATTR_TXCOUNT,
|
||||
|
||||
WPROBE_ATTR_LAST
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* enum wprobe_cmd: netlink commands for interacting with wprobe
|
||||
*
|
||||
* @WPROBE_CMD_UNSPEC: unused
|
||||
*
|
||||
* @WPROBE_CMD_GET_LIST: get global/link property list
|
||||
* @WPROBE_CMD_GET_INFO: get global/link properties
|
||||
* @WPROBE_CMD_SET_FLAGS: set global/link flags
|
||||
* @WPROBE_CMD_MEASURE: take a snapshot of the current data
|
||||
* @WPROBE_CMD_GET_LINKS: get a list of links
|
||||
* @WPROBE_CMD_CONFIG: set config options
|
||||
* @WPROBE_CMD_GET_FILTER: get counters for active filters
|
||||
*
|
||||
* @WPROBE_CMD_LAST: unused
|
||||
*
|
||||
* options for GET_INFO and SET_FLAGS:
|
||||
* - mac address set: per-link
|
||||
* - mac address unset: globalsa
|
||||
*/
|
||||
enum wprobe_cmd {
|
||||
WPROBE_CMD_UNSPEC,
|
||||
WPROBE_CMD_GET_LIST,
|
||||
WPROBE_CMD_GET_INFO,
|
||||
WPROBE_CMD_SET_FLAGS,
|
||||
WPROBE_CMD_MEASURE,
|
||||
WPROBE_CMD_GET_LINKS,
|
||||
WPROBE_CMD_CONFIG,
|
||||
WPROBE_CMD_GET_FILTER,
|
||||
WPROBE_CMD_LAST
|
||||
};
|
||||
|
||||
/**
|
||||
* enum wprobe_flags: flags for wprobe links and items
|
||||
* @WPROBE_F_KEEPSTAT: keep statistics for this link/device
|
||||
* @WPROBE_F_RESET: reset statistics now
|
||||
* @WPROBE_F_NEWDATA: used to indicate that a value has been updated
|
||||
*/
|
||||
enum wprobe_flags {
|
||||
WPROBE_F_KEEPSTAT = (1 << 0),
|
||||
WPROBE_F_RESET = (1 << 1),
|
||||
WPROBE_F_NEWDATA = (1 << 2),
|
||||
};
|
||||
|
||||
#ifdef __KERNEL__
|
||||
|
||||
struct wprobe_link;
|
||||
struct wprobe_item;
|
||||
struct wprobe_source;
|
||||
struct wprobe_value;
|
||||
|
||||
/**
|
||||
* struct wprobe_link - data structure describing a wireless link
|
||||
* @iface: pointer to the wprobe_iface that this link belongs to
|
||||
* @addr: BSSID of the remote link partner
|
||||
* @flags: link flags (see wprobe_flags)
|
||||
* @priv: user pointer
|
||||
*
|
||||
* @list: for internal use
|
||||
* @val: for internal use
|
||||
*/
|
||||
struct wprobe_link {
|
||||
struct list_head list;
|
||||
struct wprobe_iface *iface;
|
||||
char addr[ETH_ALEN];
|
||||
u32 flags;
|
||||
void *priv;
|
||||
struct wprobe_value *val;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct wprobe_item - data structure describing the format of wprobe_link::data or wprobe_iface::data
|
||||
* @name: name of the field
|
||||
* @type: data type of this field
|
||||
* @flags: measurement item flags (see wprobe_flags)
|
||||
*/
|
||||
struct wprobe_item {
|
||||
const char *name;
|
||||
enum wprobe_attr type;
|
||||
u32 flags;
|
||||
};
|
||||
|
||||
struct wprobe_value {
|
||||
bool pending;
|
||||
union {
|
||||
/*
|
||||
* the following are kept uppercase to allow
|
||||
* for automated checking against WPROBE_VAL_*
|
||||
* via BUG_ON()
|
||||
*/
|
||||
const char *STRING;
|
||||
u8 U8;
|
||||
u16 U16;
|
||||
u32 U32;
|
||||
u64 U64;
|
||||
s8 S8;
|
||||
s16 S16;
|
||||
s32 S32;
|
||||
s64 S64;
|
||||
};
|
||||
s64 s, ss;
|
||||
unsigned int n;
|
||||
|
||||
/* timestamps */
|
||||
u64 first, last;
|
||||
u64 scale_timestamp;
|
||||
};
|
||||
|
||||
struct wprobe_filter_item_hdr {
|
||||
char name[32];
|
||||
__be32 n_items;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct wprobe_filter_item {
|
||||
struct wprobe_filter_item_hdr hdr;
|
||||
struct sock_filter filter[];
|
||||
} __attribute__((packed));
|
||||
|
||||
struct wprobe_filter_counter {
|
||||
u64 tx;
|
||||
u64 rx;
|
||||
};
|
||||
|
||||
struct wprobe_filter_group {
|
||||
const char *name;
|
||||
int n_items;
|
||||
struct wprobe_filter_item **items;
|
||||
struct wprobe_filter_counter *counters;
|
||||
};
|
||||
|
||||
struct wprobe_filter_hdr {
|
||||
__u8 magic[4];
|
||||
__u8 version;
|
||||
__u8 hdrlen;
|
||||
__u16 n_groups;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct wprobe_filter {
|
||||
spinlock_t lock;
|
||||
struct sk_buff *skb;
|
||||
void *data;
|
||||
int n_groups;
|
||||
int hdrlen;
|
||||
struct wprobe_filter_item **items;
|
||||
struct wprobe_filter_counter *counters;
|
||||
struct wprobe_filter_group groups[];
|
||||
};
|
||||
|
||||
enum {
|
||||
WPROBE_PKT_RX = 0x00,
|
||||
WPROBE_PKT_TX = 0x10,
|
||||
};
|
||||
|
||||
struct wprobe_wlan_hdr {
|
||||
u16 len;
|
||||
u8 snr;
|
||||
u8 type;
|
||||
} __attribute__((packed));
|
||||
|
||||
|
||||
/**
|
||||
* struct wprobe_source - data structure describing a wireless interface
|
||||
*
|
||||
* @name: name of the interface
|
||||
* @addr: local mac address of the interface
|
||||
* @links: list of wireless links to poll
|
||||
* @link_items: description of the per-link data structure
|
||||
* @n_link_items: number of link description items
|
||||
* @global_items: description of the per-interface data structure
|
||||
* @n_global_items: number of per-interface description items
|
||||
* @sync_data: callback allowing the driver to prepare data for the wprobe poll
|
||||
*
|
||||
* @list: head for the list of interfaces
|
||||
* @priv: user pointer
|
||||
* @lock: spinlock protecting value data access
|
||||
* @val: internal use
|
||||
* @query_val: internal use
|
||||
*
|
||||
* if sync_data is NULL, wprobe assumes that it can access the data structure
|
||||
* at any time (in atomic context). if sync_data returns a negative error code,
|
||||
* the poll request will not be handled for the given link
|
||||
*/
|
||||
struct wprobe_iface {
|
||||
/* to be filled in by wprobe source drivers */
|
||||
const char *name;
|
||||
const char *addr;
|
||||
const struct wprobe_item *link_items;
|
||||
int n_link_items;
|
||||
const struct wprobe_item *global_items;
|
||||
int n_global_items;
|
||||
|
||||
int (*sync_data)(struct wprobe_iface *dev, struct wprobe_link *l,
|
||||
struct wprobe_value *val, bool measure);
|
||||
void *priv;
|
||||
|
||||
/* handled by the wprobe core */
|
||||
struct list_head list;
|
||||
struct list_head links;
|
||||
spinlock_t lock;
|
||||
struct wprobe_value *val;
|
||||
struct wprobe_value *query_val;
|
||||
struct wprobe_filter *active_filter;
|
||||
|
||||
u32 measure_interval;
|
||||
struct timer_list measure_timer;
|
||||
|
||||
u32 scale_min;
|
||||
u32 scale_max;
|
||||
u32 scale_m;
|
||||
u32 scale_d;
|
||||
};
|
||||
|
||||
|
||||
#define WPROBE_FILL_BEGIN(_ptr, _list) do { \
|
||||
struct wprobe_value *__val = (_ptr); \
|
||||
const struct wprobe_item *__item = _list; \
|
||||
u64 __msecs = jiffies_to_msecs(jiffies)
|
||||
|
||||
#define WPROBE_SET(_idx, _type, _value) \
|
||||
if (__item[_idx].type != WPROBE_VAL_##_type) { \
|
||||
printk("ERROR: invalid data type at %s:%d\n", __FILE__, __LINE__); \
|
||||
break; \
|
||||
} \
|
||||
__val[_idx].pending = true; \
|
||||
__val[_idx]._type = _value; \
|
||||
if (!__val[_idx].first) \
|
||||
__val[_idx].first = __msecs; \
|
||||
__val[_idx].first = __msecs
|
||||
|
||||
#define WPROBE_FILL_END() \
|
||||
} while(0)
|
||||
|
||||
/**
|
||||
* wprobe_add_iface: register an interface with the wireless probe subsystem
|
||||
* @dev: wprobe_iface structure describing the interface
|
||||
*/
|
||||
extern int __weak wprobe_add_iface(struct wprobe_iface *dev);
|
||||
|
||||
/**
|
||||
* wprobe_remove_iface: deregister an interface from the wireless probe subsystem
|
||||
* @dev: wprobe_iface structure describing the interface
|
||||
*/
|
||||
extern void __weak wprobe_remove_iface(struct wprobe_iface *dev);
|
||||
|
||||
/**
|
||||
* wprobe_add_link: register a new wireless link
|
||||
* @dev: wprobe_iface structure describing the interface
|
||||
* @l: storage space for the wprobe_link structure
|
||||
* @addr: mac address of the new link
|
||||
*
|
||||
* the entire wprobe_link structure is overwritten by this function call
|
||||
*/
|
||||
extern int __weak wprobe_add_link(struct wprobe_iface *dev, struct wprobe_link *l, const char *addr);
|
||||
|
||||
/**
|
||||
* wprobe_remove_link: deregister a previously registered wireless link
|
||||
* @dev: wprobe_iface structure describing the interface
|
||||
* @l: wprobe_link data structure
|
||||
*/
|
||||
extern void __weak wprobe_remove_link(struct wprobe_iface *dev, struct wprobe_link *l);
|
||||
|
||||
/**
|
||||
* wprobe_update_stats: update statistics after sampling values
|
||||
* @dev: wprobe_iface structure describing the interface
|
||||
* @l: wprobe_link data structure
|
||||
*
|
||||
* if l == NULL, then the stats for globals are updated
|
||||
*/
|
||||
extern void __weak wprobe_update_stats(struct wprobe_iface *dev, struct wprobe_link *l);
|
||||
|
||||
/**
|
||||
* wprobe_add_frame: add frame for layer 2 analysis
|
||||
* @dev: wprobe_iface structure describing the interface
|
||||
* @hdr: metadata for the frame
|
||||
* @data: 802.11 header pointer
|
||||
* @len: length of the 802.11 header
|
||||
*/
|
||||
extern int __weak wprobe_add_frame(struct wprobe_iface *dev, const struct wprobe_wlan_hdr *hdr, void *data, int len);
|
||||
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
#endif
|
||||
|
|
@ -1,96 +0,0 @@
|
|||
/*
|
||||
* wprobe-core.c: Wireless probe interface dummy driver
|
||||
* Copyright (C) 2008-2009 Felix Fietkau <nbd@openwrt.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/version.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/random.h>
|
||||
#include <linux/wprobe.h>
|
||||
|
||||
static const char local_addr[] = "\x00\x13\x37\xba\xbe\x00";
|
||||
|
||||
enum dummy_global_values {
|
||||
DUMMY_GLOBAL_MEDIUM_BUSY
|
||||
};
|
||||
enum dummy_link_values {
|
||||
DUMMY_LINK_SNR
|
||||
};
|
||||
|
||||
struct wprobe_item dummy_perlink[] = {
|
||||
[DUMMY_LINK_SNR] = {
|
||||
.name = "snr",
|
||||
.type = WPROBE_VAL_U8,
|
||||
.flags = WPROBE_F_KEEPSTAT,
|
||||
},
|
||||
};
|
||||
|
||||
struct wprobe_item dummy_globals[] = {
|
||||
[DUMMY_GLOBAL_MEDIUM_BUSY] = {
|
||||
.name = "medium_busy",
|
||||
.type = WPROBE_VAL_U8,
|
||||
.flags = WPROBE_F_KEEPSTAT,
|
||||
}
|
||||
};
|
||||
|
||||
int dummy_sync(struct wprobe_iface *dev, struct wprobe_link *l, struct wprobe_value *val, bool measure)
|
||||
{
|
||||
u8 intval = 0;
|
||||
|
||||
get_random_bytes(&intval, 1);
|
||||
if (l) {
|
||||
WPROBE_FILL_BEGIN(val, dummy_perlink);
|
||||
WPROBE_SET(DUMMY_LINK_SNR, U8, (intval % 40));
|
||||
WPROBE_FILL_END();
|
||||
} else {
|
||||
WPROBE_FILL_BEGIN(val, dummy_globals);
|
||||
WPROBE_SET(DUMMY_GLOBAL_MEDIUM_BUSY, U8, (intval % 100));
|
||||
WPROBE_FILL_END();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct wprobe_iface dummy_dev = {
|
||||
.name = "dummy",
|
||||
.addr = local_addr,
|
||||
.link_items = dummy_perlink,
|
||||
.n_link_items = ARRAY_SIZE(dummy_perlink),
|
||||
.global_items = dummy_globals,
|
||||
.n_global_items = ARRAY_SIZE(dummy_globals),
|
||||
.sync_data = dummy_sync,
|
||||
};
|
||||
|
||||
static struct wprobe_link dummy_link;
|
||||
|
||||
static int __init
|
||||
wprobe_dummy_init(void)
|
||||
{
|
||||
wprobe_add_iface(&dummy_dev);
|
||||
wprobe_add_link(&dummy_dev, &dummy_link, "\x00\x13\x37\xda\xda\x00");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __exit
|
||||
wprobe_dummy_exit(void)
|
||||
{
|
||||
wprobe_remove_link(&dummy_dev, &dummy_link);
|
||||
wprobe_remove_iface(&dummy_dev);
|
||||
}
|
||||
|
||||
module_init(wprobe_dummy_init);
|
||||
module_exit(wprobe_dummy_exit);
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
include ../Makefile.inc
|
||||
|
||||
CPPFLAGS += -I../kernel
|
||||
LDFLAGS =
|
||||
|
||||
ifneq ($(HOST_OS),Linux)
|
||||
USE_LIBNL_MICRO=1
|
||||
else
|
||||
USE_LIBNL_MICRO=
|
||||
endif
|
||||
|
||||
ifeq ($(USE_LIBNL_MICRO),1)
|
||||
LIBNL_PREFIX = /usr/local
|
||||
LIBNL = $(LIBNL_PREFIX)/lib/libnl-micro.a
|
||||
CPPFLAGS += -I$(LIBNL_PREFIX)/include/libnl-micro
|
||||
EXTRA_CFLAGS += -DNO_LOCAL_ACCESS
|
||||
else
|
||||
LIBNL = -lnl
|
||||
endif
|
||||
|
||||
LIBM = -lm
|
||||
LIBS = $(LIBNL) $(LIBM)
|
||||
|
||||
all: libwprobe.a wprobe-util
|
||||
|
||||
libwprobe.a: wprobe-lib.o
|
||||
rm -f $@
|
||||
$(AR) rcu $@ $^
|
||||
$(RANLIB) $@
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(WFLAGS) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(EXTRA_CFLAGS) $<
|
||||
|
||||
wprobe-util: wprobe-util.o wprobe-lib.o
|
||||
$(CC) -o $@ $^ $(LDFLAGS) $(LIBS)
|
||||
|
||||
clean:
|
||||
rm -f *.o *.a wprobe-util
|
||||
|
|
@ -1,601 +0,0 @@
|
|||
#ifndef _LINUX_LIST_H
|
||||
#define _LINUX_LIST_H
|
||||
|
||||
#include <stddef.h>
|
||||
/**
|
||||
* container_of - cast a member of a structure out to the containing structure
|
||||
* @ptr: the pointer to the member.
|
||||
* @type: the type of the container struct this is embedded in.
|
||||
* @member: the name of the member within the struct.
|
||||
*
|
||||
*/
|
||||
#ifndef container_of
|
||||
#define container_of(ptr, type, member) ( \
|
||||
(type *)( (char *)ptr - offsetof(type,member) ))
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Simple doubly linked list implementation.
|
||||
*
|
||||
* Some of the internal functions ("__xxx") are useful when
|
||||
* manipulating whole lists rather than single entries, as
|
||||
* sometimes we already know the next/prev entries and we can
|
||||
* generate better code by using them directly rather than
|
||||
* using the generic single-entry routines.
|
||||
*/
|
||||
|
||||
struct list_head {
|
||||
struct list_head *next, *prev;
|
||||
};
|
||||
|
||||
#define LIST_HEAD_INIT(name) { &(name), &(name) }
|
||||
|
||||
#define LIST_HEAD(name) \
|
||||
struct list_head name = LIST_HEAD_INIT(name)
|
||||
|
||||
static inline void INIT_LIST_HEAD(struct list_head *list)
|
||||
{
|
||||
list->next = list;
|
||||
list->prev = list;
|
||||
}
|
||||
|
||||
/*
|
||||
* Insert a new entry between two known consecutive entries.
|
||||
*
|
||||
* This is only for internal list manipulation where we know
|
||||
* the prev/next entries already!
|
||||
*/
|
||||
static inline void __list_add(struct list_head *new,
|
||||
struct list_head *prev,
|
||||
struct list_head *next)
|
||||
{
|
||||
next->prev = new;
|
||||
new->next = next;
|
||||
new->prev = prev;
|
||||
prev->next = new;
|
||||
}
|
||||
|
||||
/**
|
||||
* list_add - add a new entry
|
||||
* @new: new entry to be added
|
||||
* @head: list head to add it after
|
||||
*
|
||||
* Insert a new entry after the specified head.
|
||||
* This is good for implementing stacks.
|
||||
*/
|
||||
static inline void list_add(struct list_head *new, struct list_head *head)
|
||||
{
|
||||
__list_add(new, head, head->next);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* list_add_tail - add a new entry
|
||||
* @new: new entry to be added
|
||||
* @head: list head to add it before
|
||||
*
|
||||
* Insert a new entry before the specified head.
|
||||
* This is useful for implementing queues.
|
||||
*/
|
||||
static inline void list_add_tail(struct list_head *new, struct list_head *head)
|
||||
{
|
||||
__list_add(new, head->prev, head);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Delete a list entry by making the prev/next entries
|
||||
* point to each other.
|
||||
*
|
||||
* This is only for internal list manipulation where we know
|
||||
* the prev/next entries already!
|
||||
*/
|
||||
static inline void __list_del(struct list_head * prev, struct list_head * next)
|
||||
{
|
||||
next->prev = prev;
|
||||
prev->next = next;
|
||||
}
|
||||
|
||||
/**
|
||||
* list_del - deletes entry from list.
|
||||
* @entry: the element to delete from the list.
|
||||
* Note: list_empty() on entry does not return true after this, the entry is
|
||||
* in an undefined state.
|
||||
*/
|
||||
static inline void list_del(struct list_head *entry)
|
||||
{
|
||||
__list_del(entry->prev, entry->next);
|
||||
entry->next = NULL;
|
||||
entry->prev = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* list_replace - replace old entry by new one
|
||||
* @old : the element to be replaced
|
||||
* @new : the new element to insert
|
||||
*
|
||||
* If @old was empty, it will be overwritten.
|
||||
*/
|
||||
static inline void list_replace(struct list_head *old,
|
||||
struct list_head *new)
|
||||
{
|
||||
new->next = old->next;
|
||||
new->next->prev = new;
|
||||
new->prev = old->prev;
|
||||
new->prev->next = new;
|
||||
}
|
||||
|
||||
static inline void list_replace_init(struct list_head *old,
|
||||
struct list_head *new)
|
||||
{
|
||||
list_replace(old, new);
|
||||
INIT_LIST_HEAD(old);
|
||||
}
|
||||
|
||||
/**
|
||||
* list_del_init - deletes entry from list and reinitialize it.
|
||||
* @entry: the element to delete from the list.
|
||||
*/
|
||||
static inline void list_del_init(struct list_head *entry)
|
||||
{
|
||||
__list_del(entry->prev, entry->next);
|
||||
INIT_LIST_HEAD(entry);
|
||||
}
|
||||
|
||||
/**
|
||||
* list_move - delete from one list and add as another's head
|
||||
* @list: the entry to move
|
||||
* @head: the head that will precede our entry
|
||||
*/
|
||||
static inline void list_move(struct list_head *list, struct list_head *head)
|
||||
{
|
||||
__list_del(list->prev, list->next);
|
||||
list_add(list, head);
|
||||
}
|
||||
|
||||
/**
|
||||
* list_move_tail - delete from one list and add as another's tail
|
||||
* @list: the entry to move
|
||||
* @head: the head that will follow our entry
|
||||
*/
|
||||
static inline void list_move_tail(struct list_head *list,
|
||||
struct list_head *head)
|
||||
{
|
||||
__list_del(list->prev, list->next);
|
||||
list_add_tail(list, head);
|
||||
}
|
||||
|
||||
/**
|
||||
* list_is_last - tests whether @list is the last entry in list @head
|
||||
* @list: the entry to test
|
||||
* @head: the head of the list
|
||||
*/
|
||||
static inline int list_is_last(const struct list_head *list,
|
||||
const struct list_head *head)
|
||||
{
|
||||
return list->next == head;
|
||||
}
|
||||
|
||||
/**
|
||||
* list_empty - tests whether a list is empty
|
||||
* @head: the list to test.
|
||||
*/
|
||||
static inline int list_empty(const struct list_head *head)
|
||||
{
|
||||
return head->next == head;
|
||||
}
|
||||
|
||||
/**
|
||||
* list_empty_careful - tests whether a list is empty and not being modified
|
||||
* @head: the list to test
|
||||
*
|
||||
* Description:
|
||||
* tests whether a list is empty _and_ checks that no other CPU might be
|
||||
* in the process of modifying either member (next or prev)
|
||||
*
|
||||
* NOTE: using list_empty_careful() without synchronization
|
||||
* can only be safe if the only activity that can happen
|
||||
* to the list entry is list_del_init(). Eg. it cannot be used
|
||||
* if another CPU could re-list_add() it.
|
||||
*/
|
||||
static inline int list_empty_careful(const struct list_head *head)
|
||||
{
|
||||
struct list_head *next = head->next;
|
||||
return (next == head) && (next == head->prev);
|
||||
}
|
||||
|
||||
static inline void __list_splice(struct list_head *list,
|
||||
struct list_head *head)
|
||||
{
|
||||
struct list_head *first = list->next;
|
||||
struct list_head *last = list->prev;
|
||||
struct list_head *at = head->next;
|
||||
|
||||
first->prev = head;
|
||||
head->next = first;
|
||||
|
||||
last->next = at;
|
||||
at->prev = last;
|
||||
}
|
||||
|
||||
/**
|
||||
* list_splice - join two lists
|
||||
* @list: the new list to add.
|
||||
* @head: the place to add it in the first list.
|
||||
*/
|
||||
static inline void list_splice(struct list_head *list, struct list_head *head)
|
||||
{
|
||||
if (!list_empty(list))
|
||||
__list_splice(list, head);
|
||||
}
|
||||
|
||||
/**
|
||||
* list_splice_init - join two lists and reinitialise the emptied list.
|
||||
* @list: the new list to add.
|
||||
* @head: the place to add it in the first list.
|
||||
*
|
||||
* The list at @list is reinitialised
|
||||
*/
|
||||
static inline void list_splice_init(struct list_head *list,
|
||||
struct list_head *head)
|
||||
{
|
||||
if (!list_empty(list)) {
|
||||
__list_splice(list, head);
|
||||
INIT_LIST_HEAD(list);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* list_entry - get the struct for this entry
|
||||
* @ptr: the &struct list_head pointer.
|
||||
* @type: the type of the struct this is embedded in.
|
||||
* @member: the name of the list_struct within the struct.
|
||||
*/
|
||||
#define list_entry(ptr, type, member) \
|
||||
container_of(ptr, type, member)
|
||||
|
||||
/**
|
||||
* list_first_entry - get the first element from a list
|
||||
* @ptr: the list head to take the element from.
|
||||
* @type: the type of the struct this is embedded in.
|
||||
* @member: the name of the list_struct within the struct.
|
||||
*
|
||||
* Note, that list is expected to be not empty.
|
||||
*/
|
||||
#define list_first_entry(ptr, type, member) \
|
||||
list_entry((ptr)->next, type, member)
|
||||
|
||||
/**
|
||||
* list_for_each - iterate over a list
|
||||
* @pos: the &struct list_head to use as a loop cursor.
|
||||
* @head: the head for your list.
|
||||
*/
|
||||
#define list_for_each(pos, head) \
|
||||
for (pos = (head)->next; pos != (head); \
|
||||
pos = pos->next)
|
||||
|
||||
/**
|
||||
* __list_for_each - iterate over a list
|
||||
* @pos: the &struct list_head to use as a loop cursor.
|
||||
* @head: the head for your list.
|
||||
*
|
||||
* This variant differs from list_for_each() in that it's the
|
||||
* simplest possible list iteration code, no prefetching is done.
|
||||
* Use this for code that knows the list to be very short (empty
|
||||
* or 1 entry) most of the time.
|
||||
*/
|
||||
#define __list_for_each(pos, head) \
|
||||
for (pos = (head)->next; pos != (head); pos = pos->next)
|
||||
|
||||
/**
|
||||
* list_for_each_prev - iterate over a list backwards
|
||||
* @pos: the &struct list_head to use as a loop cursor.
|
||||
* @head: the head for your list.
|
||||
*/
|
||||
#define list_for_each_prev(pos, head) \
|
||||
for (pos = (head)->prev; pos != (head); \
|
||||
pos = pos->prev)
|
||||
|
||||
/**
|
||||
* list_for_each_safe - iterate over a list safe against removal of list entry
|
||||
* @pos: the &struct list_head to use as a loop cursor.
|
||||
* @n: another &struct list_head to use as temporary storage
|
||||
* @head: the head for your list.
|
||||
*/
|
||||
#define list_for_each_safe(pos, n, head) \
|
||||
for (pos = (head)->next, n = pos->next; pos != (head); \
|
||||
pos = n, n = pos->next)
|
||||
|
||||
/**
|
||||
* list_for_each_prev_safe - iterate over a list backwards safe against removal of list entry
|
||||
* @pos: the &struct list_head to use as a loop cursor.
|
||||
* @n: another &struct list_head to use as temporary storage
|
||||
* @head: the head for your list.
|
||||
*/
|
||||
#define list_for_each_prev_safe(pos, n, head) \
|
||||
for (pos = (head)->prev, n = pos->prev; \
|
||||
pos != (head); \
|
||||
pos = n, n = pos->prev)
|
||||
|
||||
/**
|
||||
* list_for_each_entry - iterate over list of given type
|
||||
* @pos: the type * to use as a loop cursor.
|
||||
* @head: the head for your list.
|
||||
* @member: the name of the list_struct within the struct.
|
||||
*/
|
||||
#define list_for_each_entry(pos, head, member) \
|
||||
for (pos = list_entry((head)->next, typeof(*pos), member); \
|
||||
&pos->member != (head); \
|
||||
pos = list_entry(pos->member.next, typeof(*pos), member))
|
||||
|
||||
/**
|
||||
* list_for_each_entry_reverse - iterate backwards over list of given type.
|
||||
* @pos: the type * to use as a loop cursor.
|
||||
* @head: the head for your list.
|
||||
* @member: the name of the list_struct within the struct.
|
||||
*/
|
||||
#define list_for_each_entry_reverse(pos, head, member) \
|
||||
for (pos = list_entry((head)->prev, typeof(*pos), member); \
|
||||
&pos->member != (head); \
|
||||
pos = list_entry(pos->member.prev, typeof(*pos), member))
|
||||
|
||||
/**
|
||||
* list_prepare_entry - prepare a pos entry for use in list_for_each_entry_continue()
|
||||
* @pos: the type * to use as a start point
|
||||
* @head: the head of the list
|
||||
* @member: the name of the list_struct within the struct.
|
||||
*
|
||||
* Prepares a pos entry for use as a start point in list_for_each_entry_continue().
|
||||
*/
|
||||
#define list_prepare_entry(pos, head, member) \
|
||||
((pos) ? : list_entry(head, typeof(*pos), member))
|
||||
|
||||
/**
|
||||
* list_for_each_entry_continue - continue iteration over list of given type
|
||||
* @pos: the type * to use as a loop cursor.
|
||||
* @head: the head for your list.
|
||||
* @member: the name of the list_struct within the struct.
|
||||
*
|
||||
* Continue to iterate over list of given type, continuing after
|
||||
* the current position.
|
||||
*/
|
||||
#define list_for_each_entry_continue(pos, head, member) \
|
||||
for (pos = list_entry(pos->member.next, typeof(*pos), member); \
|
||||
&pos->member != (head); \
|
||||
pos = list_entry(pos->member.next, typeof(*pos), member))
|
||||
|
||||
/**
|
||||
* list_for_each_entry_continue_reverse - iterate backwards from the given point
|
||||
* @pos: the type * to use as a loop cursor.
|
||||
* @head: the head for your list.
|
||||
* @member: the name of the list_struct within the struct.
|
||||
*
|
||||
* Start to iterate over list of given type backwards, continuing after
|
||||
* the current position.
|
||||
*/
|
||||
#define list_for_each_entry_continue_reverse(pos, head, member) \
|
||||
for (pos = list_entry(pos->member.prev, typeof(*pos), member); \
|
||||
&pos->member != (head); \
|
||||
pos = list_entry(pos->member.prev, typeof(*pos), member))
|
||||
|
||||
/**
|
||||
* list_for_each_entry_from - iterate over list of given type from the current point
|
||||
* @pos: the type * to use as a loop cursor.
|
||||
* @head: the head for your list.
|
||||
* @member: the name of the list_struct within the struct.
|
||||
*
|
||||
* Iterate over list of given type, continuing from current position.
|
||||
*/
|
||||
#define list_for_each_entry_from(pos, head, member) \
|
||||
for (; &pos->member != (head); \
|
||||
pos = list_entry(pos->member.next, typeof(*pos), member))
|
||||
|
||||
/**
|
||||
* list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
|
||||
* @pos: the type * to use as a loop cursor.
|
||||
* @n: another type * to use as temporary storage
|
||||
* @head: the head for your list.
|
||||
* @member: the name of the list_struct within the struct.
|
||||
*/
|
||||
#define list_for_each_entry_safe(pos, n, head, member) \
|
||||
for (pos = list_entry((head)->next, typeof(*pos), member), \
|
||||
n = list_entry(pos->member.next, typeof(*pos), member); \
|
||||
&pos->member != (head); \
|
||||
pos = n, n = list_entry(n->member.next, typeof(*n), member))
|
||||
|
||||
/**
|
||||
* list_for_each_entry_safe_continue
|
||||
* @pos: the type * to use as a loop cursor.
|
||||
* @n: another type * to use as temporary storage
|
||||
* @head: the head for your list.
|
||||
* @member: the name of the list_struct within the struct.
|
||||
*
|
||||
* Iterate over list of given type, continuing after current point,
|
||||
* safe against removal of list entry.
|
||||
*/
|
||||
#define list_for_each_entry_safe_continue(pos, n, head, member) \
|
||||
for (pos = list_entry(pos->member.next, typeof(*pos), member), \
|
||||
n = list_entry(pos->member.next, typeof(*pos), member); \
|
||||
&pos->member != (head); \
|
||||
pos = n, n = list_entry(n->member.next, typeof(*n), member))
|
||||
|
||||
/**
|
||||
* list_for_each_entry_safe_from
|
||||
* @pos: the type * to use as a loop cursor.
|
||||
* @n: another type * to use as temporary storage
|
||||
* @head: the head for your list.
|
||||
* @member: the name of the list_struct within the struct.
|
||||
*
|
||||
* Iterate over list of given type from current point, safe against
|
||||
* removal of list entry.
|
||||
*/
|
||||
#define list_for_each_entry_safe_from(pos, n, head, member) \
|
||||
for (n = list_entry(pos->member.next, typeof(*pos), member); \
|
||||
&pos->member != (head); \
|
||||
pos = n, n = list_entry(n->member.next, typeof(*n), member))
|
||||
|
||||
/**
|
||||
* list_for_each_entry_safe_reverse
|
||||
* @pos: the type * to use as a loop cursor.
|
||||
* @n: another type * to use as temporary storage
|
||||
* @head: the head for your list.
|
||||
* @member: the name of the list_struct within the struct.
|
||||
*
|
||||
* Iterate backwards over list of given type, safe against removal
|
||||
* of list entry.
|
||||
*/
|
||||
#define list_for_each_entry_safe_reverse(pos, n, head, member) \
|
||||
for (pos = list_entry((head)->prev, typeof(*pos), member), \
|
||||
n = list_entry(pos->member.prev, typeof(*pos), member); \
|
||||
&pos->member != (head); \
|
||||
pos = n, n = list_entry(n->member.prev, typeof(*n), member))
|
||||
|
||||
/*
|
||||
* Double linked lists with a single pointer list head.
|
||||
* Mostly useful for hash tables where the two pointer list head is
|
||||
* too wasteful.
|
||||
* You lose the ability to access the tail in O(1).
|
||||
*/
|
||||
|
||||
struct hlist_head {
|
||||
struct hlist_node *first;
|
||||
};
|
||||
|
||||
struct hlist_node {
|
||||
struct hlist_node *next, **pprev;
|
||||
};
|
||||
|
||||
#define HLIST_HEAD_INIT { .first = NULL }
|
||||
#define HLIST_HEAD(name) struct hlist_head name = { .first = NULL }
|
||||
#define INIT_HLIST_HEAD(ptr) ((ptr)->first = NULL)
|
||||
static inline void INIT_HLIST_NODE(struct hlist_node *h)
|
||||
{
|
||||
h->next = NULL;
|
||||
h->pprev = NULL;
|
||||
}
|
||||
|
||||
static inline int hlist_unhashed(const struct hlist_node *h)
|
||||
{
|
||||
return !h->pprev;
|
||||
}
|
||||
|
||||
static inline int hlist_empty(const struct hlist_head *h)
|
||||
{
|
||||
return !h->first;
|
||||
}
|
||||
|
||||
static inline void __hlist_del(struct hlist_node *n)
|
||||
{
|
||||
struct hlist_node *next = n->next;
|
||||
struct hlist_node **pprev = n->pprev;
|
||||
*pprev = next;
|
||||
if (next)
|
||||
next->pprev = pprev;
|
||||
}
|
||||
|
||||
static inline void hlist_del(struct hlist_node *n)
|
||||
{
|
||||
__hlist_del(n);
|
||||
n->next = NULL;
|
||||
n->pprev = NULL;
|
||||
}
|
||||
|
||||
static inline void hlist_del_init(struct hlist_node *n)
|
||||
{
|
||||
if (!hlist_unhashed(n)) {
|
||||
__hlist_del(n);
|
||||
INIT_HLIST_NODE(n);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static inline void hlist_add_head(struct hlist_node *n, struct hlist_head *h)
|
||||
{
|
||||
struct hlist_node *first = h->first;
|
||||
n->next = first;
|
||||
if (first)
|
||||
first->pprev = &n->next;
|
||||
h->first = n;
|
||||
n->pprev = &h->first;
|
||||
}
|
||||
|
||||
|
||||
/* next must be != NULL */
|
||||
static inline void hlist_add_before(struct hlist_node *n,
|
||||
struct hlist_node *next)
|
||||
{
|
||||
n->pprev = next->pprev;
|
||||
n->next = next;
|
||||
next->pprev = &n->next;
|
||||
*(n->pprev) = n;
|
||||
}
|
||||
|
||||
static inline void hlist_add_after(struct hlist_node *n,
|
||||
struct hlist_node *next)
|
||||
{
|
||||
next->next = n->next;
|
||||
n->next = next;
|
||||
next->pprev = &n->next;
|
||||
|
||||
if(next->next)
|
||||
next->next->pprev = &next->next;
|
||||
}
|
||||
|
||||
#define hlist_entry(ptr, type, member) container_of(ptr,type,member)
|
||||
|
||||
#define hlist_for_each(pos, head) \
|
||||
for (pos = (head)->first; pos; pos = pos->next)
|
||||
|
||||
#define hlist_for_each_safe(pos, n, head) \
|
||||
for (pos = (head)->first; pos; pos = n)
|
||||
|
||||
/**
|
||||
* hlist_for_each_entry - iterate over list of given type
|
||||
* @tpos: the type * to use as a loop cursor.
|
||||
* @pos: the &struct hlist_node to use as a loop cursor.
|
||||
* @head: the head for your list.
|
||||
* @member: the name of the hlist_node within the struct.
|
||||
*/
|
||||
#define hlist_for_each_entry(tpos, pos, head, member) \
|
||||
for (pos = (head)->first; pos && \
|
||||
({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
|
||||
pos = pos->next)
|
||||
|
||||
/**
|
||||
* hlist_for_each_entry_continue - iterate over a hlist continuing after current point
|
||||
* @tpos: the type * to use as a loop cursor.
|
||||
* @pos: the &struct hlist_node to use as a loop cursor.
|
||||
* @member: the name of the hlist_node within the struct.
|
||||
*/
|
||||
#define hlist_for_each_entry_continue(tpos, pos, member) \
|
||||
for (pos = (pos)->next; pos && \
|
||||
({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
|
||||
pos = pos->next)
|
||||
|
||||
/**
|
||||
* hlist_for_each_entry_from - iterate over a hlist continuing from current point
|
||||
* @tpos: the type * to use as a loop cursor.
|
||||
* @pos: the &struct hlist_node to use as a loop cursor.
|
||||
* @member: the name of the hlist_node within the struct.
|
||||
*/
|
||||
#define hlist_for_each_entry_from(tpos, pos, member) \
|
||||
for (; pos && \
|
||||
({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
|
||||
pos = pos->next)
|
||||
|
||||
/**
|
||||
* hlist_for_each_entry_safe - iterate over list of given type safe against removal of list entry
|
||||
* @tpos: the type * to use as a loop cursor.
|
||||
* @pos: the &struct hlist_node to use as a loop cursor.
|
||||
* @n: another &struct hlist_node to use as temporary storage
|
||||
* @head: the head for your list.
|
||||
* @member: the name of the hlist_node within the struct.
|
||||
*/
|
||||
#define hlist_for_each_entry_safe(tpos, pos, n, head, member) \
|
||||
for (pos = (head)->first; \
|
||||
pos && ({ n = pos->next; 1; }) && \
|
||||
({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \
|
||||
pos = n)
|
||||
|
||||
#endif
|
||||
|
|
@ -1,450 +0,0 @@
|
|||
/*
|
||||
* wprobe-test.c: Wireless probe user space test code
|
||||
* Copyright (C) 2008-2009 Felix Fietkau <nbd@openwrt.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/wait.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <inttypes.h>
|
||||
#include <errno.h>
|
||||
#include <stdint.h>
|
||||
#include <getopt.h>
|
||||
#include <stdbool.h>
|
||||
#include <unistd.h>
|
||||
#include <netdb.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <linux/wprobe.h>
|
||||
#include "wprobe.h"
|
||||
|
||||
static bool simple_mode = false;
|
||||
|
||||
static const char *
|
||||
wprobe_dump_value(struct wprobe_attribute *attr)
|
||||
{
|
||||
static char buf[128];
|
||||
|
||||
#define HANDLE_TYPE(_type, _format) \
|
||||
case WPROBE_VAL_##_type: \
|
||||
snprintf(buf, sizeof(buf), _format, attr->val._type); \
|
||||
break
|
||||
|
||||
switch(attr->type) {
|
||||
HANDLE_TYPE(S8, "%d");
|
||||
HANDLE_TYPE(S16, "%d");
|
||||
HANDLE_TYPE(S32, "%d");
|
||||
HANDLE_TYPE(S64, "%lld");
|
||||
HANDLE_TYPE(U8, "%d");
|
||||
HANDLE_TYPE(U16, "%d");
|
||||
HANDLE_TYPE(U32, "%d");
|
||||
HANDLE_TYPE(U64, "%lld");
|
||||
case WPROBE_VAL_STRING:
|
||||
/* FIXME: implement this */
|
||||
default:
|
||||
strncpy(buf, "<unknown>", sizeof(buf));
|
||||
break;
|
||||
}
|
||||
if ((attr->flags & WPROBE_F_KEEPSTAT) &&
|
||||
(attr->val.n > 0)) {
|
||||
int len = strlen(buf);
|
||||
if (simple_mode)
|
||||
snprintf(buf + len, sizeof(buf) - len, ";%.02f;%.02f;%d;%lld;%lld", attr->val.avg, attr->val.stdev, attr->val.n, attr->val.s, attr->val.ss);
|
||||
else
|
||||
snprintf(buf + len, sizeof(buf) - len, " (avg: %.02f; stdev: %.02f, n=%d)", attr->val.avg, attr->val.stdev, attr->val.n);
|
||||
}
|
||||
#undef HANDLE_TYPE
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
wprobe_dump_data(struct wprobe_iface *dev)
|
||||
{
|
||||
struct wprobe_attribute *attr;
|
||||
struct wprobe_link *link;
|
||||
bool first = true;
|
||||
|
||||
if (!simple_mode)
|
||||
fprintf(stdout, "\n");
|
||||
wprobe_request_data(dev, NULL);
|
||||
list_for_each_entry(attr, &dev->global_attr, list) {
|
||||
if (simple_mode) {
|
||||
if (first)
|
||||
fprintf(stdout, "[global]\n");
|
||||
fprintf(stdout, "%s=%s\n", attr->name, wprobe_dump_value(attr));
|
||||
} else {
|
||||
fprintf(stdout, (first ?
|
||||
"Global: %s=%s\n" :
|
||||
" %s=%s\n"),
|
||||
attr->name,
|
||||
wprobe_dump_value(attr)
|
||||
);
|
||||
}
|
||||
first = false;
|
||||
}
|
||||
|
||||
list_for_each_entry(link, &dev->links, list) {
|
||||
first = true;
|
||||
wprobe_request_data(dev, link->addr);
|
||||
list_for_each_entry(attr, &dev->link_attr, list) {
|
||||
if (first) {
|
||||
fprintf(stdout,
|
||||
(simple_mode ?
|
||||
"[%02x:%02x:%02x:%02x:%02x:%02x]\n%s=%s\n" :
|
||||
"%02x:%02x:%02x:%02x:%02x:%02x: %s=%s\n"),
|
||||
link->addr[0], link->addr[1], link->addr[2],
|
||||
link->addr[3], link->addr[4], link->addr[5],
|
||||
attr->name,
|
||||
wprobe_dump_value(attr));
|
||||
first = false;
|
||||
} else {
|
||||
fprintf(stdout,
|
||||
(simple_mode ? "%s=%s\n" :
|
||||
" %s=%s\n"),
|
||||
attr->name,
|
||||
wprobe_dump_value(attr));
|
||||
}
|
||||
}
|
||||
}
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
static const char *attr_typestr[] = {
|
||||
[0] = "Unknown",
|
||||
[WPROBE_VAL_STRING] = "String",
|
||||
[WPROBE_VAL_U8] = "Unsigned 8 bit",
|
||||
[WPROBE_VAL_U16] = "Unsigned 16 bit",
|
||||
[WPROBE_VAL_U32] = "Unsigned 32 bit",
|
||||
[WPROBE_VAL_U64] = "Unsigned 64 bit",
|
||||
[WPROBE_VAL_S8] = "Signed 8 bit",
|
||||
[WPROBE_VAL_S16] = "Signed 16 bit",
|
||||
[WPROBE_VAL_S32] = "Signed 32 bit",
|
||||
[WPROBE_VAL_S64] = "Signed 64 bit",
|
||||
};
|
||||
|
||||
static int usage(const char *prog)
|
||||
{
|
||||
fprintf(stderr,
|
||||
#ifndef NO_LOCAL_ACCESS
|
||||
"Usage: %s <interface>|<host>:<device>|-P [options]\n"
|
||||
#else
|
||||
"Usage: %s <host>:<device> [options]\n"
|
||||
#endif
|
||||
"\n"
|
||||
"Options:\n"
|
||||
" -a: Print attributes\n"
|
||||
" -c: Only apply configuration\n"
|
||||
" -d: Delay between measurement dumps (in milliseconds, default: 1000)\n"
|
||||
" A value of 0 (zero) prints once and exits; useful for scripts\n"
|
||||
" -f: Dump contents of layer 2 filter counters during measurement\n"
|
||||
" -F <file>: Apply layer 2 filters from <file>\n"
|
||||
" -h: This help text\n"
|
||||
" -i <interval>: Set measurement interval\n"
|
||||
" -m: Run measurement loop\n"
|
||||
" -p: Set the TCP port for server/client (default: 17990)\n"
|
||||
#ifndef NO_LOCAL_ACCESS
|
||||
" -P: Run in proxy mode (listen on network)\n"
|
||||
#endif
|
||||
"\n"
|
||||
, prog);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static void show_attributes(struct wprobe_iface *dev)
|
||||
{
|
||||
struct wprobe_attribute *attr;
|
||||
if (simple_mode)
|
||||
return;
|
||||
list_for_each_entry(attr, &dev->global_attr, list) {
|
||||
fprintf(stdout, "Global attribute: '%s' (%s)\n",
|
||||
attr->name, attr_typestr[attr->type]);
|
||||
}
|
||||
list_for_each_entry(attr, &dev->link_attr, list) {
|
||||
fprintf(stdout, "Link attribute: '%s' (%s)\n",
|
||||
attr->name, attr_typestr[attr->type]);
|
||||
}
|
||||
}
|
||||
|
||||
static void show_filter_simple(void *arg, const char *group, struct wprobe_filter_item *items, int n_items)
|
||||
{
|
||||
int i;
|
||||
|
||||
fprintf(stdout, "[filter:%s]\n", group);
|
||||
for (i = 0; i < n_items; i++) {
|
||||
fprintf(stdout, "%s=%lld;%lld\n",
|
||||
items[i].name, items[i].tx, items[i].rx);
|
||||
}
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
|
||||
static void show_filter(void *arg, const char *group, struct wprobe_filter_item *items, int n_items)
|
||||
{
|
||||
int i;
|
||||
fprintf(stdout, "Filter group: '%s' (tx/rx)\n", group);
|
||||
for (i = 0; i < n_items; i++) {
|
||||
fprintf(stdout, " - %s (%lld/%lld)\n",
|
||||
items[i].name, items[i].tx, items[i].rx);
|
||||
}
|
||||
}
|
||||
|
||||
static void loop_measurement(struct wprobe_iface *dev, bool print_filters, unsigned long delay)
|
||||
{
|
||||
do {
|
||||
wprobe_update_links(dev);
|
||||
wprobe_dump_data(dev);
|
||||
if (print_filters)
|
||||
wprobe_dump_filters(dev, simple_mode ? show_filter_simple : show_filter, NULL);
|
||||
usleep(delay * 1000);
|
||||
}
|
||||
while (delay);
|
||||
}
|
||||
|
||||
static void set_filter(struct wprobe_iface *dev, const char *filename)
|
||||
{
|
||||
unsigned char *buf = NULL;
|
||||
unsigned int buflen = 0;
|
||||
unsigned int len = 0;
|
||||
int fd;
|
||||
|
||||
/* clear filter */
|
||||
if (filename[0] == 0) {
|
||||
dev->filter_len = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
fd = open(filename, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
perror("open filter");
|
||||
return;
|
||||
}
|
||||
|
||||
do {
|
||||
int rlen;
|
||||
|
||||
if (!buf) {
|
||||
len = 0;
|
||||
buflen = 1024;
|
||||
buf = malloc(1024);
|
||||
} else {
|
||||
buflen *= 2;
|
||||
buf = realloc(buf, buflen);
|
||||
}
|
||||
rlen = read(fd, buf + len, buflen - len);
|
||||
if (rlen < 0)
|
||||
break;
|
||||
|
||||
len += rlen;
|
||||
} while (len == buflen);
|
||||
|
||||
dev->filter = buf;
|
||||
dev->filter_len = len;
|
||||
close(fd);
|
||||
}
|
||||
|
||||
#ifndef NO_LOCAL_ACCESS
|
||||
|
||||
static void sigchld_handler(int s)
|
||||
{
|
||||
while (waitpid(-1, NULL, WNOHANG) > 0);
|
||||
}
|
||||
|
||||
static int run_proxy(int port)
|
||||
{
|
||||
struct sockaddr_in sa;
|
||||
struct sigaction sig;
|
||||
int v = 1;
|
||||
int s;
|
||||
|
||||
s = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (s < 0) {
|
||||
perror("socket");
|
||||
return 1;
|
||||
}
|
||||
|
||||
sig.sa_handler = sigchld_handler; // Signal Handler fuer Zombie Prozesse
|
||||
sigemptyset(&sig.sa_mask);
|
||||
sig.sa_flags = SA_RESTART;
|
||||
sigaction(SIGCHLD, &sig, NULL);
|
||||
|
||||
memset(&sa, 0, sizeof(sa));
|
||||
sa.sin_family = AF_INET;
|
||||
sa.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
sa.sin_port = htons(wprobe_port);
|
||||
|
||||
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &v, sizeof(v));
|
||||
if (bind(s, (struct sockaddr *) &sa, sizeof(sa)) < 0) {
|
||||
perror("bind");
|
||||
return 1;
|
||||
}
|
||||
if (listen(s, 10)) {
|
||||
perror("listen");
|
||||
return 1;
|
||||
}
|
||||
while(1) {
|
||||
unsigned int addrlen = sizeof(struct sockaddr_in);
|
||||
int ret, c;
|
||||
|
||||
c = accept(s, (struct sockaddr *)&sa, &addrlen);
|
||||
if (c < 0) {
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
|
||||
perror("accept");
|
||||
return 1;
|
||||
}
|
||||
if (fork() == 0) {
|
||||
/* close server socket, stdin, stdout, stderr */
|
||||
close(s);
|
||||
close(0);
|
||||
close(1);
|
||||
close(2);
|
||||
|
||||
wprobe_server_init(c);
|
||||
do {
|
||||
ret = wprobe_server_handle(c);
|
||||
} while (ret >= 0);
|
||||
wprobe_server_done();
|
||||
close(c);
|
||||
exit(0);
|
||||
}
|
||||
close(c);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct wprobe_iface *dev = NULL;
|
||||
const char *ifname;
|
||||
const char *prog = argv[0];
|
||||
char *err = NULL;
|
||||
enum {
|
||||
CMD_NONE,
|
||||
CMD_CONFIG,
|
||||
CMD_MEASURE,
|
||||
CMD_PROXY,
|
||||
} cmd = CMD_NONE;
|
||||
const char *filter = NULL;
|
||||
bool print_attributes = false;
|
||||
bool print_filters = false;
|
||||
unsigned long delay = 1000;
|
||||
int interval = -1;
|
||||
int ch;
|
||||
|
||||
if (argc < 2)
|
||||
return usage(prog);
|
||||
|
||||
#ifndef NO_LOCAL_ACCESS
|
||||
if (!strcmp(argv[1], "-P")) {
|
||||
while ((ch = getopt(argc - 1, argv + 1, "p:")) != -1) {
|
||||
switch(ch) {
|
||||
case 'p':
|
||||
/* set port */
|
||||
wprobe_port = strtoul(optarg, NULL, 0);
|
||||
break;
|
||||
default:
|
||||
return usage(prog);
|
||||
}
|
||||
}
|
||||
return run_proxy(wprobe_port);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (argv[1][0] == '-')
|
||||
return usage(prog);
|
||||
|
||||
ifname = argv[1];
|
||||
argv++;
|
||||
argc--;
|
||||
|
||||
while ((ch = getopt(argc, argv, "acd:fF:hi:msp:")) != -1) {
|
||||
switch(ch) {
|
||||
case 'a':
|
||||
print_attributes = true;
|
||||
break;
|
||||
case 'c':
|
||||
cmd = CMD_CONFIG;
|
||||
break;
|
||||
case 'd':
|
||||
delay = strtoul(optarg, NULL, 10);
|
||||
break;
|
||||
case 'm':
|
||||
cmd = CMD_MEASURE;
|
||||
break;
|
||||
case 'i':
|
||||
interval = strtoul(optarg, NULL, 10);
|
||||
break;
|
||||
case 'f':
|
||||
print_filters = true;
|
||||
break;
|
||||
case 'F':
|
||||
if (filter) {
|
||||
fprintf(stderr, "Cannot set multiple filters\n");
|
||||
return usage(prog);
|
||||
}
|
||||
filter = optarg;
|
||||
break;
|
||||
case 's':
|
||||
simple_mode = true;
|
||||
break;
|
||||
case 'p':
|
||||
/* set port */
|
||||
wprobe_port = strtoul(optarg, NULL, 0);
|
||||
break;
|
||||
case 'h':
|
||||
default:
|
||||
usage(prog);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
dev = wprobe_get_auto(ifname, &err);
|
||||
if (!dev || (list_empty(&dev->global_attr) &&
|
||||
list_empty(&dev->link_attr))) {
|
||||
if (err)
|
||||
fprintf(stdout, "%s\n", err);
|
||||
else
|
||||
fprintf(stderr, "Interface '%s' not found\n", ifname);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (filter || interval >= 0) {
|
||||
if (filter)
|
||||
set_filter(dev, filter);
|
||||
if (interval >= 0)
|
||||
dev->interval = interval;
|
||||
|
||||
wprobe_apply_config(dev);
|
||||
}
|
||||
|
||||
if (cmd != CMD_CONFIG) {
|
||||
if (print_attributes)
|
||||
show_attributes(dev);
|
||||
}
|
||||
if (cmd == CMD_MEASURE)
|
||||
loop_measurement(dev, print_filters, delay);
|
||||
|
||||
wprobe_free_dev(dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,213 +0,0 @@
|
|||
/*
|
||||
* wprobe.h: Wireless probe user space library
|
||||
* Copyright (C) 2008-2009 Felix Fietkau <nbd@openwrt.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __WPROBE_USER_H
|
||||
#define __WPROBE_USER_H
|
||||
#include <inttypes.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "list.h"
|
||||
|
||||
/**
|
||||
* struct wprobe_value: data structure for attribute values
|
||||
* @STRING: string value (currently unsupported)
|
||||
* @U8: unsigned 8-bit integer value
|
||||
* @U16: unsigned 16-bit integer value
|
||||
* @U32: unsigned 32-bit integer value
|
||||
* @U64: unsigned 64-bit integer value
|
||||
* @S8: signed 8-bit integer value
|
||||
* @S16: signed 16-bit integer value
|
||||
* @S32: signed 32-bit integer value
|
||||
* @S64: signed 64-bit integer value
|
||||
*
|
||||
* @n: number of sample values
|
||||
* @avg: average value
|
||||
* @stdev: standard deviation
|
||||
* @s: sum of all sample values (internal use)
|
||||
* @ss: sum of all sample values squared (internal use)
|
||||
*/
|
||||
struct wprobe_value {
|
||||
/* attribute value */
|
||||
union {
|
||||
const char *STRING;
|
||||
uint8_t U8;
|
||||
uint16_t U16;
|
||||
uint32_t U32;
|
||||
uint64_t U64;
|
||||
int8_t S8;
|
||||
int16_t S16;
|
||||
int32_t S32;
|
||||
int64_t S64;
|
||||
};
|
||||
/* statistics */
|
||||
int64_t s, ss;
|
||||
float avg, stdev;
|
||||
unsigned int n;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct wprobe_attribute: data structures for attribute descriptions
|
||||
* @list: linked list data structure for a list of attributes
|
||||
* @id: attribute id
|
||||
* @type: netlink type for the attribute (see kernel api documentation)
|
||||
* @flags: attribute flags (see kernel api documentation)
|
||||
* @val: cached version of the last netlink query, will be overwritten on each request
|
||||
* @name: attribute name
|
||||
*/
|
||||
struct wprobe_attribute {
|
||||
struct list_head list;
|
||||
int id;
|
||||
int type;
|
||||
uint32_t flags;
|
||||
struct wprobe_value val;
|
||||
char name[];
|
||||
};
|
||||
|
||||
/**
|
||||
* struct wprobe_link: data structure for the link description
|
||||
* @list: linked list data structure for a list of links
|
||||
* @flags: link flags (see kernel api documentation)
|
||||
* @addr: mac address of the remote link partner
|
||||
*/
|
||||
struct wprobe_link {
|
||||
struct list_head list;
|
||||
uint32_t flags;
|
||||
unsigned char addr[6];
|
||||
};
|
||||
|
||||
struct wprobe_filter_item {
|
||||
char name[32];
|
||||
uint64_t rx;
|
||||
uint64_t tx;
|
||||
};
|
||||
|
||||
struct wprobe_iface_ops;
|
||||
struct wprobe_iface {
|
||||
const struct wprobe_iface_ops *ops;
|
||||
|
||||
int sockfd;
|
||||
const char *ifname;
|
||||
unsigned int genl_family;
|
||||
char addr[6];
|
||||
|
||||
struct list_head global_attr;
|
||||
struct list_head link_attr;
|
||||
struct list_head links;
|
||||
|
||||
/* config */
|
||||
int interval;
|
||||
int scale_min;
|
||||
int scale_max;
|
||||
int scale_m;
|
||||
int scale_d;
|
||||
|
||||
/* filter */
|
||||
void *filter;
|
||||
|
||||
/* filter_len:
|
||||
* set to -1 to drop the current filter
|
||||
* automatically reset to 0 after config apply
|
||||
*/
|
||||
int filter_len;
|
||||
};
|
||||
|
||||
typedef void (*wprobe_filter_cb)(void *arg, const char *group, struct wprobe_filter_item *items, int n_items);
|
||||
extern int wprobe_port;
|
||||
|
||||
/**
|
||||
* wprobe_update_links: get a list of all link partners
|
||||
* @dev: wprobe device structure
|
||||
* @list: linked list for storing link descriptions
|
||||
*
|
||||
* when wprobe_update_links is called multiple times, the linked list
|
||||
* is updated with new link partners, old entries are automatically expired
|
||||
*/
|
||||
extern int wprobe_update_links(struct wprobe_iface *dev);
|
||||
|
||||
/**
|
||||
* wprobe_dump_filters: dump all layer 2 filter counters
|
||||
* @dev: wprobe device structure
|
||||
* @cb: callback (called once per filter group)
|
||||
* @arg: user argument for the callback
|
||||
*/
|
||||
extern int wprobe_dump_filters(struct wprobe_iface *dev, wprobe_filter_cb cb, void *arg);
|
||||
|
||||
/**
|
||||
* wprobe_measure: start a measurement request for all global attributes
|
||||
* @dev: wprobe device structure
|
||||
*
|
||||
* not all attributes are automatically filled with data, since for some
|
||||
* it may be desirable to control the sampling interval from user space
|
||||
* you can use this function to do that.
|
||||
*/
|
||||
extern int wprobe_measure(struct wprobe_iface *dev);
|
||||
|
||||
/**
|
||||
* wprobe_get_dev: get a handle to a local wprobe device
|
||||
* @ifname: name of the wprobe interface
|
||||
*
|
||||
* queries the wprobe interface for all attributes
|
||||
* must be freed with wprobe_free_dev
|
||||
*/
|
||||
extern struct wprobe_iface *wprobe_get_dev(const char *ifname);
|
||||
|
||||
/**
|
||||
* wprobe_get_auto: get a handle to a local or remote wprobe device
|
||||
* @arg: pointer to the wprobe device, either <dev> (local) or <host>:<dev> (remote)
|
||||
*/
|
||||
extern struct wprobe_iface *wprobe_get_auto(const char *arg, char **err);
|
||||
|
||||
/**
|
||||
* wprobe_get_dev: free all device information
|
||||
* @dev: wprobe device structure
|
||||
*/
|
||||
extern void wprobe_free_dev(struct wprobe_iface *dev);
|
||||
|
||||
/**
|
||||
* wprobe_apply_config: apply configuration data
|
||||
* @dev: wprobe device structure
|
||||
*
|
||||
* uploads all configuration values from @dev that are not set to -1
|
||||
*/
|
||||
extern int wprobe_apply_config(struct wprobe_iface *dev);
|
||||
|
||||
/**
|
||||
* wprobe_request_data: request new sampling values for the given list of attributes
|
||||
* @dev: wprobe device structure
|
||||
* @addr: (optional) mac address of the link partner
|
||||
*
|
||||
* if addr is unset, global values are stored in the global attributes list
|
||||
* if addr is set, per-link values for the given address are stored in the link attributes list
|
||||
*/
|
||||
extern int wprobe_request_data(struct wprobe_iface *dev, const unsigned char *addr);
|
||||
|
||||
/**
|
||||
* wprobe_server_init: send a wprobe server init message to a server's client socket
|
||||
* @socket: socket of the connection to the client
|
||||
*/
|
||||
extern int wprobe_server_init(int socket);
|
||||
|
||||
/**
|
||||
* wprobe_server_handle: read a request from the client socket, process it, send the response
|
||||
* @socket: socket of the connection to the client
|
||||
*/
|
||||
extern int wprobe_server_handle(int socket);
|
||||
|
||||
/**
|
||||
* wprobe_server_done: release memory allocated for the server connection
|
||||
*/
|
||||
extern void wprobe_server_done(void);
|
||||
|
||||
#endif
|
||||