Initial commit
Some checks failed
Build Kernel / Build all affected Kernels (push) Has been cancelled
Build all core packages / Build all core packages for selected target (push) Has been cancelled
Build and Push prebuilt tools container / Build and Push all prebuilt containers (push) Has been cancelled
Build Toolchains / Build Toolchains for each target (push) Has been cancelled
Build host tools / Build host tools for linux and macos based systems (push) Has been cancelled
Coverity scan build / Coverity x86/64 build (push) Has been cancelled

This commit is contained in:
domenico
2025-06-24 14:35:53 +02:00
commit c06fb25d1f
9263 changed files with 1750214 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=adb-enablemodem
PKG_VERSION:=2017.03.05
PKG_RELEASE:=1
include $(INCLUDE_DIR)/package.mk
define Package/adb-enablemodem
SECTION:=net
CATEGORY:=Network
SUBMENU:=WWAN
TITLE:=Enable modem via adb
DEPENDS:=+adb
endef
define Build/Compile
true
endef
define Package/adb-enablemodem/install
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/adb-enablemodem $(1)/etc/init.d/adb-enablemodem
endef
$(eval $(call BuildPackage,adb-enablemodem))

View File

@@ -0,0 +1,64 @@
#!/bin/sh /etc/rc.common
START=99
adb_exec() {
adb -s "$serial" shell "( $1 ) >/dev/null 2>&1"'; printf "\nEXIT_CODE: %i\n" $?' | head -c 64 | grep -qx 'EXIT_CODE: 0\r\?'
}
enablemodem_do() {
logger -t adb-enablemodem 'INFO: waiting for device'
adb wait-for-device
serial="$(adb get-serialno)"
vendor_id="$(adb -s "$serial" shell 'uci get product.usb.vid' | head -c 16 | tr -d '\r\n')"
product_id="$(adb -s "$serial" shell 'uci get product.usb.pid' | head -c 16 | tr -d '\r\n')"
case "$vendor_id:$product_id" in
"0x2357:0x000D") # TP-LINK LTE MODULE
case "$1" in
start)
if adb_exec '
chmod +x /WEBSERVER/www/cgi-bin/*
fds="$(ls /proc/$$/fd | grep -v "^[012]$")"
for fd in $fds; do
eval "exec $fd>&-"
done
start-stop-daemon -x httpd -S -- -h /WEBSERVER/www/
'; then
logger -t adb-enablemodem 'INFO: httpd on modem started'
else
logger -t adb-enablemodem 'ERROR: failed to start httpd on modem'
fi
option_newid='/sys/bus/usb-serial/drivers/option1/new_id'
if [ -e "$option_newid" ]; then
printf '%s %s' "$vendor_id" "$product_id" > "$option_newid"
fi
;;
stop)
if adb_exec 'start-stop-daemon -x httpd -K'; then
logger -t adb-enablemodem 'INFO: httpd on modem stopped'
else
logger -t adb-enablemodem 'ERROR: failed to stop httpd on modem'
fi
;;
esac
;;
*)
logger -t adb-enablemodem "ERROR: unknown device $vendor_id:$product_id"
;;
esac
}
start() {
( enablemodem_do start ) &
}
stop() {
( enablemodem_do stop ) &
}
restart() {
( enablemodem_do stop; enablemodem_do start ) &
}

View File

@@ -0,0 +1,42 @@
# SPDX-License-Identifier: GPL-2.0-only
#
# Copyright (C) 2006-2016 OpenWrt.org
#
include $(TOPDIR)/rules.mk
PKG_NAME:=arptables
PKG_VERSION:=0.0.5
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://ftp.netfilter.org/pub/arptables
PKG_HASH:=4f9a0656ce5c90868f551cd4deeb2d04f33899667e1fb2818b64e432fe8f629c
PKG_LICENSE:=GPL-2.0
PKG_LICENSE_FILES:=COPYING
include $(INCLUDE_DIR)/package.mk
define Package/arptables-legacy
SECTION:=net
CATEGORY:=Network
SUBMENU:=Firewall
TITLE:=ARP firewalling software
DEPENDS:=+kmod-arptables
URL:=https://git.netfilter.org/arptables/
PROVIDES:=arptables
ALTERNATIVES:=\
200:/usr/sbin/arptables:/usr/sbin/arptables-legacy
endef
MAKE_FLAGS += \
COPT_FLAGS="$(TARGET_CFLAGS) -D__OPTIMIZE__=1" \
KERNEL_DIR="$(LINUX_DIR)"
define Package/arptables-legacy/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/arptables-legacy $(1)/usr/sbin/arptables-legacy
endef
$(eval $(call BuildPackage,arptables-legacy))

View File

@@ -0,0 +1,120 @@
#
# Copyright (C) 2020-2024 Tony Ambardar <itugrok@yahoo.com>
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=bpftool
PKG_VERSION:=7.4.0
PKG_RELEASE:=1
PKG_SOURCE_URL:=https://github.com/libbpf/bpftool
PKG_MIRROR_HASH:=18e22f72e67ff402b5ecaf314445f25c40bfe23299cb783b5834a496297c51ed
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=v7.4.0
PKG_MAINTAINER:=Tony Ambardar <itugrok@yahoo.com>
PKG_BUILD_FLAGS:=no-mips16 gc-sections lto
PKG_BUILD_PARALLEL:=1
PKG_INSTALL:=1
HOST_BUILD_PARALLEL:=1
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/nls.mk
include $(INCLUDE_DIR)/host-build.mk
define Package/bpftool/Default
SECTION:=net
CATEGORY:=Network
TITLE:=bpftool - eBPF subsystem utility
LICENSE:=GPL-2.0-only OR BSD-2-Clause
URL:=http://www.kernel.org
DEPENDS:=+libelf
endef
define Package/bpftool-minimal
$(call Package/bpftool/Default)
TITLE+= (Minimal)
VARIANT:=minimal
DEFAULT_VARIANT:=1
PROVIDES:=bpftool
ALTERNATIVES:=200:/usr/sbin/bpftool:/usr/libexec/bpftool-minimal
endef
define Package/bpftool-full
$(call Package/bpftool/Default)
TITLE+= (Full)
VARIANT:=full
PROVIDES:=bpftool
ALTERNATIVES:=300:/usr/sbin/bpftool:/usr/libexec/bpftool-full
DEPENDS+= +libbfd +libopcodes
endef
define Package/bpftool-minimal/description
A tool for inspection and simple manipulation of eBPF programs and maps.
endef
define Package/bpftool-full/description
A tool for inspection and simple manipulation of eBPF programs and maps.
This full version uses libbfd and libopcodes to support disassembly of
eBPF programs and jited code.
endef
ifeq ($(BUILD_VARIANT),full)
full:=1
else
full:=0
endif
MAKE_FLAGS += \
OUTPUT="$(PKG_BUILD_DIR)/" \
prefix="/usr" \
$(if $(findstring c,$(OPENWRT_VERBOSE)),V=1,V='') \
check_feat=0 \
feature-clang-bpf-co-re=0 \
feature-libbfd=$(full) \
feature-llvm=0 \
feature-libcap=0 \
feature-disassembler-four-args=1 \
feature-disassembler-init-styled=1
MAKE_PATH = src
define Package/bpftool-$(BUILD_VARIANT)/install
$(INSTALL_DIR) $(1)/usr/libexec
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/bpftool \
$(1)/usr/libexec/bpftool-$(BUILD_VARIANT)
endef
HOST_MAKE_FLAGS += \
OUTPUT="$(HOST_BUILD_DIR)/" \
prefix="/usr" \
$(if $(findstring c,$(OPENWRT_VERBOSE)),V=1,V='') \
check_feat=0 \
feature-clang-bpf-co-re=0 \
feature-libbfd=0 \
feature-llvm=0 \
feature-libcap=0 \
feature-disassembler-four-args=1 \
feature-disassembler-init-styled=1
HOST_MAKE_PATH = src
define Host/Install
$(INSTALL_DIR) $(STAGING_DIR_HOST)/usr/sbin
$(INSTALL_BIN) $(HOST_BUILD_DIR)/bpftool \
$(STAGING_DIR_HOST)/usr/sbin/bpftool
endef
define Host/Clean
rm -f $(STAGING_DIR_HOST)/usr/sbin/bpftool
endef
$(eval $(call BuildPackage,bpftool-full))
$(eval $(call BuildPackage,bpftool-minimal))
$(eval $(call HostBuild))

View File

@@ -0,0 +1,15 @@
--- a/src/Makefile
+++ b/src/Makefile
@@ -73,10 +73,10 @@ CFLAGS += -W -Wall -Wextra -Wno-unused-p
CFLAGS += $(filter-out -Wswitch-enum -Wnested-externs,$(EXTRA_WARNINGS))
CFLAGS += -DPACKAGE='"bpftool"' -D__EXPORTED_HEADERS__ \
-I$(or $(OUTPUT),.) \
- -I$(LIBBPF_INCLUDE) \
-I$(srctree)/src/kernel/bpf/ \
-I$(srctree)/include \
- -I$(srctree)/include/uapi
+ -I$(srctree)/include/uapi \
+ -I$(LIBBPF_INCLUDE)
ifneq ($(BPFTOOL_VERSION),)
CFLAGS += -DBPFTOOL_VERSION='"$(BPFTOOL_VERSION)"'
endif

View File

@@ -0,0 +1,106 @@
#
# Copyright (C) 2006-2014 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:=comgt
PKG_VERSION:=0.32
PKG_RELEASE:=36
PKG_SOURCE:=$(PKG_NAME).$(PKG_VERSION).tgz
PKG_SOURCE_URL:=@SF/comgt
PKG_HASH:=0cedb2a5aa608510da66a99aab74df3db363df495032e57e791a2ff55f1d7913
PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
PKG_LICENSE:=GPL-2.0+
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME).$(PKG_VERSION)
PKG_CHECK_FORMAT_SECURITY:=0
PKG_FLAGS:=nonshared
include $(INCLUDE_DIR)/package.mk
define Package/comgt/Default
SECTION:=net
CATEGORY:=Network
SUBMENU:=WWAN
endef
define Package/comgt
$(call Package/comgt/Default)
TITLE:=Option/Vodafone 3G/GPRS control tool
DEPENDS:=+chat
URL:=http://manpages.ubuntu.com/manpages/trusty/man1/comgt.1.html
endef
define Package/comgt-directip
$(call Package/comgt/Default)
TITLE:=Sierra Wireless Direct-IP support
DEPENDS:=+comgt +kmod-usb-serial +kmod-usb-serial-sierrawireless +kmod-usb-net +kmod-usb-net-sierrawireless
endef
define Package/comgt-ncm
$(call Package/comgt/Default)
TITLE+=NCM 3G/4G Support
DEPENDS:=+comgt +wwan +kmod-usb-serial-option +kmod-usb-net-huawei-cdc-ncm
endef
define Package/comgt/description
comgt is a scripting language interpreter useful for establishing
communications on serial lines and through PCMCIA modems as well as GPRS
and 3G datacards.
endef
define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR) \
$(TARGET_CONFIGURE_OPTS) \
CFLAGS="$(TARGET_CFLAGS)" \
LDFLAGS="" \
comgt
endef
define Package/comgt/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/comgt $(1)/usr/bin/
$(LN) comgt $(1)/usr/bin/gcom
$(INSTALL_DIR) $(1)/etc/chatscripts
$(INSTALL_DATA) ./files/3g.chat $(1)/etc/chatscripts/3g.chat
$(INSTALL_DATA) ./files/evdo.chat $(1)/etc/chatscripts/evdo.chat
$(INSTALL_DIR) $(1)/etc/gcom
$(INSTALL_DATA) ./files/setpin.gcom $(1)/etc/gcom/setpin.gcom
$(INSTALL_DATA) ./files/setmode.gcom $(1)/etc/gcom/setmode.gcom
$(INSTALL_DATA) ./files/getcardinfo.gcom $(1)/etc/gcom/getcardinfo.gcom
$(INSTALL_DATA) ./files/getstrength.gcom $(1)/etc/gcom/getstrength.gcom
$(INSTALL_DATA) ./files/getcarrier.gcom $(1)/etc/gcom/getcarrier.gcom
$(INSTALL_DATA) ./files/getcnum.gcom $(1)/etc/gcom/getcnum.gcom
$(INSTALL_DATA) ./files/getimsi.gcom $(1)/etc/gcom/getimsi.gcom
$(INSTALL_DATA) ./files/runcommand.gcom $(1)/etc/gcom/runcommand.gcom
$(INSTALL_DIR) $(1)/etc/hotplug.d/tty
$(INSTALL_CONF) ./files/3g.usb $(1)/etc/hotplug.d/tty/30-3g
$(INSTALL_DIR) $(1)/lib/netifd/proto
$(INSTALL_BIN) ./files/3g.sh $(1)/lib/netifd/proto/3g.sh
endef
define Package/comgt-directip/install
$(INSTALL_DIR) $(1)/etc/gcom
$(INSTALL_DATA) ./files/directip.gcom $(1)/etc/gcom/directip.gcom
$(INSTALL_DATA) ./files/directip-stop.gcom $(1)/etc/gcom/directip-stop.gcom
$(INSTALL_DIR) $(1)/lib/netifd/proto
$(INSTALL_BIN) ./files/directip.sh $(1)/lib/netifd/proto/directip.sh
endef
define Package/comgt-ncm/install
$(INSTALL_DIR) $(1)/etc/gcom
$(INSTALL_DATA) ./files/ncm.json $(1)/etc/gcom/ncm.json
$(INSTALL_DIR) $(1)/lib/netifd/proto
$(INSTALL_BIN) ./files/ncm.sh $(1)/lib/netifd/proto/ncm.sh
endef
$(eval $(call BuildPackage,comgt))
$(eval $(call BuildPackage,comgt-directip))
$(eval $(call BuildPackage,comgt-ncm))

View File

@@ -0,0 +1,12 @@
ABORT BUSY
ABORT 'NO CARRIER'
ABORT ERROR
REPORT CONNECT
TIMEOUT 10
"" "AT&F"
OK "ATE1"
OK 'AT+CGDCONT=1,"IP","$USE_APN"'
SAY "Calling UMTS/GPRS"
TIMEOUT 30
OK "ATD$DIALNUMBER"
CONNECT ' '

View File

@@ -0,0 +1,118 @@
#!/bin/sh
[ -n "$INCLUDE_ONLY" ] || {
NOT_INCLUDED=1
INCLUDE_ONLY=1
. ../netifd-proto.sh
. ./ppp.sh
init_proto "$@"
}
proto_3g_init_config() {
no_device=1
available=1
ppp_generic_init_config
proto_config_add_string "device:device"
proto_config_add_string "apn"
proto_config_add_string "service"
proto_config_add_string "pincode"
proto_config_add_string "delay"
proto_config_add_string "dialnumber"
}
proto_3g_setup() {
local interface="$1"
local chat
json_get_var device device
json_get_var apn apn
json_get_var service service
json_get_var pincode pincode
json_get_var dialnumber dialnumber
json_get_var delay delay
[ -n "$dat_device" ] && device=$dat_device
device="$(readlink -f $device)"
[ -e "$device" ] || {
proto_set_available "$interface" 0
return 1
}
[ -n "$delay" ] && sleep "$delay"
case "$service" in
cdma|evdo)
chat="/etc/chatscripts/evdo.chat"
;;
*)
chat="/etc/chatscripts/3g.chat"
cardinfo=$(gcom -d "$device" -s /etc/gcom/getcardinfo.gcom)
if echo "$cardinfo" | grep -q Novatel; then
case "$service" in
umts_only) CODE=2;;
gprs_only) CODE=1;;
*) CODE=0;;
esac
export MODE="AT\$NWRAT=${CODE},2"
elif echo "$cardinfo" | grep -q Option; then
case "$service" in
umts_only) CODE=1;;
gprs_only) CODE=0;;
*) CODE=3;;
esac
export MODE="AT_OPSYS=${CODE}"
elif echo "$cardinfo" | grep -q "Sierra Wireless"; then
SIERRA=1
elif echo "$cardinfo" | grep -qi huawei; then
case "$service" in
umts_only) CODE="14,2";;
gprs_only) CODE="13,1";;
*) CODE="2,2";;
esac
export MODE="AT^SYSCFG=${CODE},3FFFFFFF,2,4"
elif echo "$cardinfo" | grep -q "MikroTik"; then
COMMAND="AT+CFUN=1" gcom -d "$device" -s /etc/gcom/runcommand.gcom || return 1
fi
if [ -n "$pincode" ]; then
PINCODE="$pincode" gcom -d "$device" -s /etc/gcom/setpin.gcom || {
proto_notify_error "$interface" PIN_FAILED
proto_block_restart "$interface"
return 1
}
fi
[ -n "$MODE" ] && gcom -d "$device" -s /etc/gcom/setmode.gcom
# wait for carrier to avoid firmware stability bugs
[ -n "$SIERRA" ] && {
gcom -d "$device" -s /etc/gcom/getcarrier.gcom || return 1
}
if [ -z "$dialnumber" ]; then
dialnumber="*99***1#"
fi
;;
esac
connect="${apn:+USE_APN=$apn }DIALNUMBER=$dialnumber /usr/sbin/chat -t5 -v -E -f $chat"
ppp_generic_setup "$interface" \
noaccomp \
nopcomp \
novj \
nobsdcomp \
noauth \
set EXTENDPREFIX=1 \
lock \
crtscts \
115200 "$device"
return 0
}
proto_3g_teardown() {
proto_kill_command "$interface"
}
[ -z "$NOT_INCLUDED" ] || add_protocol 3g

View File

@@ -0,0 +1,35 @@
#!/bin/sh
. /lib/functions.sh
. /lib/netifd/netifd-proto.sh
find_3g_iface() {
local cfg="$1"
local tty="$2"
local proto
config_get proto "$cfg" proto
[ "$proto" = 3g ] || [ "$proto" = ncm ] || return 0
# bypass state vars here because 00-netstate could clobber .device
local dev=$(uci_get network "$cfg" device)
if [ "${dev##*/}" = "${tty##*/}" ]; then
if [ "$ACTION" = add ]; then
proto_set_available "$cfg" 1
fi
if [ "$ACTION" = remove ]; then
proto_set_available "$cfg" 0
fi
fi
}
[ "$ACTION" = add ] || [ "$ACTION" = remove ] || exit 0
case "$DEVICENAME" in
tty*)
[ -e "/dev/$DEVICENAME" ] || [ "$ACTION" = remove ] || exit 0
config_load network
config_foreach find_3g_iface interface "/dev/$DEVICENAME"
;;
esac

View File

@@ -0,0 +1,16 @@
opengt
set com 115200n81
set comecho off
set senddelay 0.05
waitquiet 1 0.2
:start
send "AT!SCACT=0,3^m"
waitfor 5 "OK"
if % = 0 goto hangupok
print "WWAN error. Hangup failed.\r\n"
exit 1
:hangupok
print "WWAN connection established.\r\n"
exit 0

View File

@@ -0,0 +1,55 @@
opengt
set com 115200n81
set comecho off
set senddelay 0.05
waitquiet 1 0.2
:start
if $env("USE_AUTH") = "0" goto connect
send "AT$QCPDPP=3,"
send $env("USE_AUTH")
send ",\""
if $env("USE_USER") <> "" send $env("USE_USER")
send "\",\""
if $env("USE_PASS") <> "" send $env("USE_PASS")
send "\"^m"
waitfor 5 "OK"
if % = 0 goto connect
print "WWAN error. Auth failed.\r\n"
exit 1
:connect
send "AT+CFUN=1^m"
send "AT+CGDCONT=3,\"IP\",\""
send $env("USE_APN")
send "\"^m"
waitfor 5 "OK"
if % = 0 goto connok
print "WWAN error. Connection failed.\r\n"
exit 1
:connok
let c=1
:loop
sleep 2
send "AT+CGATT?^m"
waitfor 5 "+CGATT: 1"
if % = 0 goto carrierok
if c > 10 goto carriererr
inc c
goto loop
:carriererr
print "WWAN error. No carrier.\r\n"
exit 1
:carrierok
send "AT!SCACT=1,3^m"
waitfor 5 "OK"
if % = 0 goto dialok
print "WWAN error. Dialing failed.\r\n"
exit 1
:dialok
print "WWAN connection established.\r\n"
exit 0

View File

@@ -0,0 +1,118 @@
#!/bin/sh
[ -n "$INCLUDE_ONLY" ] || {
. /lib/functions.sh
. ../netifd-proto.sh
init_proto "$@"
}
proto_directip_init_config() {
available=1
no_device=1
proto_config_add_string "device:device"
proto_config_add_string "apn"
proto_config_add_string "pincode"
proto_config_add_string "auth"
proto_config_add_string "username"
proto_config_add_string "password"
proto_config_add_boolean sourcefilter
proto_config_add_boolean delegate
proto_config_add_defaults
}
proto_directip_setup() {
local interface="$1"
local chat devpath devname
local device apn pincode ifname auth username password sourcefilter delegate $PROTO_DEFAULT_OPTIONS
json_get_vars device apn pincode auth username password sourcefilter delegate $PROTO_DEFAULT_OPTIONS
[ -n "$ctl_device" ] && device=$ctl_device
device="$(readlink -f $device)"
[ -e "$device" ] || {
proto_notify_error "$interface" NO_DEVICE
proto_set_available "$interface" 0
return 1
}
devname="$(basename "$device")"
devpath="$(readlink -f /sys/class/tty/$devname/device)"
ifname="$( ls "$devpath"/../../*/net )"
[ -n "$ifname" ] || {
proto_notify_error "$interface" NO_IFNAME
proto_set_available "$interface" 0
return 1
}
gcom -d "$device" -s /etc/gcom/getcardinfo.gcom | grep -q "Sierra Wireless" || {
proto_notify_error "$interface" BAD_DEVICE
proto_block_restart "$interface"
return 1
}
if [ -n "$pincode" ]; then
PINCODE="$pincode" gcom -d "$device" -s /etc/gcom/setpin.gcom || {
proto_notify_error "$interface" PIN_FAILED
proto_block_restart "$interface"
return 1
}
fi
# wait for carrier to avoid firmware stability bugs
gcom -d "$device" -s /etc/gcom/getcarrier.gcom || return 1
local auth_type=0
case $auth in
pap) auth_type=1;;
chap) auth_type=2;;
esac
USE_APN="$apn" USE_USER="$username" USE_PASS="$password" USE_AUTH="$auth_type" \
gcom -d "$device" -s /etc/gcom/directip.gcom || {
proto_notify_error "$interface" CONNECT_FAILED
proto_block_restart "$interface"
return 1
}
logger -p daemon.info -t "directip[$$]" "Connected, starting DHCP"
proto_init_update "$ifname" 1
proto_send_update "$interface"
json_init
json_add_string name "${interface}_4"
json_add_string ifname "@$interface"
json_add_string proto "dhcp"
proto_add_dynamic_defaults
ubus call network add_dynamic "$(json_dump)"
json_init
json_add_string name "${interface}_6"
json_add_string ifname "@$interface"
json_add_string proto "dhcpv6"
json_add_string extendprefix 1
[ "$delegate" = "0" ] && json_add_boolean delegate "0"
[ "$sourcefilter" = "0" ] && json_add_boolean sourcefilter "0"
proto_add_dynamic_defaults
ubus call network add_dynamic "$(json_dump)"
return 0
}
proto_directip_teardown() {
local interface="$1"
local device
json_get_vars device
[ -n "$ctl_device" ] && device=$ctl_device
gcom -d "$device" -s /etc/gcom/directip-stop.gcom || proto_notify_error "$interface" CONNECT_FAILED
proto_init_update "*" 0
proto_send_update "$interface"
}
[ -n "$INCLUDE_ONLY" ] || {
add_protocol directip
}

View File

@@ -0,0 +1,17 @@
# This is a simple chat script based off of the one provided by Sierra Wireless
# for CDMA connections. It should work for both Sprint and Verizon networks.
ABORT BUSY
ABORT 'NO CARRIER'
ABORT ERROR
ABORT 'NO DIAL TONE'
ABORT 'NO ANSWER'
ABORT DELAYED
REPORT CONNECT
TIMEOUT 10
'' AT
OK ATZ
SAY 'Calling CDMA/EVDO'
TIMEOUT 30
OK ATDT#777
CONNECT ''

View File

@@ -0,0 +1,14 @@
opengt
set com 115200n81
set comecho off
set senddelay 0.02
waitquiet 0.2 0.2
flash 0.1
:start
send "AT+CGMI^m"
get 1 "" $s
print $s
:continue
exit 0

View File

@@ -0,0 +1,20 @@
opengt
set senddelay 0.05
waitquiet 1 0.2
let c=1
:loop
inc c
send "AT+CGATT?^m"
waitfor 5 "+CGATT: 1","+CGATT: 0"
print "\n."
if % = -1 goto error
if c > 10 goto toolong
if % = 0 goto out
sleep 2
if % = 1 goto loop
:toolong
exit 1
:error
exit 0
:out
exit 0

View File

@@ -0,0 +1,20 @@
opengt
set com 115200n81
set comecho off
set senddelay 0.02
waitquiet 0.2 0.2
flash 0.1
:start
send "AT+CNUM^m"
get 1 "^m" $n
get 1 ":" $n
get 1 "\"" $n
get 1 "\"" $n
get 1 "\"" $n
get 1 "\"" $n
let n = len($n)
if n<1 goto continue
print $n
:continue
exit 0

View File

@@ -0,0 +1,17 @@
opengt
set com 115200n81
set comecho off
set senddelay 0.02
waitquiet 0.2 0.2
flash 0.1
:start
send "AT+CIMI^m"
get 1 "^m" $s
get 1 "^m" $s
let x = len($s)
if x<2 goto continue
let $s = $right($s, x-1)
print $s
:continue
exit 0

View File

@@ -0,0 +1,14 @@
opengt
set com 115200n81
set comecho off
set senddelay 0.02
waitquiet 0.2 0.2
flash 0.1
:start
send "AT+CSQ^m"
get 1 "" $s
print $s
:continue
exit 0

View File

@@ -0,0 +1,140 @@
{
"huawei": {
"initialize": [
"AT",
"ATZ",
"ATQ0",
"ATV1",
"ATE1",
"ATS0=0",
"AT+CGDCONT=${profile},\\\"${pdptype}\\\"${apn:+,\\\"$apn\\\"}"
],
"modes": {
"preferlte": "AT^SYSCFGEX=\\\"030201\\\",3fffffff,2,4,7fffffffffffffff,,",
"preferumts": "AT^SYSCFGEX=\\\"0201\\\",3fffffff,2,4,7fffffffffffffff,,",
"lte": "AT^SYSCFGEX=\\\"03\\\",3fffffff,2,4,7fffffffffffffff,,",
"umts": "AT^SYSCFGEX=\\\"02\\\",3fffffff,2,4,7fffffffffffffff,,",
"gsm": "AT^SYSCFGEX=\\\"01\\\",3fffffff,2,4,7fffffffffffffff,,",
"auto": "AT^SYSCFGEX=\\\"00\\\",3fffffff,2,4,7fffffffffffffff,,"
},
"connect": "AT^NDISDUP=${profile},1${apn:+,\\\"$apn\\\"}${username:+,\\\"$username\\\"}${password:+,\\\"$password\\\"}${auth:+,$auth}",
"disconnect": "AT^NDISDUP=${profile},0"
},
"samsung": {
"initialize": [
"AT",
"AT+CGREG=2",
"AT+CFUN=5",
"AT+MODESELECT=3",
"AT+CGDCONT=${profile},\\\"${pdptype}\\\"${apn:+,\\\"$apn\\\"}"
],
"modes": {
"umts": "AT+CHANGEALLPATH=1"
},
"connect": "AT+CGATT=1",
"disconnect": "AT+CGATT=0"
},
"sierra": {
"initialize": [
"AT+CFUN=1",
"AT+CGDCONT=${profile},\\\"${pdptype}\\\"${apn:+,\\\"$apn\\\"}",
"AT$QCPDPP=${profile},${auth:-0}${password:+,\\\"$password\\\"}${username:+,\\\"$username\\\"}"
],
"modes": {
"preferlte": "AT!SELRAT=07",
"preferumts": "AT!SELRAT=05",
"lte": "AT!SELRAT=06",
"umts": "AT!SELRAT=01",
"gsm": "AT!SELRAT=02",
"auto": "AT!SELRAT=00"
},
"connect": "AT!SCACT=1,${profile}",
"disconnect": "AT!SCACT=0,${profile}"
},
"sony": {
"initialize": [
"AT+CFUN=1",
"AT+CGDCONT=${profile},\\\"${pdptype}\\\"${apn:+,\\\"$apn\\\"}",
"AT*EIAAUW=${profile},1,\\\"${username}\\\",\\\"${password}\\\",${auth:-00111}"
],
"modes": {
"umts": "AT+CFUN=6",
"gsm": "AT+CFUN=5"
},
"connect": "AT*ENAP=1,${profile}",
"disconnect": "AT*ENAP=0"
},
"mtk1": {
"initialize": [
"AT+CFUN=1"
],
"configure": [
"AT+CGDCONT=${profile},\\\"${pdptype}\\\",\\\"${apn}\\\",0,0"
],
"connect": "AT+CGACT=1,${profile}",
"finalize": "AT+CGDATA=\\\"M-MBIM\\\",${profile},1",
"disconnect": "AT+CGACT=0,${profile}"
},
"quectel": {
"initialize": [
"AT+CFUN=1"
],
"configure": [
"at+qicsgp=${profile},${context_type},\\\"${apn}\\\",\\\"${username}\\\",\\\"${password}\\\",0"
],
"modes": {
"lte": "AT+QCFG=\\\"nwscanmode\\\",3",
"umts": "AT+QCFG=\\\"nwscanmode\\\",2",
"gsm": "AT+QCFG=\\\"nwscanmode\\\",1",
"auto": "AT+QCFG=\\\"nwscanmode\\\",0"
},
"connect": "AT+qnetdevctl=1,${profile},1",
"disconnect": "AT+qnetdevctl=0,${profile},0"
},
"\"zte": {
"initialize": [
"AT+CFUN=1"
],
"configure": [
"AT+ZGDCONT=${profile},\\\"${pdptype}\\\",\\\"${apn}\\\",\\\"\\\",0,0",
"AT+ZGPCOAUTH=${profile},\\\"${username}\\\",\\\"${password}\\\",0"
],
"connect": "AT+ZGACT=1,${profile}",
"disconnect": "AT+ZGACT=0,${profile}"
},
"\"marvell\"": {
"initialize": [
"AT+CFUN=1"
],
"configure": [
"AT+ZGDCONT=${profile},\\\"${pdptype}\\\",\\\"${apn}\\\",\\\"\\\",0,0",
"AT+ZGPCOAUTH=${profile},\\\"${username}\\\",\\\"${password}\\\",0"
],
"connect": "AT+ZGACT=1,${profile}",
"disconnect": "AT+ZGACT=0,${profile}"
},
"\"mikrotik\"": {
"configure": [
"AT+CFUN=4",
"AT+ZGDCONT=${profile},\\\"${pdptype}\\\",\\\"${apn}\\\",0",
"AT+ZDHCPLEASE=10",
"AT+CFUN=1"
],
"waitforconnect": "\\\"+ZCONSTAT: 1,${context_type}\\\",\\\"+ZGIPDNS: ${context_type}\\\"",
"connect": "AT+ZGACT=1,${context_type}",
"finalize": "AT+ZDHCPLEASE=0",
"disconnect": "AT+ZGACT=0,1"
},
"spreadtrum": {
"initialize": [
"AT+CFUN=1",
"AT+CCED=2,8",
"AT+SPTTYROUTER=1"
],
"configure": [
"AT+CGDCONT=${profile},\\\"${pdptype}\\\"${apn:+,\\\"$apn\\\"}"
],
"connect": "AT+SPTZCMD=\\\"Y29ubm1hbmN0bCBuZGlzZGlhbCBBVF5ORElTRFVOPSJ1c2IwIiwxLDE=\\\"",
"disconnect": "AT+SPTZCMD=\\\"Y29ubm1hbmN0bCBuZGlzZGlhbCBBVF5ORElTRFVOPSJ1c2IwIiwwLDE=\\\""
}
}

View File

@@ -0,0 +1,290 @@
#!/bin/sh
[ -n "$INCLUDE_ONLY" ] || {
. /lib/functions.sh
. ../netifd-proto.sh
init_proto "$@"
}
proto_ncm_init_config() {
no_device=1
available=1
proto_config_add_string "device:device"
proto_config_add_string ifname
proto_config_add_string apn
proto_config_add_string auth
proto_config_add_string username
proto_config_add_string password
proto_config_add_string pincode
proto_config_add_string delay
proto_config_add_string mode
proto_config_add_string pdptype
proto_config_add_boolean sourcefilter
proto_config_add_boolean delegate
proto_config_add_int profile
proto_config_add_defaults
}
proto_ncm_setup() {
local interface="$1"
local connect context_type devname devpath finalize ifpath initialize manufacturer setmode
local delegate sourcefilter $PROTO_DEFAULT_OPTIONS
json_get_vars delegate sourcefilter $PROTO_DEFAULT_OPTIONS
local apn auth delay device ifname mode password pdptype pincode profile username
json_get_vars apn auth delay device ifname mode password pdptype pincode profile username
[ "$metric" = "" ] && metric="0"
[ -n "$profile" ] || profile=1
pdptype=$(echo "$pdptype" | awk '{print toupper($0)}')
[ "$pdptype" = "IP" -o "$pdptype" = "IPV6" -o "$pdptype" = "IPV4V6" ] || pdptype="IP"
[ "$pdptype" = "IPV4V6" ] && context_type=3
[ -z "$context_type" -a "$pdptype" = "IPV6" ] && context_type=2
[ -n "$context_type" ] || context_type=1
[ -n "$ctl_device" ] && device=$ctl_device
[ -n "$device" ] || {
echo "No control device specified"
proto_notify_error "$interface" NO_DEVICE
proto_set_available "$interface" 0
return 1
}
device="$(readlink -f $device)"
[ -e "$device" ] || {
echo "Control device not valid"
proto_set_available "$interface" 0
return 1
}
[ -z "$ifname" ] && {
devname="$(basename "$device")"
case "$devname" in
'ttyACM'*)
devpath="$(readlink -f /sys/class/tty/$devname/device)"
ifpath="$devpath/../*/net"
;;
'tty'*)
devpath="$(readlink -f /sys/class/tty/$devname/device)"
ifpath="$devpath/../../*/net"
;;
*)
devpath="$(readlink -f /sys/class/usbmisc/$devname/device/)"
ifpath="$devpath/net"
;;
esac
ifname="$(ls $(ls -1 -d $ifpath | head -n 1))"
}
[ -n "$ifname" ] || {
echo "The interface could not be found."
proto_notify_error "$interface" NO_IFACE
proto_set_available "$interface" 0
return 1
}
start=$(date +%s)
while true; do
manufacturer=$(gcom -d "$device" -s /etc/gcom/getcardinfo.gcom | awk 'NF && $0 !~ /AT\+CGMI/ { sub(/\+CGMI: /,""); print tolower($1); exit; }')
[ "$manufacturer" = "error" ] && {
manufacturer=""
}
[ -n "$manufacturer" ] && {
break
}
[ -z "$delay" ] && {
break
}
sleep 1
elapsed=$(($(date +%s) - start))
[ "$elapsed" -gt "$delay" ] && {
break
}
done
[ -z "$manufacturer" ] && {
echo "Failed to get modem information"
proto_notify_error "$interface" GETINFO_FAILED
return 1
}
json_load "$(cat /etc/gcom/ncm.json)"
json_select "$manufacturer"
[ $? -ne 0 ] && {
echo "Unsupported modem"
proto_notify_error "$interface" UNSUPPORTED_MODEM
proto_set_available "$interface" 0
return 1
}
json_get_values initialize initialize
for i in $initialize; do
eval COMMAND="$i" gcom -d "$device" -s /etc/gcom/runcommand.gcom || {
echo "Failed to initialize modem"
proto_notify_error "$interface" INITIALIZE_FAILED
return 1
}
done
[ -n "$pincode" ] && {
PINCODE="$pincode" gcom -d "$device" -s /etc/gcom/setpin.gcom || {
echo "Unable to verify PIN"
proto_notify_error "$interface" PIN_FAILED
proto_block_restart "$interface"
return 1
}
}
json_get_values configure configure
echo "Configuring modem"
for i in $configure; do
eval COMMAND="$i" gcom -d "$device" -s /etc/gcom/runcommand.gcom || {
echo "Failed to configure modem"
proto_notify_error "$interface" CONFIGURE_FAILED
return 1
}
done
[ -n "$mode" ] && {
json_select modes
json_get_var setmode "$mode"
[ -n "$setmode" ] && {
echo "Setting mode"
eval COMMAND="$setmode" gcom -d "$device" -s /etc/gcom/runcommand.gcom || {
echo "Failed to set operating mode"
proto_notify_error "$interface" SETMODE_FAILED
return 1
}
}
json_select ..
}
echo "Starting network $interface"
json_get_vars connect
[ -n "$connect" ] && {
echo "Connecting modem"
eval COMMAND="$connect" gcom -d "$device" -s /etc/gcom/runcommand.gcom || {
echo "Failed to connect"
proto_notify_error "$interface" CONNECT_FAILED
return 1
}
}
json_get_vars finalize
echo "Setting up $ifname"
proto_init_update "$ifname" 1
proto_add_data
json_add_string "manufacturer" "$manufacturer"
proto_close_data
proto_send_update "$interface"
local zone="$(fw3 -q network "$interface" 2>/dev/null)"
[ "$pdptype" = "IP" -o "$pdptype" = "IPV4V6" ] && {
json_init
json_add_string name "${interface}_4"
json_add_string ifname "@$interface"
json_add_string proto "dhcp"
proto_add_dynamic_defaults
[ -n "$zone" ] && {
json_add_string zone "$zone"
}
json_close_object
ubus call network add_dynamic "$(json_dump)"
}
[ "$pdptype" = "IPV6" -o "$pdptype" = "IPV4V6" ] && {
json_init
json_add_string name "${interface}_6"
json_add_string ifname "@$interface"
json_add_string proto "dhcpv6"
json_add_string extendprefix 1
[ "$delegate" = "0" ] && json_add_boolean delegate "0"
[ "$sourcefilter" = "0" ] && json_add_boolean sourcefilter "0"
proto_add_dynamic_defaults
[ -n "$zone" ] && {
json_add_string zone "$zone"
}
json_close_object
ubus call network add_dynamic "$(json_dump)"
}
[ -n "$finalize" ] && {
eval COMMAND="$finalize" gcom -d "$device" -s /etc/gcom/runcommand.gcom || {
echo "Failed to configure modem"
proto_notify_error "$interface" FINALIZE_FAILED
return 1
}
}
}
proto_ncm_teardown() {
local interface="$1"
local manufacturer disconnect
local device profile
json_get_vars device profile
[ -n "$ctl_device" ] && device=$ctl_device
[ -n "$device" ] || {
echo "No control device specified"
proto_notify_error "$interface" NO_DEVICE
proto_set_available "$interface" 0
return 1
}
device="$(readlink -f $device)"
[ -e "$device" ] || {
echo "Control device not valid"
proto_set_available "$interface" 0
return 1
}
[ -n "$profile" ] || profile=1
echo "Stopping network $interface"
json_load "$(ubus call network.interface.$interface status)"
json_select data
json_get_vars manufacturer
[ $? -ne 0 -o -z "$manufacturer" ] && {
# Fallback to direct detect, for proper handle device replug.
manufacturer=$(gcom -d "$device" -s /etc/gcom/getcardinfo.gcom | awk 'NF && $0 !~ /AT\+CGMI/ { sub(/\+CGMI: /,""); print tolower($1); exit; }')
[ $? -ne 0 -o -z "$manufacturer" ] && {
echo "Failed to get modem information"
proto_notify_error "$interface" GETINFO_FAILED
return 1
}
json_add_string "manufacturer" "$manufacturer"
}
json_load "$(cat /etc/gcom/ncm.json)"
json_select "$manufacturer" || {
echo "Unsupported modem"
proto_notify_error "$interface" UNSUPPORTED_MODEM
return 1
}
json_get_vars disconnect
[ -n "$disconnect" ] && {
eval COMMAND="$disconnect" gcom -d "$device" -s /etc/gcom/runcommand.gcom || {
echo "Failed to disconnect"
proto_notify_error "$interface" DISCONNECT_FAILED
return 1
}
}
proto_init_update "*" 0
proto_send_update "$interface"
}
[ -n "$INCLUDE_ONLY" ] || {
add_protocol ncm
}

View File

@@ -0,0 +1,31 @@
# run AT-command from environment
opengt
set com 115200n81
set senddelay 0.02
waitquiet 1 0.2
flash 0.1
:start
print "sending -> ",$env("COMMAND"),"\n"
send $env("COMMAND")
send "^m"
waitfor 25 "OK","ERR","ERROR","COMMAND NOT SUPPORT"
if % = 0 goto continue
if % = 1 goto error
if % = 2 goto error
if % = 3 goto notsupported
print "Timeout running AT-command\n"
exit 1
:error
print "Error running AT-command\n"
exit 1
:notsupported
print "AT-command not supported\n"
exit 1
:continue
exit 0

View File

@@ -0,0 +1,26 @@
# set wwan mode from environment
opengt
set com 115200n81
set senddelay 0.02
waitquiet 1 0.2
flash 0.1
:start
print "Trying to set mode\n"
send $env("MODE")
send "^m"
waitfor 15 "OK","ERR","ERROR"
if % = 0 goto continue
if % = 1 goto modeerror
if % = 2 goto modeerror
print "Timeout setting WWAN mode!\n"
exit 1
:modeerror
print "Error setting WWAN mode!\n"
exit 1
:continue
exit 0

View File

@@ -0,0 +1,56 @@
# set pin code from evnironment "$PINCODE"
opengt
set com 115200n81
set senddelay 0.05
waitquiet 3 0.5
flash 0.1
let c=0
:start
send "AT+CFUN=1^m"
send "AT+CPIN?^m"
waitfor 15 "SIM PUK","SIM PIN","READY","ERROR","ERR"
if % = -1 goto timeout
if % = 0 goto ready
if % = 1 goto setpin
if % = 2 goto ready
if % = 3 goto checkrepeat
if % = 4 goto checkrepeat
:checkrepeat
inc c
if c>3 goto pinerror
waitquiet 12 0.5
goto start
:timeout
print "timeout checking for PIN."
exit 1
:ready
print "SIM ready\n"
goto continue
exit 0
:setpin
# check if output was "SIM PIN2", that's ok.
waitfor 1 "2"
if % = 0 goto ready
print "Trying to set PIN\n"
send "AT+CPIN=\""
send $env("PINCODE")
send "\"^m"
waitfor 20 "OK","ERR"
if % = -1 goto pinerror
if % = 0 goto continue
if % = 1 goto pinerror
:pinerror
print "Error setting PIN, check card manually\n"
exit 1
:continue
print "PIN set successfully\n"
exit 0

View File

@@ -0,0 +1,21 @@
opengt
set com 115200n81
set comecho off
set senddelay 0.02
waitquiet 0.2 0.2
flash 0.1
:start
send "AT+CUSD=1,"
send $env("ussd")
send ",15"
send "^m"
waitfor 120 "+CUSD:"
if % = -1 goto timeout
get 1 "^m" $s
print $s
exit 0
:timeout
print "ERROR: no USSD response, timeout.\n"
exit 1

View File

@@ -0,0 +1,23 @@
--- a/Makefile
+++ b/Makefile
@@ -32,6 +32,7 @@ SCRIPTPATH = /etc/comgt/
SCRIPTSRC = ./scripts/
BIN = $(CPROG)
MANP = comgt.1 sigmon.1
+CC = cc
CFLAGS = -c
LDFLAGS =
@@ -70,10 +71,5 @@ clean:
-rm *~
-rm $(SCRIPTSRC)*~
-
-comgt: comgt.o
- cc comgt.o $(LDFLAGS) -o comgt
-
-comgt.o: comgt.c comgt.h
- cc comgt.c $(CFLAGS)
-
+comgt: comgt.c comgt.h
+ $(CC) $(CFLAGS) -o comgt $< $(LDFLAGS)

View File

@@ -0,0 +1,105 @@
--- a/comgt.c
+++ b/comgt.c
@@ -30,7 +30,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
-#include <termio.h>
+#include <termios.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
@@ -81,7 +81,7 @@ char token[MAXTOKEN]; /* For gettoken(
char scriptfile[MAXPATH]; /* Script file name */
char scriptfilepath[MAXPATH]; /* temp storage for full path */
BOOL verbose=0; /* Log actions */
-struct termio cons, stbuf, svbuf; /* termios: svbuf=before, stbuf=while */
+struct termios cons, stbuf, svbuf; /* termios: svbuf=before, stbuf=while */
int comfd=0; /* Communication file descriptor. Defaults to stdin. */
char msg[STRINGL]; /* Massage messages here */
int preturn,returns[MAXGOSUBS];
@@ -172,7 +172,7 @@ void dotestkey(void) {
/* Exit after resetting terminal settings */
void ext(long xtc) {
- ioctl(1, TCSETA, &cons);
+ ioctl(1, TCSETS, &cons);
exit(xtc);
}
@@ -920,24 +920,24 @@ BOOL getonoroff(void) {
void setcom(void) {
stbuf.c_cflag &= ~(CBAUD | CSIZE | CSTOPB | CLOCAL | PARENB);
stbuf.c_cflag |= (speed | bits | CREAD | clocal | parity | stopbits );
- if (ioctl(comfd, TCSETA, &stbuf) < 0) {
+ if (ioctl(comfd, TCSETS, &stbuf) < 0) {
serror("Can't ioctl set device",1);
}
}
void doset(void) {
- struct termio console;
+ struct termios console;
int a,b;
gettoken();
if(strcmp(token,"echo")==0) {
a=0;
if(getonoroff()) a=ECHO|ECHOE;
- if(ioctl(0, TCGETA, &console)<0) {
+ if(ioctl(0, TCGETS, &console)<0) {
serror("Can't ioctl FD zero!\n",2);
}
console.c_lflag &= ~(ECHO | ECHOE);
console.c_lflag |= a;
- ioctl(0, TCSETA, &console);
+ ioctl(0, TCSETS, &console);
}
else if(strcmp(token,"senddelay")==0) {
senddelay=10000L*getdvalue();
@@ -1224,7 +1224,7 @@ void doclose(void) {
if(strcmp(token,"hardcom")==0) {
if(comfd== -1) serror("Com device not open",1);
vmsg("Closing device");
- if (ioctl(comfd, TCSETA, &svbuf) < 0) {
+ if (ioctl(comfd, TCSETS, &svbuf) < 0) {
sprintf(msg,"Can't ioctl set device %s.\n",device);
serror(msg,1);
}
@@ -1266,12 +1266,12 @@ void opengt(void) {
ext(1);
}
}
- if (ioctl (comfd, TCGETA, &svbuf) < 0) {
+ if (ioctl (comfd, TCGETS, &svbuf) < 0) {
sprintf(msg,"Can't control %s, please try again.\n",device);
serror(msg,1);
}
setenv("COMGTDEVICE",device,1);
- ioctl(comfd, TCGETA, &stbuf);
+ ioctl(comfd, TCGETS, &stbuf);
speed=stbuf.c_cflag & CBAUD;
if (high_speed == 0) strcpy(cspeed,"115200");
else strcpy(cspeed,"57600");
@@ -1303,11 +1303,11 @@ void opendevice(void) {
}
else comfd=0;
- if (ioctl (comfd, TCGETA, &svbuf) < 0) {
+ if (ioctl (comfd, TCGETS, &svbuf) < 0) {
sprintf(msg,"Can't ioctl get device %s.\n",device);
serror(msg,1);
}
- ioctl(comfd, TCGETA, &stbuf);
+ ioctl(comfd, TCGETS, &stbuf);
speed=stbuf.c_cflag & CBAUD;
switch(speed) {
case B0: strcpy(cspeed,"0");break;
@@ -1553,7 +1553,7 @@ int main(int argc,char **argv) {
skip_default=0;
filep=NULL;
scriptspace=4096;
- ioctl(1, TCGETA, &cons);
+ ioctl(1, TCGETS, &cons);
if((script=( char *)malloc(scriptspace))==NULL) {
serror("Could not malloc()",3);
}

View File

@@ -0,0 +1,20 @@
--- a/comgt.c
+++ b/comgt.c
@@ -1281,7 +1281,7 @@ void opengt(void) {
parity=stbuf.c_cflag & (PARENB | PARODD);
stbuf.c_iflag &= ~(IGNCR | ICRNL | IUCLC | INPCK | IXON | IXANY | IGNPAR );
stbuf.c_oflag &= ~(OPOST | OLCUC | OCRNL | ONLCR | ONLRET);
- stbuf.c_lflag &= ~(ICANON | XCASE | ECHO | ECHOE | ECHONL);
+ stbuf.c_lflag &= ~(ICANON | ECHO | ECHOE | ECHONL);
stbuf.c_lflag &= ~(ECHO | ECHOE);
stbuf.c_cc[VMIN] = 1;
stbuf.c_cc[VTIME] = 0;
@@ -1336,7 +1336,7 @@ void opendevice(void) {
parity=stbuf.c_cflag & (PARENB | PARODD);
stbuf.c_iflag &= ~(IGNCR | ICRNL | IUCLC | INPCK | IXON | IXANY | IGNPAR );
stbuf.c_oflag &= ~(OPOST | OLCUC | OCRNL | ONLCR | ONLRET);
- stbuf.c_lflag &= ~(ICANON | XCASE | ECHO | ECHOE | ECHONL);
+ stbuf.c_lflag &= ~(ICANON | ECHO | ECHOE | ECHONL);
stbuf.c_lflag &= ~(ECHO | ECHOE);
stbuf.c_cc[VMIN] = 1;
stbuf.c_cc[VTIME] = 0;

View File

@@ -0,0 +1,68 @@
--- a/comgt.c
+++ b/comgt.c
@@ -91,6 +91,7 @@ unsigned long hstart,hset;
char NullString[]={ "" };
BOOL lastcharnl=1; /* Indicate that last char printed from getonebyte
was a nl, so no new one is needed */
+BOOL tty=1;
//"open com \"/dev/modem\"\nset com 38400n81\nset senddelay 0.05\nsend \"ATi^m\"\nget 2 \" ^m\" $s\nprint \"Response : \",$s,\"\\n\"\nget 2 \" ^m\" $s\nprint \"Response :\",$s,\"\\n\"\nget 2 \" ^m\" $s\nprint \"Response : \",$s,\"\\n\"\n\n";
@@ -920,7 +921,7 @@ BOOL getonoroff(void) {
void setcom(void) {
stbuf.c_cflag &= ~(CBAUD | CSIZE | CSTOPB | CLOCAL | PARENB);
stbuf.c_cflag |= (speed | bits | CREAD | clocal | parity | stopbits );
- if (ioctl(comfd, TCSETS, &stbuf) < 0) {
+ if (tty && ioctl(comfd, TCSETS, &stbuf) < 0) {
serror("Can't ioctl set device",1);
}
}
@@ -1224,7 +1225,7 @@ void doclose(void) {
if(strcmp(token,"hardcom")==0) {
if(comfd== -1) serror("Com device not open",1);
vmsg("Closing device");
- if (ioctl(comfd, TCSETS, &svbuf) < 0) {
+ if (tty && ioctl(comfd, TCSETS, &svbuf) < 0) {
sprintf(msg,"Can't ioctl set device %s.\n",device);
serror(msg,1);
}
@@ -1266,12 +1267,17 @@ void opengt(void) {
ext(1);
}
}
- if (ioctl (comfd, TCGETS, &svbuf) < 0) {
+ if (isatty (comfd))
+ tty=1;
+ else
+ tty=0;
+ if (tty && ioctl (comfd, TCGETS, &svbuf) < 0) {
sprintf(msg,"Can't control %s, please try again.\n",device);
serror(msg,1);
}
setenv("COMGTDEVICE",device,1);
- ioctl(comfd, TCGETS, &stbuf);
+ if (tty)
+ ioctl(comfd, TCGETS, &stbuf);
speed=stbuf.c_cflag & CBAUD;
if (high_speed == 0) strcpy(cspeed,"115200");
else strcpy(cspeed,"57600");
@@ -1302,12 +1308,16 @@ void opendevice(void) {
}
}
else comfd=0;
-
- if (ioctl (comfd, TCGETS, &svbuf) < 0) {
+ if (isatty (comfd))
+ tty=1;
+ else
+ tty=0;
+ if (tty && ioctl (comfd, TCGETS, &svbuf) < 0) {
sprintf(msg,"Can't ioctl get device %s.\n",device);
serror(msg,1);
}
- ioctl(comfd, TCGETS, &stbuf);
+ if (tty)
+ ioctl(comfd, TCGETS, &stbuf);
speed=stbuf.c_cflag & CBAUD;
switch(speed) {
case B0: strcpy(cspeed,"0");break;

View File

@@ -0,0 +1,80 @@
#
# Copyright (C) 2006-2015 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:=ebtables
PKG_SOURCE_DATE:=2018-06-27
PKG_RELEASE:=2
PKG_SOURCE_URL:=https://git.netfilter.org/ebtables
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=48cff25dfea5b37e16ba5dc6601e98ab140f5f99
PKG_MIRROR_HASH:=1ee560498e1a047b329eab3dad8425ae51e7f0527e4495efb99481ca11206b37
PKG_LICENSE:=GPL-2.0
PKG_CPE_ID:=cpe:/a:netfilter:ebtables
include $(INCLUDE_DIR)/package.mk
define Package/ebtables-legacy
SECTION:=net
CATEGORY:=Network
SUBMENU:=Firewall
DEPENDS:=+kmod-ebtables
TITLE:=Ethernet bridge firewall administration utility
URL:=http://ebtables.sourceforge.net/
PROVIDES:=ebtables
ALTERNATIVES:=\
200:/usr/sbin/ebtables:/usr/sbin/ebtables-legacy
endef
define Package/ebtables-legacy-utils
$(call Package/ebtables-legacy)
DEPENDS:=ebtables-legacy
TITLE:=ebtables save/restore utilities
PROVIDES:=ebtables-utils
ALTERNATIVES:=\
200:/usr/sbin/ebtables-restore:/usr/sbin/ebtables-legacy-restore
endef
define Package/ebtables-legacy/description
The ebtables program is a filtering tool for a bridging firewall. The
filtering is focussed on the Link Layer Ethernet frame fields. Apart
from filtering, it also gives the ability to alter the Ethernet MAC
addresses and implement a brouter.
endef
define Package/ebtables-legacy-utils/description
$(call Package/ebtables-legacy/description)
endef
MAKE_VARS += EXT_LIBSI="$(LIBGCC_S)"
MAKE_FLAGS += \
CFLAGS="$(TARGET_CFLAGS)" \
LIBDIR="/usr/lib/ebtables"
define Package/ebtables-legacy/install
$(INSTALL_DIR) $(1)/etc
$(INSTALL_DATA) $(PKG_BUILD_DIR)/ethertypes $(1)/etc/
$(INSTALL_DIR) $(1)/usr/lib/ebtables
$(INSTALL_BIN) $(PKG_BUILD_DIR)/lib*.so $(1)/usr/lib/
$(INSTALL_BIN) $(PKG_BUILD_DIR)/extensions/*.so $(1)/usr/lib/ebtables/
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/ebtables $(1)/usr/sbin/ebtables-legacy
endef
define Package/ebtables-legacy-utils/install
$(INSTALL_DIR) $(1)/usr/sbin
#ebtables-save depends on perl and is just broken
#$(INSTALL_BIN) $(PKG_BUILD_DIR)/ebtables-save $(1)/usr/sbin/ebtables-legacy-save
$(INSTALL_BIN) $(PKG_BUILD_DIR)/ebtables-restore $(1)/usr/sbin/ebtables-legacy-restore
endef
$(eval $(call BuildPackage,ebtables-legacy))
$(eval $(call BuildPackage,ebtables-legacy-utils))

View File

@@ -0,0 +1,260 @@
--- a/extensions/Makefile
+++ b/extensions/Makefile
@@ -11,13 +11,13 @@ EXT_LIBSI+=$(foreach T,$(EXT_FUNC), -leb
EXT_LIBSI+=$(foreach T,$(EXT_TABLES), -lebtable_$(T))
extensions/ebt_%.so: extensions/ebt_%.o
- $(CC) $(LDFLAGS) -shared -o $@ -lc $< -nostartfiles
+ $(CC) $(LDFLAGS) -shared -o $@ -lc $<
extensions/libebt_%.so: extensions/ebt_%.so
mv $< $@
extensions/ebtable_%.so: extensions/ebtable_%.o
- $(CC) $(LDFLAGS) -shared -o $@ -lc $< -nostartfiles
+ $(CC) $(LDFLAGS) -shared -o $@ -lc $<
extensions/libebtable_%.so: extensions/ebtable_%.so
mv $< $@
--- a/extensions/ebt_802_3.c
+++ b/extensions/ebt_802_3.c
@@ -141,7 +141,7 @@ static struct ebt_u_match _802_3_match =
.extra_ops = opts,
};
-void _init(void)
+__attribute__((constructor)) static void extension_init(void)
{
ebt_register_match(&_802_3_match);
}
--- a/extensions/ebt_among.c
+++ b/extensions/ebt_among.c
@@ -491,7 +491,7 @@ static struct ebt_u_match among_match =
.extra_ops = opts,
};
-void _init(void)
+__attribute__((constructor)) static void extension_init(void)
{
ebt_register_match(&among_match);
}
--- a/extensions/ebt_arp.c
+++ b/extensions/ebt_arp.c
@@ -362,7 +362,7 @@ static struct ebt_u_match arp_match =
.extra_ops = opts,
};
-void _init(void)
+__attribute__((constructor)) static void extension_init(void)
{
ebt_register_match(&arp_match);
}
--- a/extensions/ebt_arpreply.c
+++ b/extensions/ebt_arpreply.c
@@ -133,7 +133,7 @@ static struct ebt_u_target arpreply_targ
.extra_ops = opts,
};
-void _init(void)
+__attribute__((constructor)) static void extension_init(void)
{
ebt_register_target(&arpreply_target);
}
--- a/extensions/ebt_ip.c
+++ b/extensions/ebt_ip.c
@@ -472,7 +472,7 @@ static struct ebt_u_match ip_match =
.extra_ops = opts,
};
-void _init(void)
+__attribute__((constructor)) static void extension_init(void)
{
ebt_register_match(&ip_match);
}
--- a/extensions/ebt_ip6.c
+++ b/extensions/ebt_ip6.c
@@ -413,7 +413,7 @@ static struct ebt_u_match ip6_match =
.extra_ops = opts,
};
-void _init(void)
+__attribute__((constructor)) static void extension_init(void)
{
ebt_register_match(&ip6_match);
}
--- a/extensions/ebt_limit.c
+++ b/extensions/ebt_limit.c
@@ -212,7 +212,7 @@ static struct ebt_u_match limit_match =
.extra_ops = opts,
};
-void _init(void)
+__attribute__((constructor)) static void extension_init(void)
{
ebt_register_match(&limit_match);
}
--- a/extensions/ebt_log.c
+++ b/extensions/ebt_log.c
@@ -217,7 +217,7 @@ static struct ebt_u_watcher log_watcher
.extra_ops = opts,
};
-void _init(void)
+__attribute__((constructor)) static void extension_init(void)
{
ebt_register_watcher(&log_watcher);
}
--- a/extensions/ebt_mark.c
+++ b/extensions/ebt_mark.c
@@ -172,7 +172,7 @@ static struct ebt_u_target mark_target =
.extra_ops = opts,
};
-void _init(void)
+__attribute__((constructor)) static void extension_init(void)
{
ebt_register_target(&mark_target);
}
--- a/extensions/ebt_mark_m.c
+++ b/extensions/ebt_mark_m.c
@@ -121,7 +121,7 @@ static struct ebt_u_match mark_match =
.extra_ops = opts,
};
-void _init(void)
+__attribute__((constructor)) static void extension_init(void)
{
ebt_register_match(&mark_match);
}
--- a/extensions/ebt_nat.c
+++ b/extensions/ebt_nat.c
@@ -231,7 +231,7 @@ static struct ebt_u_target dnat_target =
.extra_ops = opts_d,
};
-void _init(void)
+__attribute__((constructor)) static void extension_init(void)
{
ebt_register_target(&snat_target);
ebt_register_target(&dnat_target);
--- a/extensions/ebt_nflog.c
+++ b/extensions/ebt_nflog.c
@@ -166,7 +166,7 @@ static struct ebt_u_watcher nflog_watche
.extra_ops = nflog_opts,
};
-void _init(void)
+__attribute__((constructor)) static void extension_init(void)
{
ebt_register_watcher(&nflog_watcher);
}
--- a/extensions/ebt_pkttype.c
+++ b/extensions/ebt_pkttype.c
@@ -125,7 +125,7 @@ static struct ebt_u_match pkttype_match
.extra_ops = opts,
};
-void _init(void)
+__attribute__((constructor)) static void extension_init(void)
{
ebt_register_match(&pkttype_match);
}
--- a/extensions/ebt_redirect.c
+++ b/extensions/ebt_redirect.c
@@ -108,7 +108,7 @@ static struct ebt_u_target redirect_targ
.extra_ops = opts,
};
-void _init(void)
+__attribute__((constructor)) static void extension_init(void)
{
ebt_register_target(&redirect_target);
}
--- a/extensions/ebt_standard.c
+++ b/extensions/ebt_standard.c
@@ -84,7 +84,7 @@ static struct ebt_u_target standard =
.extra_ops = opts,
};
-void _init(void)
+__attribute__((constructor)) static void extension_init(void)
{
ebt_register_target(&standard);
}
--- a/extensions/ebt_stp.c
+++ b/extensions/ebt_stp.c
@@ -337,7 +337,7 @@ static struct ebt_u_match stp_match =
.extra_ops = opts,
};
-void _init(void)
+__attribute__((constructor)) static void extension_init(void)
{
ebt_register_match(&stp_match);
}
--- a/extensions/ebt_ulog.c
+++ b/extensions/ebt_ulog.c
@@ -180,7 +180,7 @@ static struct ebt_u_watcher ulog_watcher
.extra_ops = opts,
};
-void _init(void)
+__attribute__((constructor)) static void extension_init(void)
{
ebt_register_watcher(&ulog_watcher);
}
--- a/extensions/ebt_vlan.c
+++ b/extensions/ebt_vlan.c
@@ -181,7 +181,7 @@ static struct ebt_u_match vlan_match = {
.extra_ops = opts,
};
-void _init(void)
+__attribute__((constructor)) static void extension_init(void)
{
ebt_register_match(&vlan_match);
}
--- a/extensions/ebtable_broute.c
+++ b/extensions/ebtable_broute.c
@@ -23,7 +23,7 @@ ebt_u_table table =
.help = print_help,
};
-void _init(void)
+__attribute__((constructor)) static void extension_init(void)
{
ebt_register_table(&table);
}
--- a/extensions/ebtable_filter.c
+++ b/extensions/ebtable_filter.c
@@ -29,7 +29,7 @@ static struct ebt_u_table table =
.help = print_help,
};
-void _init(void)
+__attribute__((constructor)) static void extension_init(void)
{
ebt_register_table(&table);
}
--- a/extensions/ebtable_nat.c
+++ b/extensions/ebtable_nat.c
@@ -30,7 +30,7 @@ ebt_u_table table =
.help = print_help,
};
-void _init(void)
+__attribute__((constructor)) static void extension_init(void)
{
ebt_register_table(&table);
}
--- a/extensions/ebt_string.c
+++ b/extensions/ebt_string.c
@@ -312,7 +312,7 @@ static struct ebt_u_match string_match =
.extra_ops = opts,
};
-void _init(void)
+__attribute__((constructor)) static void extension_init(void)
{
ebt_register_match(&string_match);
}

View File

@@ -0,0 +1,68 @@
#
# Copyright (C) 2006-2014 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:=ethtool
PKG_VERSION:=6.10
PKG_RELEASE:=1
PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
PKG_SOURCE_URL:=@KERNEL/software/network/ethtool
PKG_HASH:=cc613fe8a2bcddee17a1e6e0d763c0f3ea33c7e930658d2d7f601aa65e426a1f
PKG_LICENSE:=GPL-2.0
PKG_LICENSE_FILES:=COPYING
PKG_CPE_ID:=cpe:/a:kernel:ethtool
PKG_FIXUP:=autoreconf
PKG_INSTALL:=1
PKG_BUILD_PARALLEL:=1
include $(INCLUDE_DIR)/package.mk
define Package/ethtool
SECTION:=net
CATEGORY:=Network
TITLE:=Display or change ethernet card settings
URL:=http://www.kernel.org/pub/software/network/ethtool/
VARIANT:=tiny
CONFLICTS:=ethtool-full
endef
define Package/ethtool-full
$(Package/ethtool)
TITLE += (full)
VARIANT:=full
PROVIDES:=ethtool
DEPENDS:=+libmnl
CONFLICTS:=
endef
define Package/ethtool/description
ethtool is a small utility for examining and tuning your ethernet-based
network interface
endef
Package/ethtool-full/description:=$(Package/ethtool/description)
ifeq ($(BUILD_VARIANT),full)
CONFIGURE_ARGS += --enable-netlink --enable-pretty-dump
else
CONFIGURE_ARGS += --disable-netlink --disable-pretty-dump
endif
define Package/ethtool/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/ethtool $(1)/usr/sbin
endef
Package/ethtool-full/install=$(Package/ethtool/install)
$(eval $(call BuildPackage,ethtool))
$(eval $(call BuildPackage,ethtool-full))

View File

@@ -0,0 +1,268 @@
#
# Copyright (C) 2006-2015 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:=iproute2
PKG_VERSION:=6.12.0
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
PKG_SOURCE_URL:=@KERNEL/linux/utils/net/iproute2
PKG_HASH:=bbd141ef7b5d0127cc2152843ba61f274dc32814fa3e0f13e7d07a080bef53d9
PKG_BUILD_PARALLEL:=1
PKG_BUILD_DEPENDS:=iptables
PKG_LICENSE:=GPL-2.0
PKG_CPE_ID:=cpe:/a:iproute2_project:iproute2
PKG_BUILD_FLAGS:=gc-sections lto
include $(INCLUDE_DIR)/kernel.mk
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/nls.mk
define Package/iproute2/Default
SECTION:=net
CATEGORY:=Network
URL:=http://www.linuxfoundation.org/collaborate/workgroups/networking/iproute2
SUBMENU:=Routing and Redirection
MAINTAINER:=Russell Senior <russell@personaltelco.net>
endef
define Package/ip-tiny
$(call Package/iproute2/Default)
TITLE:=Routing control utility (minimal)
VARIANT:=iptiny
DEFAULT_VARIANT:=1
PROVIDES:=ip
ALTERNATIVES:=200:/sbin/ip:/usr/libexec/ip-tiny
DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl
endef
define Package/ip-full
$(call Package/iproute2/Default)
TITLE:=Routing control utility (full)
VARIANT:=ipfull
PROVIDES:=ip
ALTERNATIVES:=300:/sbin/ip:/usr/libexec/ip-full
DEPENDS:=+libnl-tiny +libbpf +(PACKAGE_devlink||PACKAGE_rdma):libmnl
endef
define Package/tc-tiny
$(call Package/iproute2/Default)
TITLE:=Traffic control utility (minimal)
VARIANT:=tctiny
DEFAULT_VARIANT:=1
PROVIDES:=tc
ALTERNATIVES:=200:/sbin/tc:/usr/libexec/tc-tiny
DEPENDS:=+kmod-sched-core +(PACKAGE_devlink||PACKAGE_rdma):libmnl
endef
define Package/tc-bpf
$(call Package/iproute2/Default)
TITLE:=Traffic control utility (bpf)
VARIANT:=tcbpf
PROVIDES:=tc
ALTERNATIVES:=300:/sbin/tc:/usr/libexec/tc-bpf
DEPENDS:=+kmod-sched-core +(PACKAGE_devlink||PACKAGE_rdma):libmnl +libbpf
endef
define Package/tc-full
$(call Package/iproute2/Default)
TITLE:=Traffic control utility (full)
VARIANT:=tcfull
PROVIDES:=tc
ALTERNATIVES:=400:/sbin/tc:/usr/libexec/tc-full
DEPENDS:=+kmod-sched-core +(PACKAGE_devlink||PACKAGE_rdma):libmnl +libbpf +libxtables
endef
define Package/genl
$(call Package/iproute2/Default)
TITLE:=General netlink utility frontend
DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl
endef
define Package/ip-bridge
$(call Package/iproute2/Default)
TITLE:=Bridge configuration utility from iproute2
DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl
endef
define Package/ss
$(call Package/iproute2/Default)
TITLE:=Socket statistics utility
DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl +libbpf +kmod-netlink-diag
endef
define Package/nstat
$(call Package/iproute2/Default)
TITLE:=Network statistics utility
DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl
endef
define Package/devlink
$(call Package/iproute2/Default)
TITLE:=Network devlink utility
DEPENDS:=+libmnl
endef
define Package/rdma
$(call Package/iproute2/Default)
TITLE:=Network rdma utility
DEPENDS:=+libmnl
endef
ifeq ($(BUILD_VARIANT),iptiny)
IP_CONFIG_TINY:=y
LIBBPF_FORCE:=off
endif
ifeq ($(BUILD_VARIANT),ipfull)
HAVE_ELF:=y
LIBBPF_FORCE:=on
endif
ifeq ($(BUILD_VARIANT),tctiny)
LIBBPF_FORCE:=off
endif
ifeq ($(BUILD_VARIANT),tcbpf)
HAVE_ELF:=y
LIBBPF_FORCE:=on
SHARED_LIBS:=y
endif
ifeq ($(BUILD_VARIANT),tcfull)
#enable iptables/xtables requirement only if tciptables variant is selected
TC_CONFIG_XT:=y
TC_CONFIG_XT_OLD:=y
TC_CONFIG_XT_OLD_H:=y
TC_CONFIG_IPSET:=y
HAVE_ELF:=y
LIBBPF_FORCE:=on
SHARED_LIBS:=y
else
#disable iptables requirement by default
TC_CONFIG_XT:=n
TC_CONFIG_XT_OLD:=n
TC_CONFIG_XT_OLD_H:=n
TC_CONFIG_IPSET:=n
endif
ifdef CONFIG_PACKAGE_devlink
HAVE_MNL:=y
endif
ifdef CONFIG_PACKAGE_rdma
HAVE_MNL:=y
endif
define Build/Configure
echo "static const char SNAPSHOT[] = \"$(PKG_VERSION)-$(PKG_RELEASE)-openwrt\";" \
> $(PKG_BUILD_DIR)/include/SNAPSHOT.h
endef
TARGET_LDFLAGS += -Wl,--as-needed
TARGET_CPPFLAGS += -I$(STAGING_DIR)/usr/include/libnl-tiny
MAKE_FLAGS += \
KERNEL_INCLUDE="$(LINUX_DIR)/include/uapi" \
SHARED_LIBS=$(SHARED_LIBS) \
IP_CONFIG_TINY=$(IP_CONFIG_TINY) \
BUILD_VARIANT=$(BUILD_VARIANT) \
LIBBPF_FORCE=$(LIBBPF_FORCE) \
HAVE_ELF=$(HAVE_ELF) \
HAVE_MNL=$(HAVE_MNL) \
HAVE_CAP=$(HAVE_CAP) \
HAVE_TIRPC=n \
IPT_LIB_DIR=/usr/lib/iptables \
XT_LIB_DIR=/usr/lib/iptables \
TC_CONFIG_XT=$(TC_CONFIG_XT) \
TC_CONFIG_XT_OLD=$(TC_CONFIG_XT_OLD) \
TC_CONFIG_XT_OLD_H=$(TC_CONFIG_XT_OLD_H) \
TC_CONFIG_IPSET=$(TC_CONFIG_IPSET) \
FPIC="$(FPIC)" \
$(if $(findstring c,$(OPENWRT_VERBOSE)),V=1,V='')
define Build/Compile
+$(MAKE_VARS) $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) $(MAKE_FLAGS)
endef
define Build/InstallDev
$(INSTALL_DIR) $(1)/usr/include/iproute2
$(CP) $(PKG_BUILD_DIR)/include/bpf_elf.h $(1)/usr/include/iproute2
$(CP) $(PKG_BUILD_DIR)/include/{libgenl,libnetlink}.h $(1)/usr/include/
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/lib/libnetlink.a $(1)/usr/lib/
endef
define Package/ip-tiny/install
$(INSTALL_DIR) $(1)/usr/libexec
$(INSTALL_BIN) $(PKG_BUILD_DIR)/ip/ip $(1)/usr/libexec/ip-tiny
endef
define Package/ip-full/install
$(INSTALL_DIR) $(1)/usr/libexec
$(INSTALL_BIN) $(PKG_BUILD_DIR)/ip/ip $(1)/usr/libexec/ip-full
endef
define Package/tc-tiny/install
$(INSTALL_DIR) $(1)/usr/libexec
$(INSTALL_BIN) $(PKG_BUILD_DIR)/tc/tc $(1)/usr/libexec/tc-tiny
endef
define Package/tc-bpf/install
$(INSTALL_DIR) $(1)/usr/libexec
$(INSTALL_BIN) $(PKG_BUILD_DIR)/tc/tc $(1)/usr/libexec/tc-bpf
endef
define Package/tc-full/install
$(INSTALL_DIR) $(1)/usr/libexec
$(INSTALL_BIN) $(PKG_BUILD_DIR)/tc/tc $(1)/usr/libexec/tc-full
endef
define Package/genl/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/genl/genl $(1)/usr/sbin/
endef
define Package/ip-bridge/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bridge/bridge $(1)/usr/sbin/
endef
define Package/ss/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/misc/ss $(1)/usr/sbin/
endef
define Package/nstat/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/misc/nstat $(1)/usr/sbin/
endef
define Package/devlink/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/devlink/devlink $(1)/usr/sbin/
endef
define Package/rdma/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/rdma/rdma $(1)/usr/sbin/
endef
$(eval $(call BuildPackage,ip-tiny))
$(eval $(call BuildPackage,ip-full))
$(eval $(call BuildPackage,tc-tiny))
$(eval $(call BuildPackage,tc-bpf))
$(eval $(call BuildPackage,tc-full))
$(eval $(call BuildPackage,genl))
$(eval $(call BuildPackage,ip-bridge))
$(eval $(call BuildPackage,ss))
$(eval $(call BuildPackage,nstat))
$(eval $(call BuildPackage,devlink))
$(eval $(call BuildPackage,rdma))

View File

@@ -0,0 +1,28 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Thu, 8 Aug 2024 09:19:01 +0200
Subject: libnetlink: fix build with musl and gcc 14
Fixes compilation error with musl libc and gcc 14:
../include/libnetlink.h: In function 'rta_getattr_be64':
../include/libnetlink.h:280:16: error: implicit declaration of function 'htobe64' [-Wimplicit-function-declaration]
280 | return htobe64(rta_getattr_u64(rta));
| ^~~~~~~
Reference: https://man7.org/linux/man-pages/man3/endian.3.html
Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
---
include/libnetlink.h | 1 +
1 file changed, 1 insertion(+)
--- a/include/libnetlink.h
+++ b/include/libnetlink.h
@@ -2,6 +2,7 @@
#ifndef __LIBNETLINK_H__
#define __LIBNETLINK_H__ 1
+#include <endian.h>
#include <stdio.h>
#include <string.h>
#include <asm/types.h>

View File

@@ -0,0 +1,59 @@
--- a/netem/maketable.c
+++ b/netem/maketable.c
@@ -11,7 +11,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
+#if !defined(__APPLE__) && !defined(__FreeBSD__)
#include <malloc.h>
+#endif
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
--- a/netem/normal.c
+++ b/netem/normal.c
@@ -9,8 +9,12 @@
#include <string.h>
#include <limits.h>
+#if !defined(__APPLE__) && !defined(__FreeBSD__)
#include <linux/types.h>
#include <linux/pkt_sched.h>
+#else
+#define NETEM_DIST_SCALE 8192
+#endif
#define TABLESIZE 16384
#define TABLEFACTOR NETEM_DIST_SCALE
--- a/netem/pareto.c
+++ b/netem/pareto.c
@@ -8,8 +8,12 @@
#include <math.h>
#include <limits.h>
+#if !defined(__APPLE__) && !defined(__FreeBSD__)
#include <linux/types.h>
#include <linux/pkt_sched.h>
+#else
+#define NETEM_DIST_SCALE 8192
+#endif
static const double a=3.0;
#define TABLESIZE 16384
--- a/netem/paretonormal.c
+++ b/netem/paretonormal.c
@@ -15,10 +15,13 @@
#include <string.h>
#include <math.h>
#include <limits.h>
+#if !defined(__APPLE__) && !defined(__FreeBSD__)
#include <malloc.h>
-
#include <linux/types.h>
#include <linux/pkt_sched.h>
+#else
+#define NETEM_DIST_SCALE 8192
+#endif
#define TABLESIZE 16384
#define TABLEFACTOR NETEM_DIST_SCALE

View File

@@ -0,0 +1,12 @@
--- a/tc/Makefile
+++ b/tc/Makefile
@@ -107,6 +107,9 @@ CFLAGS += -DCONFIG_GACT -DCONFIG_GACT_PR
ifneq ($(IPT_LIB_DIR),)
CFLAGS += -DIPT_LIB_DIR=\"$(IPT_LIB_DIR)\"
endif
+ifneq ($(XT_LIB_DIR),)
+ CFLAGS += -DXT_LIB_DIR=\"$(XT_LIB_DIR)\"
+endif
LEX := flex
CFLAGS += -DYY_NO_INPUT

View File

@@ -0,0 +1,20 @@
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -2,13 +2,13 @@
SSOBJ=ss.o ssfilter_check.o ssfilter.tab.o
LNSTATOBJ=lnstat.o lnstat_util.o
-TARGETS=ss nstat ifstat rtacct lnstat
+TARGETS=ss nstat
include ../config.mk
-ifeq ($(HAVE_BERKELEY_DB),y)
- TARGETS += arpd
-endif
+#ifeq ($(HAVE_BERKELEY_DB),y)
+# TARGETS += arpd
+#endif
all: $(TARGETS)

View File

@@ -0,0 +1,14 @@
--- a/Makefile
+++ b/Makefile
@@ -69,9 +69,9 @@ WFLAGS += -Wmissing-declarations -Wold-s
CFLAGS := $(WFLAGS) $(CCOPTS) -I../include -I../include/uapi $(DEFINES) $(CFLAGS)
YACCFLAGS = -d -t -v
-SUBDIRS=lib ip tc bridge misc netem genl man
+SUBDIRS=lib ip tc bridge misc genl
ifeq ($(HAVE_MNL),y)
-SUBDIRS += tipc devlink rdma dcb vdpa
+SUBDIRS += devlink rdma
endif
LIBNETLINK=../lib/libutil.a ../lib/libnetlink.a

View File

@@ -0,0 +1,9 @@
--- a/tc/q_fifo.c
+++ b/tc/q_fifo.c
@@ -90,5 +90,6 @@ struct qdisc_util pfifo_head_drop_qdisc_
struct qdisc_util pfifo_fast_qdisc_util = {
.id = "pfifo_fast",
+ .parse_qopt = fifo_parse_opt,
.print_qopt = prio_print_opt,
};

View File

@@ -0,0 +1,11 @@
--- a/configure
+++ b/configure
@@ -368,7 +368,7 @@ check_tirpc()
check_mnl()
{
- if ${PKG_CONFIG} libmnl --exists; then
+ if [ "${HAVE_MNL}" = "y" ] && ${PKG_CONFIG} libmnl --exists; then
echo "HAVE_MNL:=y" >>$CONFIG
echo "yes"

View File

@@ -0,0 +1,11 @@
--- a/configure
+++ b/configure
@@ -217,7 +217,7 @@ EOF
check_elf()
{
- if ${PKG_CONFIG} libelf --exists; then
+ if [ "${HAVE_ELF}" = "y" ] && ${PKG_CONFIG} libelf --exists; then
echo "HAVE_ELF:=y" >>$CONFIG
echo "yes"

View File

@@ -0,0 +1,11 @@
--- a/configure
+++ b/configure
@@ -427,7 +427,7 @@ EOF
check_cap()
{
- if ${PKG_CONFIG} libcap --exists; then
+ if [ "${HAVE_CAP}" = "y" ] && ${PKG_CONFIG} libcap --exists; then
echo "HAVE_CAP:=y" >>$CONFIG
echo "yes"

View File

@@ -0,0 +1,11 @@
--- a/configure
+++ b/configure
@@ -355,7 +355,7 @@ check_selinux()
check_tirpc()
{
- if ${PKG_CONFIG} libtirpc --exists; then
+ if [ "${HAVE_TIRPC}" = "y" ] && ${PKG_CONFIG} libtirpc --exists; then
echo "HAVE_RPC:=y" >>$CONFIG
echo "yes"

View File

@@ -0,0 +1,11 @@
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: GPL-2.0
include ../config.mk
-CFLAGS += -fPIC
+CFLAGS += $(FPIC)
UTILOBJ = utils.o utils_math.o rt_names.o ll_map.o ll_types.o ll_proto.o ll_addr.o \
inet_proto.o namespace.o json_writer.o json_print.o json_print_math.o \

View File

@@ -0,0 +1,108 @@
--- a/ip/Makefile
+++ b/ip/Makefile
@@ -19,6 +19,13 @@ RTMONOBJ=rtmon.o
include ../config.mk
+STATIC_SYM_FILTER:=
+ifeq ($(IP_CONFIG_TINY),y)
+ STATIC_SYM_FILTER:=iplink_can.c iplink_ipoib.c iplink_vxlan.c
+ CFLAGS += -DIPROUTE2_TINY
+endif
+STATIC_SYM_SOURCES:=$(filter-out $(STATIC_SYM_FILTER),$(wildcard *.c))
+
ALLOBJ=$(IPOBJ) $(RTMONOBJ)
SCRIPTS=routel
TARGETS=ip rtmon
@@ -48,7 +55,7 @@ else
ip: static-syms.o
static-syms.o: static-syms.h
-static-syms.h: $(wildcard *.c)
+static-syms.h: $(STATIC_SYM_SOURCES)
files="$^" ; \
for s in `grep -B 3 '\<dlsym' $$files | sed -n '/snprintf/{s:.*"\([^"]*\)".*:\1:;s:%s::;p}'` ; do \
sed -n '/'$$s'[^ ]* =/{s:.* \([^ ]*'$$s'[^ ]*\) .*:extern char \1[] __attribute__((weak)); if (!strcmp(sym, "\1")) return \1;:;p}' $$files ; \
--- a/ip/ip.c
+++ b/ip/ip.c
@@ -61,11 +61,17 @@ static void usage(void)
fprintf(stderr,
"Usage: ip [ OPTIONS ] OBJECT { COMMAND | help }\n"
" ip [ -force ] -batch filename\n"
+#ifndef IPROUTE2_TINY
"where OBJECT := { address | addrlabel | fou | help | ila | ioam | l2tp | link |\n"
" macsec | maddress | monitor | mptcp | mroute | mrule |\n"
" neighbor | neighbour | netconf | netns | nexthop | ntable |\n"
" ntbl | route | rule | sr | stats | tap | tcpmetrics |\n"
" token | tunnel | tuntap | vrf | xfrm }\n"
+#else
+ "where OBJECT := { address | help | link | maddress | monitor |\n"
+ " neighbor | neighbour | netns | route |\n"
+ " rule | stats | token | tunnel }\n"
+#endif
" OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] | -r[esolve] |\n"
" -h[uman-readable] | -iec | -j[son] | -p[retty] |\n"
" -f[amily] { inet | inet6 | mpls | bridge | link } |\n"
@@ -88,37 +94,49 @@ static const struct cmd {
int (*func)(int argc, char **argv);
} cmds[] = {
{ "address", do_ipaddr },
+#ifndef IPROUTE2_TINY
{ "addrlabel", do_ipaddrlabel },
+#endif
{ "maddress", do_multiaddr },
{ "route", do_iproute },
{ "rule", do_iprule },
{ "neighbor", do_ipneigh },
{ "neighbour", do_ipneigh },
+#ifndef IPROUTE2_TINY
{ "ntable", do_ipntable },
{ "ntbl", do_ipntable },
+#endif
{ "link", do_iplink },
+#ifndef IPROUTE2_TINY
{ "l2tp", do_ipl2tp },
{ "fou", do_ipfou },
{ "ila", do_ipila },
{ "macsec", do_ipmacsec },
+#endif
{ "tunnel", do_iptunnel },
{ "tunl", do_iptunnel },
+#ifndef IPROUTE2_TINY
{ "tuntap", do_iptuntap },
{ "tap", do_iptuntap },
{ "token", do_iptoken },
{ "tcpmetrics", do_tcp_metrics },
{ "tcp_metrics", do_tcp_metrics },
+#endif
{ "monitor", do_ipmonitor },
+#ifndef IPROUTE2_TINY
{ "xfrm", do_xfrm },
{ "mroute", do_multiroute },
{ "mrule", do_multirule },
+#endif
{ "netns", do_netns },
+#ifndef IPROUTE2_TINY
{ "netconf", do_ipnetconf },
{ "vrf", do_ipvrf},
{ "sr", do_seg6 },
{ "nexthop", do_ipnh },
{ "mptcp", do_mptcp },
{ "ioam", do_ioam6 },
+#endif
{ "help", do_help },
{ "stats", do_ipstats },
{ 0 }
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -3,6 +3,10 @@ include ../config.mk
CFLAGS += $(FPIC)
+ifeq ($(IP_CONFIG_TINY),y)
+ CFLAGS += -DIPROUTE2_TINY
+endif
+
UTILOBJ = utils.o utils_math.o rt_names.o ll_map.o ll_types.o ll_proto.o ll_addr.o \
inet_proto.o namespace.o json_writer.o json_print.o json_print_math.o \
names.o color.o bpf_legacy.o bpf_glue.o exec.o fs.o cg_map.o ppp_proto.o

View File

@@ -0,0 +1,41 @@
From 4e7dbf76227e8c7be7897dc81def3011f637864d Mon Sep 17 00:00:00 2001
From: Jonas Gorski <jogo@openwrt.org>
Date: Thu, 30 May 2013 11:54:04 +0200
Subject: [PATCH] add support for dropping with FAILED_POLICY
---
include/linux/fib_rules.h | 4 ++++
include/linux/rtnetlink.h | 1 +
ip/rtm_map.c | 4 ++++
3 files changed, 9 insertions(+)
--- a/ip/rtm_map.c
+++ b/ip/rtm_map.c
@@ -49,6 +49,8 @@ char *rtnl_rtntype_n2a(int id, char *buf
return "nat";
case RTN_XRESOLVE:
return "xresolve";
+ case RTN_FAILED_POLICY:
+ return "failed_policy";
default:
snprintf(buf, len, "%d", id);
return buf;
@@ -84,6 +86,8 @@ int rtnl_rtntype_a2n(int *id, char *arg)
res = RTN_UNICAST;
else if (strcmp(arg, "throw") == 0)
res = RTN_THROW;
+ else if (strcmp(arg, "failed_policy") == 0)
+ res = RTN_FAILED_POLICY;
else {
res = strtoul(arg, &end, 0);
if (!end || end == arg || *end || res > 255)
--- a/include/uapi/linux/rtnetlink.h
+++ b/include/uapi/linux/rtnetlink.h
@@ -265,6 +265,7 @@ enum {
RTN_THROW, /* Not in this table */
RTN_NAT, /* Translate this address */
RTN_XRESOLVE, /* Use external resolver */
+ RTN_FAILED_POLICY, /* Source address failed policy */
__RTN_MAX
};

View File

@@ -0,0 +1,20 @@
--- a/configure
+++ b/configure
@@ -241,7 +241,7 @@ int main(int argc, char **argv) {
}
EOF
- $CC -o $TMPDIR/libbpf_test $TMPDIR/libbpf_test.c $LIBBPF_CFLAGS $LIBBPF_LDLIBS >/dev/null 2>&1
+ $CC -o $TMPDIR/libbpf_test $TMPDIR/libbpf_test.c $LIBBPF_CFLAGS $LIBBPF_LDLIBS $LDFLAGS >/dev/null 2>&1
local ret=$?
rm -f $TMPDIR/libbpf_test.c $TMPDIR/libbpf_test
@@ -259,7 +259,7 @@ int main(int argc, char **argv) {
}
EOF
- $CC -o $TMPDIR/libbpf_sec_test $TMPDIR/libbpf_sec_test.c $LIBBPF_CFLAGS $LIBBPF_LDLIBS >/dev/null 2>&1
+ $CC -o $TMPDIR/libbpf_sec_test $TMPDIR/libbpf_sec_test.c $LIBBPF_CFLAGS $LIBBPF_LDLIBS $LDFLAGS >/dev/null 2>&1
local ret=$?
rm -f $TMPDIR/libbpf_sec_test.c $TMPDIR/libbpf_sec_test

View File

@@ -0,0 +1,22 @@
--- a/ip/Makefile
+++ b/ip/Makefile
@@ -28,7 +28,7 @@ STATIC_SYM_SOURCES:=$(filter-out $(STATI
ALLOBJ=$(IPOBJ) $(RTMONOBJ)
SCRIPTS=routel
-TARGETS=ip rtmon
+TARGETS=$(findstring ip,$(BUILD_VARIANT)) rtmon
all: $(TARGETS) $(SCRIPTS)
--- a/tc/Makefile
+++ b/tc/Makefile
@@ -120,7 +120,7 @@ MODDESTDIR := $(DESTDIR)$(LIBDIR)/tc
$(QUIET_CC)$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -shared -fpic $< -o $@
-all: tc $(TCSO)
+all: $(findstring tc,$(BUILD_VARIANT)) $(TCSO)
tc: $(TCOBJ) $(LIBNETLINK) libtc.a
$(QUIET_LINK)$(CC) $^ $(LDFLAGS) $(LDLIBS) -o $@

View File

@@ -0,0 +1,19 @@
--- a/configure
+++ b/configure
@@ -413,14 +413,8 @@ EOF
if $CC -I$INCLUDE -o $TMPDIR/strtest $TMPDIR/strtest.c >/dev/null 2>&1; then
echo "no"
else
- if ${PKG_CONFIG} libbsd --exists; then
- echo 'CFLAGS += -DHAVE_LIBBSD' "$(${PKG_CONFIG} libbsd --cflags)" >>$CONFIG
- echo 'LDLIBS +=' "$(${PKG_CONFIG} libbsd --libs)" >> $CONFIG
- echo "no"
- else
- echo 'CFLAGS += -DNEED_STRLCPY' >>$CONFIG
- echo "yes"
- fi
+ echo 'CFLAGS += -DNEED_STRLCPY' >>$CONFIG
+ echo "yes"
fi
rm -f $TMPDIR/strtest.c $TMPDIR/strtest
}

View File

@@ -0,0 +1,11 @@
--- a/configure
+++ b/configure
@@ -342,7 +342,7 @@ check_libbpf()
check_selinux()
# SELinux is a compile time option in the ss utility
{
- if ${PKG_CONFIG} libselinux --exists; then
+ if [ "${HAVE_SELINUX}" = "y" ] && ${PKG_CONFIG} libselinux --exists; then
echo "HAVE_SELINUX:=y" >>$CONFIG
echo "yes"

View File

@@ -0,0 +1,10 @@
--- a/rdma/rdma.h
+++ b/rdma/rdma.h
@@ -16,6 +16,7 @@
#include <rdma/rdma_user_cm.h>
#include <time.h>
#include <net/if_arp.h>
+#include <libgen.h>
#include "list.h"
#include "utils.h"

View File

@@ -0,0 +1,75 @@
# 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:=ipset
PKG_VERSION:=7.21
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=https://ipset.netfilter.org
PKG_HASH:=e2c6ce4fcf3acb3893ca5d35c86935f80ad76fc5ccae601185842df760e0bc69
PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io>
PKG_LICENSE:=GPL-2.0
PKG_CPE_ID:=cpe:/a:netfilter:ipset
PKG_FIXUP:=autoreconf
PKG_INSTALL:=1
include $(INCLUDE_DIR)/package.mk
define Package/ipset/Default
SECTION:=net
CATEGORY:=Network
DEPENDS+= +kmod-ipt-ipset +libmnl
TITLE:=IPset administration utility
URL:=http://ipset.netfilter.org/
endef
define Package/ipset
$(call Package/ipset/Default)
DEPENDS+= +libipset
endef
define Package/libipset
$(call Package/ipset/Default)
ABI_VERSION:=13
endef
CONFIGURE_ARGS += \
--disable-static \
--with-kbuild="$(LINUX_DIR)"
TARGET_LDFLAGS += -Wl,--gc-sections,--as-needed
MAKE_FLAGS += \
ARCH="$(LINUX_KARCH)" \
SHELL="$(BASH)"
define Build/InstallDev
$(INSTALL_DIR) $(1)/usr/include $(1)/usr/lib $(1)/usr/lib/pkgconfig
$(CP) $(PKG_INSTALL_DIR)/usr/include/libipset $(1)/usr/include/
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libipset.so* $(1)/usr/lib/
$(CP) $(PKG_BUILD_DIR)/lib/libipset.pc $(1)/usr/lib/pkgconfig/
endef
define Package/ipset/install
$(INSTALL_DIR) $(1)/usr/sbin
$(CP) $(PKG_INSTALL_DIR)/usr/sbin/ipset $(1)/usr/sbin/
$(CP) $(PKG_INSTALL_DIR)/usr/sbin/ipset-translate $(1)/usr/sbin/
endef
define Package/libipset/install
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libipset*.so.* $(1)/usr/lib/
endef
$(eval $(call BuildPackage,libipset))
$(eval $(call BuildPackage,ipset))

View File

@@ -0,0 +1,12 @@
--- a/src/ipset.c
+++ b/src/ipset.c
@@ -6,8 +6,8 @@
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
-#define _GNU_SOURCE
#include <assert.h> /* assert */
+#include <libgen.h> /* basename */
#include <stdio.h> /* fprintf */
#include <stdlib.h> /* exit */
#include <string.h> /* strcmp */

View File

@@ -0,0 +1,764 @@
#
# Copyright (C) 2006-2016 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:=iptables
PKG_VERSION:=1.8.10
PKG_RELEASE:=1
PKG_SOURCE_URL:=https://netfilter.org/projects/iptables/files
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
PKG_HASH:=5cc255c189356e317d070755ce9371eb63a1b783c34498fb8c30264f3cc59c9c
PKG_FIXUP:=autoreconf
PKG_FLAGS:=nonshared
PKG_INSTALL:=1
PKG_BUILD_FLAGS:=gc-sections no-lto
PKG_BUILD_PARALLEL:=1
PKG_LICENSE:=GPL-2.0
PKG_CPE_ID:=cpe:/a:netfilter:iptables
include $(INCLUDE_DIR)/package.mk
ifeq ($(DUMP),)
-include $(LINUX_DIR)/.config
include $(INCLUDE_DIR)/netfilter.mk
STAMP_CONFIGURED:=$(strip $(STAMP_CONFIGURED))_$(shell grep 'NETFILTER' $(LINUX_DIR)/.config | $(MKHASH) md5)
endif
define Package/iptables/Default
SECTION:=net
CATEGORY:=Network
SUBMENU:=Firewall
URL:=https://netfilter.org/
endef
define Package/iptables/Module
$(call Package/iptables/Default)
DEPENDS:=+libxtables $(1)
endef
define Package/xtables-legacy
$(call Package/iptables/Default)
TITLE:=IP firewall administration tool
DEPENDS+= +kmod-ipt-core +libip4tc +IPV6:libip6tc +libiptext +IPV6:libiptext6 +libxtables
endef
define Package/iptables-zz-legacy
$(call Package/iptables/Default)
TITLE:=IP firewall administration tool
DEPENDS+= +xtables-legacy
PROVIDES:=iptables iptables-legacy
ALTERNATIVES:=\
200:/usr/sbin/iptables:/usr/sbin/xtables-legacy-multi \
200:/usr/sbin/iptables-restore:/usr/sbin/xtables-legacy-multi \
200:/usr/sbin/iptables-save:/usr/sbin/xtables-legacy-multi
endef
define Package/iptables-zz-legacy/description
IP firewall administration tool.
Matches:
- icmp
- tcp
- udp
- comment
- conntrack
- limit
- mac
- mark
- multiport
- set
- state
- time
Targets:
- ACCEPT
- CT
- DNAT
- DROP
- REJECT
- FLOWOFFLOAD
- LOG
- MARK
- MASQUERADE
- REDIRECT
- SET
- SNAT
- TCPMSS
Tables:
- filter
- mangle
- nat
- raw
endef
define Package/xtables-nft
$(call Package/iptables/Default)
TITLE:=IP firewall administration tool nft
DEPENDS:=+libnftnl +libiptext +IPV6:libiptext6 +libiptext-nft +kmod-nft-compat
endef
define Package/arptables-nft
$(call Package/iptables/Default)
DEPENDS:=+kmod-nft-arp +xtables-nft +kmod-arptables
TITLE:=ARP firewall administration tool nft
PROVIDES:=arptables
ALTERNATIVES:=\
300:/usr/sbin/arptables:/usr/sbin/xtables-nft-multi \
300:/usr/sbin/arptables-restore:/usr/sbin/xtables-nft-multi \
300:/usr/sbin/arptables-save:/usr/sbin/xtables-nft-multi
endef
define Package/ebtables-nft
$(call Package/iptables/Default)
DEPENDS:=+kmod-nft-bridge +xtables-nft +kmod-ebtables
TITLE:=Bridge firewall administration tool nft
PROVIDES:=ebtables
ALTERNATIVES:=\
300:/usr/sbin/ebtables:/usr/sbin/xtables-nft-multi \
300:/usr/sbin/ebtables-restore:/usr/sbin/xtables-nft-multi \
300:/usr/sbin/ebtables-save:/usr/sbin/xtables-nft-multi
endef
define Package/iptables-nft
$(call Package/iptables/Default)
TITLE:=IP firewall administration tool nft
DEPENDS:=+kmod-ipt-core +xtables-nft
PROVIDES:=iptables
ALTERNATIVES:=\
300:/usr/sbin/iptables:/usr/sbin/xtables-nft-multi \
300:/usr/sbin/iptables-restore:/usr/sbin/xtables-nft-multi \
300:/usr/sbin/iptables-save:/usr/sbin/xtables-nft-multi
endef
define Package/iptables-nft/description
Extra iptables nftables nft binaries.
iptables-nft
iptables-nft-restore
iptables-nft-save
iptables-translate
iptables-restore-translate
endef
define Package/iptables-mod-conntrack-extra
$(call Package/iptables/Module, +kmod-ipt-conntrack-extra)
TITLE:=Extra connection tracking extensions
endef
define Package/iptables-mod-conntrack-extra/description
Extra iptables extensions for connection tracking.
Matches:
- connbytes
- connlimit
- connmark
- recent
- helper
Targets:
- CONNMARK
endef
define Package/iptables-mod-conntrack-label
$(call Package/iptables/Module, +kmod-ipt-conntrack-label @IPTABLES_CONNLABEL)
TITLE:=Connection tracking labeling extension
DEFAULT:=y if IPTABLES_CONNLABEL
endef
define Package/iptables-mod-conntrack-label/description
Match and set label(s) on connection tracking entries
Matches:
- connlabel
endef
define Package/iptables-mod-filter
$(call Package/iptables/Module, +kmod-ipt-filter)
TITLE:=Content inspection extensions
endef
define Package/iptables-mod-filter/description
iptables extensions for packet content inspection.
Includes support for:
Matches:
- string
- bpf
endef
define Package/iptables-mod-ipopt
$(call Package/iptables/Module, +kmod-ipt-ipopt)
TITLE:=IP/Packet option extensions
endef
define Package/iptables-mod-ipopt/description
iptables extensions for matching/changing IP packet options.
Matches:
- dscp
- ecn
- length
- statistic
- tcpmss
- unclean
- hl
Targets:
- DSCP
- CLASSIFY
- ECN
- HL
endef
define Package/iptables-mod-ipsec
$(call Package/iptables/Module, +kmod-ipt-ipsec)
TITLE:=IPsec extensions
endef
define Package/iptables-mod-ipsec/description
iptables extensions for matching ipsec traffic.
Matches:
- ah
- esp
- policy
endef
define Package/iptables-mod-nat-extra
$(call Package/iptables/Module, +kmod-ipt-nat-extra)
TITLE:=Extra NAT extensions
endef
define Package/iptables-mod-nat-extra/description
iptables extensions for extra NAT targets.
Targets:
- MIRROR
- NETMAP
endef
define Package/iptables-mod-nflog
$(call Package/iptables/Module, +kmod-nfnetlink-log +kmod-ipt-nflog)
TITLE:=Netfilter NFLOG target
endef
define Package/iptables-mod-nflog/description
iptables extension for user-space logging via NFNETLINK.
Includes:
- libxt_NFLOG
endef
define Package/iptables-mod-trace
$(call Package/iptables/Module, +kmod-ipt-debug)
TITLE:=Netfilter TRACE target
endef
define Package/iptables-mod-trace/description
iptables extension for TRACE target
Includes:
- libxt_TRACE
endef
define Package/iptables-mod-nfqueue
$(call Package/iptables/Module, +kmod-nfnetlink-queue +kmod-ipt-nfqueue)
TITLE:=Netfilter NFQUEUE target
endef
define Package/iptables-mod-nfqueue/description
iptables extension for user-space queuing via NFNETLINK.
Includes:
- libxt_NFQUEUE
endef
define Package/iptables-mod-hashlimit
$(call Package/iptables/Module, +kmod-ipt-hashlimit)
TITLE:=hashlimit matching
endef
define Package/iptables-mod-hashlimit/description
iptables extensions for hashlimit matching
Matches:
- hashlimit
endef
define Package/iptables-mod-rpfilter
$(call Package/iptables/Module, +kmod-ipt-rpfilter)
TITLE:=rpfilter iptables extension
endef
define Package/iptables-mod-rpfilter/description
iptables extensions for reverse path filter test on a packet
Matches:
- rpfilter
endef
define Package/iptables-mod-iprange
$(call Package/iptables/Module, +kmod-ipt-iprange)
TITLE:=IP range extension
endef
define Package/iptables-mod-iprange/description
iptables extensions for matching ip ranges.
Matches:
- iprange
endef
define Package/iptables-mod-cluster
$(call Package/iptables/Module, +kmod-ipt-cluster)
TITLE:=Match cluster extension
endef
define Package/iptables-mod-cluster/description
iptables extensions for matching cluster.
Netfilter (IPv4/IPv6) module for matching cluster
This option allows you to build work-load-sharing clusters of
network servers/stateful firewalls without having a dedicated
load-balancing router/server/switch. Basically, this match returns
true when the packet must be handled by this cluster node. Thus,
all nodes see all packets and this match decides which node handles
what packets. The work-load sharing algorithm is based on source
address hashing.
This module is usable for ipv4 and ipv6.
If you select it, it enables kmod-ipt-cluster.
see `iptables -m cluster --help` for more information.
endef
define Package/iptables-mod-extra
$(call Package/iptables/Module, +kmod-ipt-extra)
TITLE:=Other extra iptables extensions
endef
define Package/iptables-mod-extra/description
Other extra iptables extensions.
Matches:
- addrtype
- condition
- owner
- pkttype
- quota
endef
define Package/iptables-mod-physdev
$(call Package/iptables/Module, +kmod-ipt-physdev)
TITLE:=physdev iptables extension
endef
define Package/iptables-mod-physdev/description
The iptables physdev match.
endef
define Package/iptables-mod-led
$(call Package/iptables/Module, +kmod-ipt-led)
TITLE:=LED trigger iptables extension
endef
define Package/iptables-mod-led/description
iptables extension for triggering a LED.
Targets:
- LED
endef
define Package/iptables-mod-socket
$(call Package/iptables/Module, +kmod-ipt-socket)
TITLE:=Socket match iptables extensions
endef
define Package/iptables-mod-socket/description
Socket match iptables extensions.
Matches:
- socket
endef
define Package/iptables-mod-tproxy
$(call Package/iptables/Module, +kmod-ipt-tproxy)
TITLE:=Transparent proxy iptables extensions
endef
define Package/iptables-mod-tproxy/description
Transparent proxy iptables extensions.
Targets:
- TPROXY
endef
define Package/iptables-mod-tee
$(call Package/iptables/Module, +kmod-ipt-tee)
TITLE:=TEE iptables extensions
endef
define Package/iptables-mod-tee/description
TEE iptables extensions.
Targets:
- TEE
endef
define Package/iptables-mod-u32
$(call Package/iptables/Module, +kmod-ipt-u32)
TITLE:=U32 iptables extensions
endef
define Package/iptables-mod-u32/description
U32 iptables extensions.
Matches:
- u32
endef
define Package/iptables-mod-checksum
$(call Package/iptables/Module, +kmod-ipt-checksum)
TITLE:=IP CHECKSUM target extension
endef
define Package/iptables-mod-checksum/description
iptables extension for the CHECKSUM calculation target
endef
define Package/ip6tables-zz-legacy
$(call Package/iptables/Default)
DEPENDS:=@IPV6 +kmod-ip6tables +xtables-legacy
CATEGORY:=Network
TITLE:=IPv6 firewall administration tool
PROVIDES:=ip6tables ip6tables-legacy
ALTERNATIVES:=\
200:/usr/sbin/ip6tables:/usr/sbin/xtables-legacy-multi \
200:/usr/sbin/ip6tables-restore:/usr/sbin/xtables-legacy-multi \
200:/usr/sbin/ip6tables-save:/usr/sbin/xtables-legacy-multi
endef
define Package/ip6tables-nft
$(call Package/iptables/Default)
DEPENDS:=@IPV6 +kmod-ip6tables +xtables-nft
TITLE:=IP firewall administration tool nft
PROVIDES:=ip6tables
ALTERNATIVES:=\
300:/usr/sbin/ip6tables:/usr/sbin/xtables-nft-multi \
300:/usr/sbin/ip6tables-restore:/usr/sbin/xtables-nft-multi \
300:/usr/sbin/ip6tables-save:/usr/sbin/xtables-nft-multi
endef
define Package/ip6tables-nft/description
Extra ip6tables nftables nft binaries.
ip6tables-nft
ip6tables-nft-restore
ip6tables-nft-save
ip6tables-translate
ip6tables-restore-translate
endef
define Package/ip6tables-extra
$(call Package/iptables/Default)
DEPENDS:=+libxtables +kmod-ip6tables-extra
TITLE:=IPv6 header matching modules
endef
define Package/ip6tables-extra/description
iptables header matching modules for IPv6
endef
define Package/ip6tables-mod-nat
$(call Package/iptables/Default)
DEPENDS:=+libxtables +kmod-ipt-nat6
TITLE:=IPv6 NAT extensions
endef
define Package/ip6tables-mod-nat/description
iptables extensions for IPv6-NAT targets.
endef
define Package/libip4tc
$(call Package/iptables/Default)
SECTION:=libs
CATEGORY:=Libraries
TITLE:=IPv4 firewall - shared libiptc library
ABI_VERSION:=2
endef
define Package/libip6tc
$(call Package/iptables/Default)
SECTION:=libs
CATEGORY:=Libraries
TITLE:=IPv6 firewall - shared libiptc library
ABI_VERSION:=2
endef
define Package/libiptext
$(call Package/iptables/Default)
SECTION:=libs
CATEGORY:=Libraries
TITLE:=IPv4 firewall - shared libiptext library
ABI_VERSION:=0
DEPENDS:=+libxtables
endef
define Package/libiptext6
$(call Package/iptables/Default)
SECTION:=libs
CATEGORY:=Libraries
TITLE:=IPv6 firewall - shared libiptext library
ABI_VERSION:=0
DEPENDS:=+libxtables
endef
define Package/libiptext-nft
$(call Package/iptables/Default)
SECTION:=libs
CATEGORY:=Libraries
TITLE:=IPv4/IPv6 firewall - shared libiptext nft library
ABI_VERSION:=0
DEPENDS:=+libxtables
endef
define Package/libxtables
$(call Package/iptables/Default)
SECTION:=libs
CATEGORY:=Libraries
TITLE:=IPv4/IPv6 firewall - shared xtables library
MENU:=1
ABI_VERSION:=12
DEPENDS:=+IPTABLES_CONNLABEL:libnetfilter-conntrack
endef
define Package/libxtables/config
config IPTABLES_CONNLABEL
bool "Enable Connlabel support"
default n
help
This enable connlabel support in iptables.
endef
TARGET_CPPFLAGS := \
-I$(PKG_BUILD_DIR)/include \
-I$(LINUX_DIR)/user_headers/include \
$(TARGET_CPPFLAGS)
TARGET_CFLAGS += \
-I$(PKG_BUILD_DIR)/include \
-I$(LINUX_DIR)/user_headers/include \
-DNO_LEGACY
CONFIGURE_ARGS += \
--enable-shared \
--enable-static \
--enable-devel \
--with-kernel="$(LINUX_DIR)/user_headers" \
--with-xtlibdir=/usr/lib/iptables \
--with-xt-lock-name=/var/run/xtables.lock \
$(if $(CONFIG_IPTABLES_CONNLABEL),,--disable-connlabel) \
$(if $(CONFIG_IPV6),,--disable-ipv6)
MAKE_FLAGS := \
$(TARGET_CONFIGURE_OPTS) \
COPT_FLAGS="$(TARGET_CFLAGS)" \
KERNEL_DIR="$(LINUX_DIR)/user_headers/" PREFIX=/usr \
KBUILD_OUTPUT="$(LINUX_DIR)" \
BUILTIN_MODULES="$(patsubst ip6t_%,%,$(patsubst ipt_%,%,$(patsubst xt_%,%,$(IPT_BUILTIN) $(IPT_CONNTRACK-m) $(IPT_NAT-m))))"
ifneq ($(wildcard $(PKG_BUILD_DIR)/.config_*),$(subst .configured_,.config_,$(STAMP_CONFIGURED)))
define Build/Configure/rebuild
$(FIND) $(PKG_BUILD_DIR) -name \*.o -or -name \*.\?o -or -name \*.a | $(XARGS) rm -f
rm -f $(PKG_BUILD_DIR)/.config_*
rm -f $(PKG_BUILD_DIR)/.configured_*
touch $(subst .configured_,.config_,$(STAMP_CONFIGURED))
endef
endif
define Build/Configure
$(Build/Configure/rebuild)
$(Build/Configure/Default)
endef
define Build/InstallDev
$(INSTALL_DIR) $(1)/usr/include
$(INSTALL_DIR) $(1)/usr/include/iptables
$(INSTALL_DIR) $(1)/usr/include/net/netfilter
# XXX: iptables header fixup, some headers are not installed by iptables anymore
$(CP) $(PKG_BUILD_DIR)/include/iptables/*.h $(1)/usr/include/iptables/
$(CP) $(PKG_BUILD_DIR)/include/iptables.h $(1)/usr/include/
$(CP) $(PKG_BUILD_DIR)/include/ip6tables.h $(1)/usr/include/
$(CP) $(PKG_BUILD_DIR)/include/libiptc $(1)/usr/include/
$(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libxtables.so* $(1)/usr/lib/
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libip*tc.so* $(1)/usr/lib/
$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
$(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/xtables.pc $(1)/usr/lib/pkgconfig/
$(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libip*tc.pc $(1)/usr/lib/pkgconfig/
# XXX: needed by firewall3
$(CP) $(PKG_BUILD_DIR)/extensions/libiptext*.so $(1)/usr/lib/
endef
define Package/xtables-legacy/install
$(INSTALL_DIR) $(1)/usr/sbin
$(CP) $(PKG_INSTALL_DIR)/usr/sbin/xtables-legacy-multi $(1)/usr/sbin/
endef
define Package/iptables-zz-legacy/install
$(INSTALL_DIR) $(1)/usr/sbin
$(CP) $(PKG_INSTALL_DIR)/usr/sbin/iptables-legacy{,-restore,-save} $(1)/usr/sbin/
$(INSTALL_DIR) $(1)/usr/lib/iptables
endef
define Package/xtables-nft/install
$(INSTALL_DIR) $(1)/usr/sbin
$(CP) $(PKG_INSTALL_DIR)/usr/sbin/xtables-nft-multi $(1)/usr/sbin/
endef
define Package/arptables-nft/install
$(INSTALL_DIR) $(1)/usr/sbin
$(CP) $(PKG_INSTALL_DIR)/usr/sbin/arptables-nft{,-restore,-save} $(1)/usr/sbin/
$(INSTALL_DIR) $(1)/usr/lib/iptables
$(CP) $(PKG_BUILD_DIR)/extensions/libarpt_*.so $(1)/usr/lib/iptables/
endef
define Package/ebtables-nft/install
$(INSTALL_DIR) $(1)/usr/sbin
$(CP) $(PKG_INSTALL_DIR)/usr/sbin/ebtables-nft{,-restore,-save} $(1)/usr/sbin/
$(INSTALL_DIR) $(1)/usr/lib/iptables
$(CP) $(PKG_BUILD_DIR)/extensions/libebt_*.so $(1)/usr/lib/iptables/
endef
define Package/iptables-nft/install
$(INSTALL_DIR) $(1)/usr/sbin
$(CP) $(PKG_INSTALL_DIR)/usr/sbin/iptables-nft{,-restore,-save} $(1)/usr/sbin/
$(CP) $(PKG_INSTALL_DIR)/usr/sbin/iptables{,-restore}-translate $(1)/usr/sbin/
endef
define Package/ip6tables-zz-legacy/install
$(INSTALL_DIR) $(1)/usr/sbin
$(CP) $(PKG_INSTALL_DIR)/usr/sbin/ip6tables-legacy{,-restore,-save} $(1)/usr/sbin/
endef
define Package/ip6tables-nft/install
$(INSTALL_DIR) $(1)/usr/sbin
$(CP) $(PKG_INSTALL_DIR)/usr/sbin/ip6tables-nft{,-restore,-save} $(1)/usr/sbin/
$(CP) $(PKG_INSTALL_DIR)/usr/sbin/ip6tables{,-restore}-translate $(1)/usr/sbin/
endef
define Package/libip4tc/install
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libip4tc.so.* $(1)/usr/lib/
endef
define Package/libip6tc/install
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libip6tc.so.* $(1)/usr/lib/
endef
define Package/libiptext/install
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/extensions/libiptext.so $(1)/usr/lib/
$(CP) $(PKG_BUILD_DIR)/extensions/libiptext4.so $(1)/usr/lib/
endef
define Package/libiptext6/install
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/extensions/libiptext6.so $(1)/usr/lib/
endef
define Package/libiptext-nft/install
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/extensions/libiptext_*.so $(1)/usr/lib/
endef
define Package/libxtables/install
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libxtables.so.* $(1)/usr/lib/
endef
define BuildPlugin
define Package/$(1)/install
$(INSTALL_DIR) $$(1)/usr/lib/iptables
for m in $(patsubst xt_%,ipt_%,$(2)) $(patsubst ipt_%,xt_%,$(2)) $(patsubst xt_%,ip6t_%,$(2)) $(patsubst ip6t_%,xt_%,$(2)); do \
if [ -f $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$$$$$${m}.so ]; then \
$(CP) $(PKG_INSTALL_DIR)/usr/lib/iptables/lib$$$$$$$${m}.so $$(1)/usr/lib/iptables/ ; \
fi; \
done
$(3)
endef
$$(eval $$(call BuildPackage,$(1)))
endef
$(eval $(call BuildPackage,libxtables))
$(eval $(call BuildPackage,libip4tc))
$(eval $(call BuildPackage,libip6tc))
$(eval $(call BuildPackage,libiptext))
$(eval $(call BuildPackage,libiptext6))
$(eval $(call BuildPackage,libiptext-nft))
$(eval $(call BuildPackage,xtables-legacy))
$(eval $(call BuildPackage,xtables-nft))
$(eval $(call BuildPackage,arptables-nft))
$(eval $(call BuildPackage,ebtables-nft))
$(eval $(call BuildPackage,iptables-nft))
$(eval $(call BuildPackage,iptables-zz-legacy))
$(eval $(call BuildPlugin,iptables-mod-conntrack-extra,$(IPT_CONNTRACK_EXTRA-m)))
$(eval $(call BuildPlugin,iptables-mod-conntrack-label,$(IPT_CONNTRACK_LABEL-m)))
$(eval $(call BuildPlugin,iptables-mod-extra,$(IPT_EXTRA-m)))
$(eval $(call BuildPlugin,iptables-mod-physdev,$(IPT_PHYSDEV-m)))
$(eval $(call BuildPlugin,iptables-mod-filter,$(IPT_FILTER-m)))
$(eval $(call BuildPlugin,iptables-mod-ipopt,$(IPT_IPOPT-m)))
$(eval $(call BuildPlugin,iptables-mod-ipsec,$(IPT_IPSEC-m)))
$(eval $(call BuildPlugin,iptables-mod-nat-extra,$(IPT_NAT_EXTRA-m)))
$(eval $(call BuildPlugin,iptables-mod-iprange,$(IPT_IPRANGE-m)))
$(eval $(call BuildPlugin,iptables-mod-cluster,$(IPT_CLUSTER-m)))
$(eval $(call BuildPlugin,iptables-mod-hashlimit,$(IPT_HASHLIMIT-m)))
$(eval $(call BuildPlugin,iptables-mod-rpfilter,$(IPT_RPFILTER-m)))
$(eval $(call BuildPlugin,iptables-mod-led,$(IPT_LED-m)))
$(eval $(call BuildPlugin,iptables-mod-socket,$(IPT_SOCKET-m)))
$(eval $(call BuildPlugin,iptables-mod-tproxy,$(IPT_TPROXY-m)))
$(eval $(call BuildPlugin,iptables-mod-tee,$(IPT_TEE-m)))
$(eval $(call BuildPlugin,iptables-mod-u32,$(IPT_U32-m)))
$(eval $(call BuildPlugin,iptables-mod-nflog,$(IPT_NFLOG-m)))
$(eval $(call BuildPlugin,iptables-mod-trace,$(IPT_DEBUG-m)))
$(eval $(call BuildPlugin,iptables-mod-nfqueue,$(IPT_NFQUEUE-m)))
$(eval $(call BuildPlugin,iptables-mod-checksum,$(IPT_CHECKSUM-m)))
$(eval $(call BuildPackage,ip6tables-nft))
$(eval $(call BuildPackage,ip6tables-zz-legacy))
$(eval $(call BuildPlugin,ip6tables-extra,$(IPT_IPV6_EXTRA-m)))
$(eval $(call BuildPlugin,ip6tables-mod-nat,$(IPT_NAT6-m)))

View File

@@ -0,0 +1,452 @@
From 74267bacce0c43e5038b0377cb7c08f1ad9d50a3 Mon Sep 17 00:00:00 2001
From: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
Date: Sat, 23 Mar 2019 10:21:03 +0000
Subject: [PATCH] iptables: connmark - add set-dscpmark option for openwrt
Naive user space front end to xt_connmark 'setdscp' option.
iptables -A QOS_MARK_eth0 -t mangle -j CONNMARK --set-dscpmark 0xfc000000/0x01000000
This version has a hack to support a backport to 4.14
Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
---
extensions/libxt_CONNMARK.c | 315 +++++++++++++++++++++++++-
include/linux/netfilter/xt_connmark.h | 10 +
2 files changed, 324 insertions(+), 1 deletion(-)
--- a/extensions/libxt_CONNMARK.c
+++ b/extensions/libxt_CONNMARK.c
@@ -22,6 +22,7 @@
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
+#include <strings.h>
#include <xtables.h>
#include <linux/netfilter/xt_CONNMARK.h>
@@ -49,6 +50,7 @@ enum {
O_CTMASK,
O_NFMASK,
O_MASK,
+ O_DSCP_MARK,
F_SET_MARK = 1 << O_SET_MARK,
F_SAVE_MARK = 1 << O_SAVE_MARK,
F_RESTORE_MARK = 1 << O_RESTORE_MARK,
@@ -61,8 +63,10 @@ enum {
F_CTMASK = 1 << O_CTMASK,
F_NFMASK = 1 << O_NFMASK,
F_MASK = 1 << O_MASK,
+ F_DSCP_MARK = 1 << O_DSCP_MARK,
F_OP_ANY = F_SET_MARK | F_SAVE_MARK | F_RESTORE_MARK |
- F_AND_MARK | F_OR_MARK | F_XOR_MARK | F_SET_XMARK,
+ F_AND_MARK | F_OR_MARK | F_XOR_MARK | F_SET_XMARK |
+ F_DSCP_MARK,
};
static const char *const xt_connmark_shift_ops[] = {
@@ -114,6 +118,8 @@ static const struct xt_option_entry conn
.excl = F_MASK, .flags = XTOPT_PUT, XTOPT_POINTER(s, nfmask)},
{.name = "mask", .id = O_MASK, .type = XTTYPE_UINT32,
.excl = F_CTMASK | F_NFMASK},
+ {.name = "set-dscpmark", .id = O_DSCP_MARK, .type = XTTYPE_MARKMASK32,
+ .excl = F_OP_ANY},
XTOPT_TABLEEND,
};
#undef s
@@ -148,6 +154,38 @@ static const struct xt_option_entry conn
};
#undef s
+#define s struct xt_connmark_tginfo3
+static const struct xt_option_entry connmark_tg_opts_v3[] = {
+ {.name = "set-xmark", .id = O_SET_XMARK, .type = XTTYPE_MARKMASK32,
+ .excl = F_OP_ANY},
+ {.name = "set-mark", .id = O_SET_MARK, .type = XTTYPE_MARKMASK32,
+ .excl = F_OP_ANY},
+ {.name = "and-mark", .id = O_AND_MARK, .type = XTTYPE_UINT32,
+ .excl = F_OP_ANY},
+ {.name = "or-mark", .id = O_OR_MARK, .type = XTTYPE_UINT32,
+ .excl = F_OP_ANY},
+ {.name = "xor-mark", .id = O_XOR_MARK, .type = XTTYPE_UINT32,
+ .excl = F_OP_ANY},
+ {.name = "save-mark", .id = O_SAVE_MARK, .type = XTTYPE_NONE,
+ .excl = F_OP_ANY},
+ {.name = "restore-mark", .id = O_RESTORE_MARK, .type = XTTYPE_NONE,
+ .excl = F_OP_ANY},
+ {.name = "left-shift-mark", .id = O_LEFT_SHIFT_MARK, .type = XTTYPE_UINT8,
+ .min = 0, .max = 32},
+ {.name = "right-shift-mark", .id = O_RIGHT_SHIFT_MARK, .type = XTTYPE_UINT8,
+ .min = 0, .max = 32},
+ {.name = "ctmask", .id = O_CTMASK, .type = XTTYPE_UINT32,
+ .excl = F_MASK, .flags = XTOPT_PUT, XTOPT_POINTER(s, ctmask)},
+ {.name = "nfmask", .id = O_NFMASK, .type = XTTYPE_UINT32,
+ .excl = F_MASK, .flags = XTOPT_PUT, XTOPT_POINTER(s, nfmask)},
+ {.name = "mask", .id = O_MASK, .type = XTTYPE_UINT32,
+ .excl = F_CTMASK | F_NFMASK},
+ {.name = "set-dscpmark", .id = O_DSCP_MARK, .type = XTTYPE_MARKMASK32,
+ .excl = F_OP_ANY},
+ XTOPT_TABLEEND,
+};
+#undef s
+
static void connmark_tg_help(void)
{
printf(
@@ -175,6 +213,15 @@ static void connmark_tg_help_v2(void)
);
}
+static void connmark_tg_help_v3(void)
+{
+ connmark_tg_help_v2();
+ printf(
+" --set-dscpmark value/mask Save DSCP to conntrack mark value\n"
+);
+}
+
+
static void connmark_tg_init(struct xt_entry_target *target)
{
struct xt_connmark_tginfo1 *info = (void *)target->data;
@@ -199,6 +246,16 @@ static void connmark_tg_init_v2(struct x
info->shift_bits = 0;
}
+static void connmark_tg_init_v3(struct xt_entry_target *target)
+{
+ struct xt_connmark_tginfo3 *info;
+
+ connmark_tg_init_v2(target);
+ info = (void *)target->data;
+
+ info->func = 0;
+}
+
static void CONNMARK_parse(struct xt_option_call *cb)
{
struct xt_connmark_target_info *markinfo = cb->data;
@@ -253,6 +310,23 @@ static void connmark_tg_parse(struct xt_
info->ctmark = cb->val.u32;
info->ctmask = 0;
break;
+ case O_DSCP_MARK:
+/* we sneaky sneaky this. nfmask isn't used by the set mark functionality
+ * and by default is set to uint32max. We can use the top bit as a flag
+ * that we're in DSCP_MARK submode of SET_MARK, if set then it's normal
+ * if unset then we're in DSCP_MARK
+ */
+ info->mode = XT_CONNMARK_SET;
+ info->ctmark = cb->val.mark;
+ info->ctmask = cb->val.mask;
+ info->nfmask = info->ctmark ? ffs(info->ctmark) - 1 : 0;
+ /* need 6 contiguous bits */
+ if ((~0 & (info->ctmark >> info->nfmask)) != 0x3f)
+ xtables_error(PARAMETER_PROBLEM,
+ "CONNMARK set-dscpmark: need 6 contiguous dscpmask bits");
+ if (info->ctmark & info->ctmask)
+ xtables_error(PARAMETER_PROBLEM,
+ "CONNMARK set-dscpmark: dscpmask/statemask bits overlap");
case O_SAVE_MARK:
info->mode = XT_CONNMARK_SAVE;
break;
@@ -320,6 +394,78 @@ static void connmark_tg_parse_v2(struct
}
}
+static void connmark_tg_parse_v3(struct xt_option_call *cb)
+{
+ struct xt_connmark_tginfo3 *info = cb->data;
+
+ xtables_option_parse(cb);
+ switch (cb->entry->id) {
+ case O_SET_XMARK:
+ info->mode = XT_CONNMARK_SET;
+ info->func = XT_CONNMARK_VALUE;
+ info->ctmark = cb->val.mark;
+ info->ctmask = cb->val.mask;
+ break;
+ case O_SET_MARK:
+ info->mode = XT_CONNMARK_SET;
+ info->func = XT_CONNMARK_VALUE;
+ info->ctmark = cb->val.mark;
+ info->ctmask = cb->val.mark | cb->val.mask;
+ break;
+ case O_AND_MARK:
+ info->mode = XT_CONNMARK_SET;
+ info->func = XT_CONNMARK_VALUE;
+ info->ctmark = 0;
+ info->ctmask = ~cb->val.u32;
+ break;
+ case O_OR_MARK:
+ info->mode = XT_CONNMARK_SET;
+ info->func = XT_CONNMARK_VALUE;
+ info->ctmark = cb->val.u32;
+ info->ctmask = cb->val.u32;
+ break;
+ case O_XOR_MARK:
+ info->mode = XT_CONNMARK_SET;
+ info->func = XT_CONNMARK_VALUE;
+ info->ctmark = cb->val.u32;
+ info->ctmask = 0;
+ break;
+ case O_DSCP_MARK:
+ info->mode = XT_CONNMARK_SET;
+ info->func = XT_CONNMARK_DSCP;
+ info->ctmark = cb->val.mark;
+ info->ctmask = cb->val.mask;
+ info->shift_bits = info->ctmark ? ffs(info->ctmark) - 1 : 0;
+ /* need 6 contiguous bits */
+ if ((~0 & (info->ctmark >> info->shift_bits)) != 0x3f)
+ xtables_error(PARAMETER_PROBLEM,
+ "CONNMARK set-dscpmark: need 6 contiguous dscpmask bits");
+ if (info->ctmark & info->ctmask)
+ xtables_error(PARAMETER_PROBLEM,
+ "CONNMARK set-dscpmark: dscpmask/statemask bits overlap");
+ break;
+ case O_SAVE_MARK:
+ info->mode = XT_CONNMARK_SAVE;
+ break;
+ case O_RESTORE_MARK:
+ info->mode = XT_CONNMARK_RESTORE;
+ break;
+ case O_MASK:
+ info->nfmask = info->ctmask = cb->val.u32;
+ break;
+ case O_LEFT_SHIFT_MARK:
+ info->shift_dir = D_SHIFT_LEFT;
+ info->shift_bits = cb->val.u8;
+ break;
+ case O_RIGHT_SHIFT_MARK:
+ info->shift_dir = D_SHIFT_RIGHT;
+ info->shift_bits = cb->val.u8;
+ break;
+ default:
+ break;
+ }
+}
+
static void connmark_tg_check(struct xt_fcheck_call *cb)
{
if (!(cb->xflags & F_OP_ANY))
@@ -463,6 +609,65 @@ connmark_tg_print_v2(const void *ip, con
}
}
+static void
+connmark_tg_print_v3(const void *ip, const struct xt_entry_target *target,
+ int numeric)
+{
+ const struct xt_connmark_tginfo3 *info = (const void *)target->data;
+ const char *shift_op = xt_connmark_shift_ops[info->shift_dir];
+
+ switch (info->mode) {
+ case XT_CONNMARK_SET:
+ if (info->func & XT_CONNMARK_DSCP) {
+ printf(" CONNMARK DSCP 0x%x/0x%x",
+ info->ctmark, info->ctmask);
+ }
+ if (info->func & XT_CONNMARK_VALUE) {
+ if (info->ctmark == 0)
+ printf(" CONNMARK and 0x%x",
+ (unsigned int)(uint32_t)~info->ctmask);
+ else if (info->ctmark == info->ctmask)
+ printf(" CONNMARK or 0x%x", info->ctmark);
+ else if (info->ctmask == 0)
+ printf(" CONNMARK xor 0x%x", info->ctmark);
+ else if (info->ctmask == 0xFFFFFFFFU)
+ printf(" CONNMARK set 0x%x", info->ctmark);
+ else
+ printf(" CONNMARK xset 0x%x/0x%x",
+ info->ctmark, info->ctmask);
+ }
+ break;
+ case XT_CONNMARK_SAVE:
+ if (info->nfmask == UINT32_MAX && info->ctmask == UINT32_MAX)
+ printf(" CONNMARK save");
+ else if (info->nfmask == info->ctmask)
+ printf(" CONNMARK save mask 0x%x", info->nfmask);
+ else
+ printf(" CONNMARK save nfmask 0x%x ctmask ~0x%x",
+ info->nfmask, info->ctmask);
+ break;
+ case XT_CONNMARK_RESTORE:
+ if (info->ctmask == UINT32_MAX && info->nfmask == UINT32_MAX)
+ printf(" CONNMARK restore");
+ else if (info->ctmask == info->nfmask)
+ printf(" CONNMARK restore mask 0x%x", info->ctmask);
+ else
+ printf(" CONNMARK restore ctmask 0x%x nfmask ~0x%x",
+ info->ctmask, info->nfmask);
+ break;
+
+ default:
+ printf(" ERROR: UNKNOWN CONNMARK MODE");
+ break;
+ }
+
+ if (info->mode <= XT_CONNMARK_RESTORE &&
+ !(info->mode == XT_CONNMARK_SET && info->func == XT_CONNMARK_DSCP) &&
+ info->shift_bits != 0) {
+ printf(" %s %u", shift_op, info->shift_bits);
+ }
+}
+
static void CONNMARK_save(const void *ip, const struct xt_entry_target *target)
{
const struct xt_connmark_target_info *markinfo =
@@ -548,6 +753,38 @@ connmark_tg_save_v2(const void *ip, cons
}
}
+static void
+connmark_tg_save_v3(const void *ip, const struct xt_entry_target *target)
+{
+ const struct xt_connmark_tginfo3 *info = (const void *)target->data;
+ const char *shift_op = xt_connmark_shift_ops[info->shift_dir];
+
+ switch (info->mode) {
+ case XT_CONNMARK_SET:
+ if (info->func & XT_CONNMARK_VALUE)
+ printf(" --set-xmark 0x%x/0x%x", info->ctmark, info->ctmask);
+ if (info->func & XT_CONNMARK_DSCP)
+ printf(" --set-dscpmark 0x%x/0x%x", info->ctmark, info->ctmask);
+ break;
+ case XT_CONNMARK_SAVE:
+ printf(" --save-mark --nfmask 0x%x --ctmask 0x%x",
+ info->nfmask, info->ctmask);
+ break;
+ case XT_CONNMARK_RESTORE:
+ printf(" --restore-mark --nfmask 0x%x --ctmask 0x%x",
+ info->nfmask, info->ctmask);
+ break;
+ default:
+ printf(" ERROR: UNKNOWN CONNMARK MODE");
+ break;
+ }
+ if (info->mode <= XT_CONNMARK_RESTORE &&
+ !(info->mode == XT_CONNMARK_SET && info->func == XT_CONNMARK_DSCP) &&
+ info->shift_bits != 0) {
+ printf(" --%s %u", shift_op, info->shift_bits);
+ }
+}
+
static int connmark_tg_xlate(struct xt_xlate *xl,
const struct xt_xlate_tg_params *params)
{
@@ -644,6 +881,66 @@ static int connmark_tg_xlate_v2(struct x
return 1;
}
+
+static int connmark_tg_xlate_v3(struct xt_xlate *xl,
+ const struct xt_xlate_tg_params *params)
+{
+ const struct xt_connmark_tginfo3 *info =
+ (const void *)params->target->data;
+ const char *shift_op = xt_connmark_shift_ops[info->shift_dir];
+
+ switch (info->mode) {
+ case XT_CONNMARK_SET:
+ xt_xlate_add(xl, "ct mark set ");
+ if (info->func & XT_CONNMARK_VALUE) {
+ if (info->ctmask == 0xFFFFFFFFU)
+ xt_xlate_add(xl, "0x%x ", info->ctmark);
+ else if (info->ctmark == 0)
+ xt_xlate_add(xl, "ct mark and 0x%x", ~info->ctmask);
+ else if (info->ctmark == info->ctmask)
+ xt_xlate_add(xl, "ct mark or 0x%x",
+ info->ctmark);
+ else if (info->ctmask == 0)
+ xt_xlate_add(xl, "ct mark xor 0x%x",
+ info->ctmark);
+ else
+ xt_xlate_add(xl, "ct mark xor 0x%x and 0x%x",
+ info->ctmark, ~info->ctmask);
+ }
+ if (info->func & XT_CONNMARK_DSCP) {
+/* FIXME the nftables syntax would go here if only we knew what it was */
+ xt_xlate_add(xl, "ct mark set typeof(ct mark) ip dscp "
+ "<< %u or 0x%x", info->shift_bits,
+ info->ctmask);
+ }
+ break;
+ case XT_CONNMARK_SAVE:
+ xt_xlate_add(xl, "ct mark set mark");
+ if (!(info->nfmask == UINT32_MAX &&
+ info->ctmask == UINT32_MAX)) {
+ if (info->nfmask == info->ctmask)
+ xt_xlate_add(xl, " and 0x%x", info->nfmask);
+ }
+ break;
+ case XT_CONNMARK_RESTORE:
+ xt_xlate_add(xl, "meta mark set ct mark");
+ if (!(info->nfmask == UINT32_MAX &&
+ info->ctmask == UINT32_MAX)) {
+ if (info->nfmask == info->ctmask)
+ xt_xlate_add(xl, " and 0x%x", info->nfmask);
+ }
+ break;
+ }
+
+ if (info->mode <= XT_CONNMARK_RESTORE &&
+ !(info->mode == XT_CONNMARK_SET && info->func == XT_CONNMARK_DSCP) &&
+ info->shift_bits != 0) {
+ xt_xlate_add(xl, " %s %u", shift_op, info->shift_bits);
+ }
+
+ return 1;
+}
+
static struct xtables_target connmark_tg_reg[] = {
{
.family = NFPROTO_UNSPEC,
@@ -692,6 +989,22 @@ static struct xtables_target connmark_tg
.x6_options = connmark_tg_opts_v2,
.xlate = connmark_tg_xlate_v2,
},
+ {
+ .version = XTABLES_VERSION,
+ .name = "CONNMARK",
+ .revision = 3,
+ .family = NFPROTO_UNSPEC,
+ .size = XT_ALIGN(sizeof(struct xt_connmark_tginfo3)),
+ .userspacesize = XT_ALIGN(sizeof(struct xt_connmark_tginfo3)),
+ .help = connmark_tg_help_v3,
+ .init = connmark_tg_init_v3,
+ .print = connmark_tg_print_v3,
+ .save = connmark_tg_save_v3,
+ .x6_parse = connmark_tg_parse_v3,
+ .x6_fcheck = connmark_tg_check,
+ .x6_options = connmark_tg_opts_v3,
+ .xlate = connmark_tg_xlate_v3,
+ },
};
void _init(void)
--- a/include/linux/netfilter/xt_connmark.h
+++ b/include/linux/netfilter/xt_connmark.h
@@ -18,6 +18,11 @@ enum {
XT_CONNMARK_RESTORE
};
+enum {
+ XT_CONNMARK_VALUE = (1 << 0),
+ XT_CONNMARK_DSCP = (1 << 1)
+};
+
struct xt_connmark_tginfo1 {
__u32 ctmark, ctmask, nfmask;
__u8 mode;
@@ -28,6 +33,11 @@ struct xt_connmark_tginfo2 {
__u8 shift_dir, shift_bits, mode;
};
+struct xt_connmark_tginfo3 {
+ __u32 ctmark, ctmask, nfmask;
+ __u8 shift_dir, shift_bits, mode, func;
+};
+
struct xt_connmark_mtinfo1 {
__u32 mark, mask;
__u8 invert;

View File

@@ -0,0 +1,28 @@
--- a/libxtables/xtables.c
+++ b/libxtables/xtables.c
@@ -1095,12 +1095,6 @@ void xtables_register_match(struct xtabl
struct xtables_match **pos;
bool seen_myself = false;
- if (me->next) {
- fprintf(stderr, "%s: match \"%s\" already registered\n",
- xt_params->program_name, me->name);
- exit(1);
- }
-
if (me->version == NULL) {
fprintf(stderr, "%s: match %s<%u> is missing a version\n",
xt_params->program_name, me->name, me->revision);
@@ -1279,12 +1273,6 @@ void xtables_register_target(struct xtab
struct xtables_target **pos;
bool seen_myself = false;
- if (me->next) {
- fprintf(stderr, "%s: target \"%s\" already registered\n",
- xt_params->program_name, me->name);
- exit(1);
- }
-
if (me->version == NULL) {
fprintf(stderr, "%s: target %s<%u> is missing a version\n",
xt_params->program_name, me->name, me->revision);

View File

@@ -0,0 +1,27 @@
--- a/libxtables/xtables.c
+++ b/libxtables/xtables.c
@@ -475,7 +475,7 @@ char *xtables_strdup(const char *s)
return dup;
}
-static char *get_modprobe(void)
+__attribute__((unused)) static char *get_modprobe(void)
{
int procfile;
char *ret;
@@ -505,6 +505,7 @@ static char *get_modprobe(void)
int xtables_insmod(const char *modname, const char *modprobe, bool quiet)
{
+#if 0
char *buf = NULL;
char *argv[4];
int status;
@@ -539,6 +540,7 @@ int xtables_insmod(const char *modname,
free(buf);
if (WIFEXITED(status) && WEXITSTATUS(status) == 0)
return 0;
+#endif
return -1;
}

View File

@@ -0,0 +1,13 @@
--- a/iptables/xtables-legacy-multi.c
+++ b/iptables/xtables-legacy-multi.c
@@ -28,8 +28,10 @@ static const struct subcommand multi_sub
#endif
+#ifdef ENABLE_XML
{"iptables-xml", iptables_xml_main},
{"xml", iptables_xml_main},
+#endif
#ifdef ENABLE_IPV6
{"ip6tables", ip6tables_main},
{"main6", ip6tables_main},

View File

@@ -0,0 +1,79 @@
--- a/extensions/GNUmakefile.in
+++ b/extensions/GNUmakefile.in
@@ -50,11 +50,31 @@ pfb_build_mod := $(filter-out @blacklist
pfa_build_mod := $(filter-out @blacklist_modules@ @blacklist_a_modules@,${pfa_build_mod})
pf4_build_mod := $(filter-out @blacklist_modules@ @blacklist_4_modules@,${pf4_build_mod})
pf6_build_mod := $(filter-out @blacklist_modules@ @blacklist_6_modules@,${pf6_build_mod})
-pfx_objs := $(patsubst %,libxt_%.o,${pfx_build_mod})
-pfb_objs := $(patsubst %,libebt_%.o,${pfb_build_mod})
-pfa_objs := $(patsubst %,libarpt_%.o,${pfa_build_mod})
-pf4_objs := $(patsubst %,libipt_%.o,${pf4_build_mod})
-pf6_objs := $(patsubst %,libip6t_%.o,${pf6_build_mod})
+ifdef BUILTIN_MODULES
+pfx_build_static := $(filter $(BUILTIN_MODULES),${pfx_build_mod})
+pfb_build_static := $(filter $(BUILTIN_MODULES),${pfb_build_mod})
+pfa_build_static := $(filter $(BUILTIN_MODULES),${pfa_build_mod})
+pf4_build_static := $(filter $(BUILTIN_MODULES),${pf4_build_mod})
+pf6_build_static := $(filter $(BUILTIN_MODULES),${pf6_build_mod})
+else
+@ENABLE_STATIC_TRUE@ pfx_build_static := $(pfx_build_mod)
+@ENABLE_STATIC_TRUE@ pfb_build_static := $(pfb_build_mod)
+@ENABLE_STATIC_TRUE@ pfa_build_static := $(pfa_build_mod)
+@ENABLE_STATIC_TRUE@ pf4_build_static := $(pf4_build_mod)
+@ENABLE_STATIC_TRUE@ pf6_build_static := $(pf6_build_mod)
+endif
+
+pfx_build_mod := $(filter-out $(pfx_build_static),$(pfx_build_mod))
+pfb_build_mod := $(filter-out $(pfb_build_static),$(pfb_build_mod))
+pfa_build_mod := $(filter-out $(pfa_build_static),$(pfa_build_mod))
+pf4_build_mod := $(filter-out $(pf4_build_static),$(pf4_build_mod))
+pf6_build_mod := $(filter-out $(pf6_build_static),$(pf6_build_mod))
+
+pfx_objs := $(patsubst %,libxt_%.o,${pfx_build_static})
+pfb_objs := $(patsubst %,libebt_%.o,${pfb_build_static})
+pfa_objs := $(patsubst %,libarpt_%.o,${pfa_build_static})
+pf4_objs := $(patsubst %,libipt_%.o,${pf4_build_static})
+pf6_objs := $(patsubst %,libip6t_%.o,${pf6_build_static})
pfx_solibs := $(patsubst %,libxt_%.so,${pfx_build_mod})
pfb_solibs := $(patsubst %,libebt_%.so,${pfb_build_mod})
pfa_solibs := $(patsubst %,libarpt_%.so,${pfa_build_mod})
@@ -68,14 +88,14 @@ pfx_symlink_files := $(patsubst %,libxt_
#
targets := libext.a libext4.a libext6.a libext_ebt.a libext_arpt.a matches.man targets.man
targets_install :=
-@ENABLE_STATIC_TRUE@ libext_objs := ${pfx_objs}
-@ENABLE_STATIC_TRUE@ libext_ebt_objs := ${pfb_objs}
-@ENABLE_STATIC_TRUE@ libext_arpt_objs := ${pfa_objs}
-@ENABLE_STATIC_TRUE@ libext4_objs := ${pf4_objs}
-@ENABLE_STATIC_TRUE@ libext6_objs := ${pf6_objs}
-@ENABLE_STATIC_FALSE@ targets += ${pfx_solibs} ${pfb_solibs} ${pf4_solibs} ${pf6_solibs} ${pfa_solibs} ${pfx_symlink_files}
-@ENABLE_STATIC_FALSE@ targets_install += ${pfx_solibs} ${pfb_solibs} ${pf4_solibs} ${pf6_solibs} ${pfa_solibs}
-@ENABLE_STATIC_FALSE@ symlinks_install := ${pfx_symlink_files}
+libext_objs := ${pfx_objs}
+libext_ebt_objs := ${pfb_objs}
+libext_arpt_objs := ${pfa_objs}
+libext4_objs := ${pf4_objs}
+libext6_objs := ${pf6_objs}
+targets += ${pfx_solibs} ${pfb_solibs} ${pf4_solibs} ${pf6_solibs} ${pfa_solibs} ${pfx_symlink_files}
+targets_install := $(strip ${pfx_solibs} ${pfb_solibs} ${pf4_solibs} ${pf6_solibs} ${pfa_solibs})
+symlinks_install := ${pfx_symlink_files}
.SECONDARY:
@@ -170,11 +190,11 @@ libext4.a: initext4.o ${libext4_objs}
libext6.a: initext6.o ${libext6_objs}
${AM_VERBOSE_AR} ${AR} crs $@ $^;
-initext_func := $(addprefix xt_,${pfx_build_mod})
-initextb_func := $(addprefix ebt_,${pfb_build_mod})
-initexta_func := $(addprefix arpt_,${pfa_build_mod})
-initext4_func := $(addprefix ipt_,${pf4_build_mod})
-initext6_func := $(addprefix ip6t_,${pf6_build_mod})
+initext_func := $(addprefix xt_,${pfx_build_static})
+initextb_func := $(addprefix ebt_,${pfb_build_static})
+initexta_func := $(addprefix arpt_,${pfa_build_static})
+initext4_func := $(addprefix ipt_,${pf4_build_static})
+initext6_func := $(addprefix ip6t_,${pf6_build_static})
initexts := ext exta extb ext4 ext6
initext_depfiles = $(patsubst %,.init%.dd,${initexts})

View File

@@ -0,0 +1,100 @@
--- a/extensions/GNUmakefile.in
+++ b/extensions/GNUmakefile.in
@@ -86,7 +86,7 @@ pfx_symlink_files := $(patsubst %,libxt_
#
# Building blocks
#
-targets := libext.a libext4.a libext6.a libext_ebt.a libext_arpt.a matches.man targets.man
+targets := libiptext.so libiptext4.so libiptext6.so libiptext_ebt.so libiptext_arpt.so matches.man targets.man
targets_install :=
libext_objs := ${pfx_objs}
libext_ebt_objs := ${pfb_objs}
@@ -133,7 +133,7 @@ clean:
distclean: clean
init%.o: init%.c
- ${AM_VERBOSE_CC} ${CC} ${AM_CPPFLAGS} ${AM_DEPFLAGS} ${AM_CFLAGS} -D_INIT=$*_init ${CFLAGS} -o $@ -c $<;
+ ${AM_VERBOSE_CC} ${CC} ${AM_CPPFLAGS} ${AM_DEPFLAGS} ${AM_CFLAGS} -D_INIT=$*_init -DPIC -fPIC ${CFLAGS} -o $@ -c $<;
-include .*.d
@@ -173,22 +173,22 @@ xt_connlabel_LIBADD = @libnetfilter_conn
# handling code in the Makefiles.
#
lib%.o: ${srcdir}/lib%.c
- ${AM_VERBOSE_CC} ${CC} ${AM_CPPFLAGS} ${AM_DEPFLAGS} ${AM_CFLAGS} -DNO_SHARED_LIBS=1 -D_INIT=lib$*_init ${CFLAGS} -o $@ -c $<;
+ ${AM_VERBOSE_CC} ${CC} ${AM_CPPFLAGS} ${AM_DEPFLAGS} ${AM_CFLAGS} -DNO_SHARED_LIBS=1 -D_INIT=lib$*_init -DPIC -fPIC ${CFLAGS} -o $@ -c $<;
-libext.a: initext.o ${libext_objs}
- ${AM_VERBOSE_AR} ${AR} crs $@ $^;
+libiptext.so: initext.o ${libext_objs}
+ ${AM_VERBOSE_CCLD} ${CCLD} ${AM_LDFLAGS} -shared ${LDFLAGS} -o $@ $^ -L../libxtables/.libs -lxtables $(foreach obj,$^,${$(patsubst lib%.o,%,$(obj))_LIBADD});
-libext_ebt.a: initextb.o ${libext_ebt_objs}
- ${AM_VERBOSE_AR} ${AR} crs $@ $^;
+libiptext_ebt.so: initextb.o ${libext_ebt_objs}
+ ${AM_VERBOSE_CCLD} ${CCLD} ${AM_LDFLAGS} -shared ${LDFLAGS} -o $@ $^ -L../libxtables/.libs -lxtables $(foreach obj,$^,${$(patsubst lib%.o,%,$(obj))_LIBADD});
-libext_arpt.a: initexta.o ${libext_arpt_objs}
- ${AM_VERBOSE_AR} ${AR} crs $@ $^;
+libiptext_arpt.so: initexta.o ${libext_arpt_objs}
+ ${AM_VERBOSE_CCLD} ${CCLD} ${AM_LDFLAGS} -shared ${LDFLAGS} -o $@ $^ -L../libxtables/.libs -lxtables $(foreach obj,$^,${$(patsubst lib%.o,%,$(obj))_LIBADD});
-libext4.a: initext4.o ${libext4_objs}
- ${AM_VERBOSE_AR} ${AR} crs $@ $^;
+libiptext4.so: initext4.o ${libext4_objs}
+ ${AM_VERBOSE_CCLD} ${CCLD} ${AM_LDFLAGS} -shared ${LDFLAGS} -o $@ $^ -L../libxtables/.libs -lxtables $(foreach obj,$^,${$(patsubst lib%.o,%,$(obj))_LIBADD});
-libext6.a: initext6.o ${libext6_objs}
- ${AM_VERBOSE_AR} ${AR} crs $@ $^;
+libiptext6.so: initext6.o ${libext6_objs}
+ ${AM_VERBOSE_CCLD} ${CCLD} ${AM_LDFLAGS} -shared ${LDFLAGS} -o $@ $^ -L../libxtables/.libs -lxtables $(foreach obj,$^,${$(patsubst lib%.o,%,$(obj))_LIBADD});
initext_func := $(addprefix xt_,${pfx_build_static})
initextb_func := $(addprefix ebt_,${pfb_build_static})
--- a/iptables/Makefile.am
+++ b/iptables/Makefile.am
@@ -7,7 +7,7 @@ AM_LDFLAGS = ${regular_LDFLAGS}
BUILT_SOURCES =
common_sources = iptables-xml.c xtables-multi.h xshared.c xshared.h
-common_ldadd = ../extensions/libext.a ../libxtables/libxtables.la -lm
+common_ldadd = ../libxtables/libxtables.la -lm
common_cflags = ${AM_CFLAGS}
if ENABLE_STATIC
common_cflags += -DALL_INCLUSIVE
@@ -17,15 +17,18 @@ xtables_legacy_multi_SOURCES = ${common
iptables-restore.c iptables-save.c
xtables_legacy_multi_CFLAGS = ${common_cflags}
xtables_legacy_multi_LDADD = ${common_ldadd}
+xtables_legacy_multi_LDFLAGS = -L../extensions/ -liptext
if ENABLE_IPV4
xtables_legacy_multi_SOURCES += iptables-standalone.c iptables.c iptables-multi.h
xtables_legacy_multi_CFLAGS += -DENABLE_IPV4
-xtables_legacy_multi_LDADD += ../libiptc/libip4tc.la ../extensions/libext4.a
+xtables_legacy_multi_LDADD += ../libiptc/libip4tc.la
+xtables_legacy_multi_LDFLAGS += -liptext4
endif
if ENABLE_IPV6
xtables_legacy_multi_SOURCES += ip6tables-standalone.c ip6tables.c ip6tables-multi.h
xtables_legacy_multi_CFLAGS += -DENABLE_IPV6
-xtables_legacy_multi_LDADD += ../libiptc/libip6tc.la ../extensions/libext6.a
+xtables_legacy_multi_LDADD += ../libiptc/libip6tc.la
+xtables_legacy_multi_LDFLAGS += -liptext6
endif
# iptables using nf_tables api
@@ -33,12 +36,9 @@ if ENABLE_NFTABLES
xtables_nft_multi_SOURCES = ${common_sources} xtables-nft-multi.c
xtables_nft_multi_CFLAGS = ${common_cflags}
xtables_nft_multi_LDADD = ${common_ldadd} \
- ../extensions/libext_arpt.a \
- ../extensions/libext_ebt.a \
- ../extensions/libext4.a \
- ../extensions/libext6.a \
${libmnl_LIBS} ${libnftnl_LIBS} \
${libnetfilter_conntrack_LIBS}
+xtables_nft_multi_LDFLAGS = -L../extensions/ -liptext -liptext_arpt -liptext_ebt -liptext4 -liptext6
xtables_nft_multi_CFLAGS += -DENABLE_NFTABLES -DENABLE_IPV4 -DENABLE_IPV6
xtables_nft_multi_SOURCES += nft.c nft.h \
nft-arp.c nft-ipv4.c nft-ipv6.c \

View File

@@ -0,0 +1,95 @@
--- a/extensions/libxt_conntrack.c
+++ b/extensions/libxt_conntrack.c
@@ -1385,6 +1385,7 @@ static int conntrack3_mt6_xlate(struct x
}
static struct xtables_match conntrack_mt_reg[] = {
+#ifndef NO_LEGACY
{
.version = XTABLES_VERSION,
.name = "conntrack",
@@ -1460,6 +1461,7 @@ static struct xtables_match conntrack_mt
.alias = conntrack_print_name_alias,
.x6_options = conntrack2_mt_opts,
},
+#endif
{
.version = XTABLES_VERSION,
.name = "conntrack",
@@ -1492,6 +1494,7 @@ static struct xtables_match conntrack_mt
.x6_options = conntrack3_mt_opts,
.xlate = conntrack3_mt6_xlate,
},
+#ifndef NO_LEGACY
{
.family = NFPROTO_UNSPEC,
.name = "state",
@@ -1522,6 +1525,8 @@ static struct xtables_match conntrack_mt
.x6_parse = state_ct23_parse,
.x6_options = state_opts,
},
+#endif
+#ifndef NO_LEGACY
{
.family = NFPROTO_UNSPEC,
.name = "state",
@@ -1551,6 +1556,7 @@ static struct xtables_match conntrack_mt
.x6_parse = state_parse,
.x6_options = state_opts,
},
+#endif
};
void _init(void)
--- a/extensions/libxt_CT.c
+++ b/extensions/libxt_CT.c
@@ -363,6 +363,7 @@ static int xlate_ct1_tg(struct xt_xlate
}
static struct xtables_target ct_target_reg[] = {
+#ifndef NO_LEGACY
{
.family = NFPROTO_UNSPEC,
.name = "CT",
@@ -388,6 +389,7 @@ static struct xtables_target ct_target_r
.x6_parse = ct_parse_v1,
.x6_options = ct_opts_v1,
},
+#endif
{
.family = NFPROTO_UNSPEC,
.name = "CT",
@@ -403,6 +405,7 @@ static struct xtables_target ct_target_r
.x6_options = ct_opts_v1,
.xlate = xlate_ct1_tg,
},
+#ifndef NO_LEGACY
{
.family = NFPROTO_UNSPEC,
.name = "NOTRACK",
@@ -441,6 +444,7 @@ static struct xtables_target ct_target_r
.revision = 0,
.version = XTABLES_VERSION,
},
+#endif
};
void _init(void)
--- a/extensions/libxt_multiport.c
+++ b/extensions/libxt_multiport.c
@@ -591,6 +591,7 @@ static int multiport_xlate6_v1(struct xt
}
static struct xtables_match multiport_mt_reg[] = {
+#ifndef NO_LEGACY
{
.family = NFPROTO_IPV4,
.name = "multiport",
@@ -621,6 +622,7 @@ static struct xtables_match multiport_mt
.x6_options = multiport_opts,
.xlate = multiport_xlate6,
},
+#endif
{
.family = NFPROTO_IPV4,
.name = "multiport",

View File

@@ -0,0 +1,95 @@
--- /dev/null
+++ b/extensions/libxt_FLOWOFFLOAD.c
@@ -0,0 +1,72 @@
+#include <stdio.h>
+#include <xtables.h>
+#include <linux/netfilter/xt_FLOWOFFLOAD.h>
+
+enum {
+ O_HW,
+};
+
+static void offload_help(void)
+{
+ printf(
+"FLOWOFFLOAD target options:\n"
+" --hw Enable hardware offload\n"
+ );
+}
+
+static const struct xt_option_entry offload_opts[] = {
+ {.name = "hw", .id = O_HW, .type = XTTYPE_NONE},
+ XTOPT_TABLEEND,
+};
+
+static void offload_parse(struct xt_option_call *cb)
+{
+ struct xt_flowoffload_target_info *info = cb->data;
+
+ xtables_option_parse(cb);
+ switch (cb->entry->id) {
+ case O_HW:
+ info->flags |= XT_FLOWOFFLOAD_HW;
+ break;
+ }
+}
+
+static void offload_print(const void *ip, const struct xt_entry_target *target, int numeric)
+{
+ const struct xt_flowoffload_target_info *info =
+ (const struct xt_flowoffload_target_info *)target->data;
+
+ printf(" FLOWOFFLOAD");
+ if (info->flags & XT_FLOWOFFLOAD_HW)
+ printf(" hw");
+}
+
+static void offload_save(const void *ip, const struct xt_entry_target *target)
+{
+ const struct xt_flowoffload_target_info *info =
+ (const struct xt_flowoffload_target_info *)target->data;
+
+ if (info->flags & XT_FLOWOFFLOAD_HW)
+ printf(" --hw");
+}
+
+static struct xtables_target offload_tg_reg[] = {
+ {
+ .family = NFPROTO_UNSPEC,
+ .name = "FLOWOFFLOAD",
+ .revision = 0,
+ .version = XTABLES_VERSION,
+ .size = XT_ALIGN(sizeof(struct xt_flowoffload_target_info)),
+ .userspacesize = sizeof(struct xt_flowoffload_target_info),
+ .help = offload_help,
+ .print = offload_print,
+ .save = offload_save,
+ .x6_parse = offload_parse,
+ .x6_options = offload_opts,
+ },
+};
+
+void _init(void)
+{
+ xtables_register_targets(offload_tg_reg, ARRAY_SIZE(offload_tg_reg));
+}
--- /dev/null
+++ b/include/linux/netfilter/xt_FLOWOFFLOAD.h
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+#ifndef _XT_FLOWOFFLOAD_H
+#define _XT_FLOWOFFLOAD_H
+
+#include <linux/types.h>
+
+enum {
+ XT_FLOWOFFLOAD_HW = 1 << 0,
+
+ XT_FLOWOFFLOAD_MASK = XT_FLOWOFFLOAD_HW
+};
+
+struct xt_flowoffload_target_info {
+ __u32 flags;
+};
+
+#endif /* _XT_FLOWOFFLOAD_H */

View File

@@ -0,0 +1,75 @@
#
# Copyright (C) 2007-2011 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:=iw
PKG_VERSION:=6.9
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
PKG_SOURCE_URL:=@KERNEL/software/network/iw
PKG_HASH:=3f2db22ad41c675242b98ae3942dbf3112548c60a42ff739210f2de4e98e4894
PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
PKG_LICENSE:=GPL-2.0
PKG_CPE_ID:=cpe:/a:kernel:iw
PKG_BUILD_FLAGS:=gc-sections lto
include $(INCLUDE_DIR)/package.mk
define Package/iw
SECTION:=net
CATEGORY:=Network
TITLE:=cfg80211 interface configuration utility
URL:=http://wireless.kernel.org/en/users/Documentation/iw
DEPENDS:= +libnl-tiny
VARIANT:=tiny
endef
define Package/iw-full
$(Package/iw)
TITLE += (full version)
VARIANT:=full
PROVIDES:=iw
endef
define Build/Configure
echo "const char iw_version[] = \"$(PKG_VERSION)\";" > $(PKG_BUILD_DIR)/version.c
echo "#!/bin/sh" > $(PKG_BUILD_DIR)/version.sh
chmod +x $(PKG_BUILD_DIR)/version.sh
endef
TARGET_CPPFLAGS:= \
-I$(STAGING_DIR)/usr/include/libnl-tiny \
$(TARGET_CPPFLAGS) \
-DCONFIG_LIBNL20 \
-D_GNU_SOURCE
ifeq ($(BUILD_VARIANT),full)
TARGET_CPPFLAGS += -DIW_FULL
MAKE_FLAGS += IW_FULL=1
endif
MAKE_FLAGS += \
CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \
LDFLAGS="$(TARGET_LDFLAGS)" \
NL1FOUND="" NL2FOUND=Y \
NLLIBNAME="libnl-tiny" \
LIBS="-lm -lnl-tiny" \
V=1
define Package/iw/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/iw $(1)/usr/sbin/
endef
Package/iw-full/install=$(Package/iw/install)
$(eval $(call BuildPackage,iw))
$(eval $(call BuildPackage,iw-full))

View File

@@ -0,0 +1,98 @@
--- a/nl80211.h
+++ b/nl80211.h
@@ -2061,6 +2061,10 @@ enum nl80211_commands {
* @NL80211_ATTR_INTERFACE_COMBINATIONS: Nested attribute listing the supported
* interface combinations. In each nested item, it contains attributes
* defined in &enum nl80211_if_combination_attrs.
+ * If the wiphy uses multiple radios (@NL80211_ATTR_WIPHY_RADIOS is set),
+ * this attribute contains the interface combinations of the first radio.
+ * See @NL80211_ATTR_WIPHY_INTERFACE_COMBINATIONS for the global wiphy
+ * combinations for the sum of all radios.
* @NL80211_ATTR_SOFTWARE_IFTYPES: Nested attribute (just like
* %NL80211_ATTR_SUPPORTED_IFTYPES) containing the interface types that
* are managed in software: interfaces of these types aren't subject to
@@ -2856,6 +2860,17 @@ enum nl80211_commands {
* %NL80211_CMD_ASSOCIATE indicating the SPP A-MSDUs
* are used on this connection
*
+ * @NL80211_ATTR_WIPHY_RADIOS: Nested attribute describing physical radios
+ * belonging to this wiphy. See &enum nl80211_wiphy_radio_attrs.
+ *
+ * @NL80211_ATTR_WIPHY_INTERFACE_COMBINATIONS: Nested attribute listing the
+ * supported interface combinations for all radios combined. In each
+ * nested item, it contains attributes defined in
+ * &enum nl80211_if_combination_attrs.
+ *
+ * @NL80211_ATTR_VIF_RADIO_MASK: Bitmask of allowed radios (u32).
+ * A value of 0 means all radios.
+ *
* @NUM_NL80211_ATTR: total number of nl80211_attrs available
* @NL80211_ATTR_MAX: highest attribute number currently defined
* @__NL80211_ATTR_AFTER_LAST: internal use
@@ -3401,6 +3416,11 @@ enum nl80211_attrs {
NL80211_ATTR_ASSOC_SPP_AMSDU,
+ NL80211_ATTR_WIPHY_RADIOS,
+ NL80211_ATTR_WIPHY_INTERFACE_COMBINATIONS,
+
+ NL80211_ATTR_VIF_RADIO_MASK,
+
/* add attributes here, update the policy in nl80211.c */
__NL80211_ATTR_AFTER_LAST,
@@ -7987,4 +8007,54 @@ enum nl80211_ap_settings_flags {
NL80211_AP_SETTINGS_SA_QUERY_OFFLOAD_SUPPORT = 1 << 1,
};
+/**
+ * enum nl80211_wiphy_radio_attrs - wiphy radio attributes
+ *
+ * @__NL80211_WIPHY_RADIO_ATTR_INVALID: Invalid
+ *
+ * @NL80211_WIPHY_RADIO_ATTR_INDEX: Index of this radio (u32)
+ * @NL80211_WIPHY_RADIO_ATTR_FREQ_RANGE: Frequency range supported by this
+ * radio. Attribute may be present multiple times.
+ * @NL80211_WIPHY_RADIO_ATTR_INTERFACE_COMBINATION: Supported interface
+ * combination for this radio. Attribute may be present multiple times
+ * and contains attributes defined in &enum nl80211_if_combination_attrs.
+ *
+ * @__NL80211_WIPHY_RADIO_ATTR_LAST: Internal
+ * @NL80211_WIPHY_RADIO_ATTR_MAX: Highest attribute
+ */
+enum nl80211_wiphy_radio_attrs {
+ __NL80211_WIPHY_RADIO_ATTR_INVALID,
+
+ NL80211_WIPHY_RADIO_ATTR_INDEX,
+ NL80211_WIPHY_RADIO_ATTR_FREQ_RANGE,
+ NL80211_WIPHY_RADIO_ATTR_INTERFACE_COMBINATION,
+
+ /* keep last */
+ __NL80211_WIPHY_RADIO_ATTR_LAST,
+ NL80211_WIPHY_RADIO_ATTR_MAX = __NL80211_WIPHY_RADIO_ATTR_LAST - 1,
+};
+
+/**
+ * enum nl80211_wiphy_radio_freq_range - wiphy radio frequency range
+ *
+ * @__NL80211_WIPHY_RADIO_FREQ_ATTR_INVALID: Invalid
+ *
+ * @NL80211_WIPHY_RADIO_FREQ_ATTR_START: Frequency range start (u32).
+ * The unit is kHz.
+ * @NL80211_WIPHY_RADIO_FREQ_ATTR_END: Frequency range end (u32).
+ * The unit is kHz.
+ *
+ * @__NL80211_WIPHY_RADIO_FREQ_ATTR_LAST: Internal
+ * @NL80211_WIPHY_RADIO_FREQ_ATTR_MAX: Highest attribute
+ */
+enum nl80211_wiphy_radio_freq_range {
+ __NL80211_WIPHY_RADIO_FREQ_ATTR_INVALID,
+
+ NL80211_WIPHY_RADIO_FREQ_ATTR_START,
+ NL80211_WIPHY_RADIO_FREQ_ATTR_END,
+
+ __NL80211_WIPHY_RADIO_FREQ_ATTR_LAST,
+ NL80211_WIPHY_RADIO_FREQ_ATTR_MAX = __NL80211_WIPHY_RADIO_FREQ_ATTR_LAST - 1,
+};
+
#endif /* __LINUX_NL80211_H */

View File

@@ -0,0 +1,68 @@
From 1f3706d10812d70adefe32fe0d7d3a3ec25374f0 Mon Sep 17 00:00:00 2001
From: Hauke Mehrtens <hauke@hauke-m.de>
Date: Sun, 21 Nov 2021 00:02:57 +0100
Subject: Revert "iw: allow specifying CFLAGS/LIBS externally"
This reverts commit 1325244b77d56fd7a16d1e35fdae0efc151920b1.
The OpenWrt build system provides the CFLAGS and LIBS names from the
package Makefile to overwrite them for libnl-tiny. This is not possible
after this upstream change which we revert here any more
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
Makefile | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
--- a/Makefile
+++ b/Makefile
@@ -46,30 +46,30 @@ NLLIBNAME = libnl-1
endif
ifeq ($(NL2FOUND),Y)
-override CFLAGS += -DCONFIG_LIBNL20
-override LIBS += -lnl-genl
+CFLAGS += -DCONFIG_LIBNL20
+LIBS += -lnl-genl
NLLIBNAME = libnl-2.0
endif
ifeq ($(NL3xFOUND),Y)
# libnl 3.2 might be found as 3.2 and 3.0
NL3FOUND = N
-override CFLAGS += -DCONFIG_LIBNL30
-override LIBS += -lnl-genl-3
+CFLAGS += -DCONFIG_LIBNL30
+LIBS += -lnl-genl-3
NLLIBNAME = libnl-3.0
endif
ifeq ($(NL3FOUND),Y)
-override CFLAGS += -DCONFIG_LIBNL30
-override LIBS += -lnl-genl
+CFLAGS += -DCONFIG_LIBNL30
+LIBS += -lnl-genl
NLLIBNAME = libnl-3.0
endif
# nl-3.1 has a broken libnl-gnl-3.1.pc file
# as show by pkg-config --debug --libs --cflags --exact-version=3.1 libnl-genl-3.1;echo $?
ifeq ($(NL31FOUND),Y)
-override CFLAGS += -DCONFIG_LIBNL30
-override LIBS += -lnl-genl
+CFLAGS += -DCONFIG_LIBNL30
+LIBS += -lnl-genl
NLLIBNAME = libnl-3.1
endif
@@ -77,8 +77,8 @@ ifeq ($(NLLIBNAME),)
$(error Cannot find development files for any supported version of libnl)
endif
-override LIBS += $(shell $(PKG_CONFIG) --libs $(NLLIBNAME))
-override CFLAGS += $(shell $(PKG_CONFIG) --cflags $(NLLIBNAME))
+LIBS += $(shell $(PKG_CONFIG) --libs $(NLLIBNAME))
+CFLAGS += $(shell $(PKG_CONFIG) --cflags $(NLLIBNAME))
endif # NO_PKG_CONFIG
ifeq ($(V),1)

View File

@@ -0,0 +1,12 @@
--- a/survey.c
+++ b/survey.c
@@ -60,6 +60,9 @@ static int print_survey_handler(struct n
if (sinfo[NL80211_SURVEY_INFO_CHANNEL_TIME_RX])
printf("\tchannel receive time:\t\t%llu ms\n",
(unsigned long long)nla_get_u64(sinfo[NL80211_SURVEY_INFO_CHANNEL_TIME_RX]));
+ if (sinfo[NL80211_SURVEY_INFO_TIME_BSS_RX])
+ printf("\tchannel BSS receive time:\t%llu ms\n",
+ (unsigned long long)nla_get_u64(sinfo[NL80211_SURVEY_INFO_TIME_BSS_RX]));
if (sinfo[NL80211_SURVEY_INFO_CHANNEL_TIME_TX])
printf("\tchannel transmit time:\t\t%llu ms\n",
(unsigned long long)nla_get_u64(sinfo[NL80211_SURVEY_INFO_CHANNEL_TIME_TX]));

View File

@@ -0,0 +1,371 @@
--- a/event.c
+++ b/event.c
@@ -973,6 +973,7 @@ static int print_event(struct nl_msg *ms
}
switch (gnlh->cmd) {
+#ifdef IW_FULL
case NL80211_CMD_NEW_WIPHY:
printf("renamed to %s\n", nla_get_string(tb[NL80211_ATTR_WIPHY_NAME]));
break;
@@ -1008,6 +1009,7 @@ static int print_event(struct nl_msg *ms
case NL80211_CMD_SCHED_SCAN_RESULTS:
printf("got scheduled scan results\n");
break;
+#endif
case NL80211_CMD_WIPHY_REG_CHANGE:
case NL80211_CMD_REG_CHANGE:
if (gnlh->cmd == NL80211_CMD_WIPHY_REG_CHANGE)
@@ -1090,6 +1092,7 @@ static int print_event(struct nl_msg *ms
mac_addr_n2a(macbuf, nla_data(tb[NL80211_ATTR_MAC]));
printf("del station %s\n", macbuf);
break;
+#ifdef IW_FULL
case NL80211_CMD_JOIN_IBSS:
mac_addr_n2a(macbuf, nla_data(tb[NL80211_ATTR_MAC]));
printf("IBSS %s joined\n", macbuf);
@@ -1297,9 +1300,9 @@ static int print_event(struct nl_msg *ms
case NL80211_CMD_ASSOC_COMEBACK: /* 147 */
parse_assoc_comeback(tb, gnlh->cmd);
break;
+#endif
default:
- printf("unknown event %d (%s)\n",
- gnlh->cmd, command_name(gnlh->cmd));
+ printf("unknown event %d\n", gnlh->cmd);
break;
}
--- a/info.c
+++ b/info.c
@@ -446,6 +446,7 @@ next:
}
}
+#ifdef IW_FULL
if (tb_band[NL80211_BAND_ATTR_RATES]) {
printf("\t\tBitrates (non-HT):\n");
nla_for_each_nested(nl_rate, tb_band[NL80211_BAND_ATTR_RATES], rem_rate) {
@@ -462,6 +463,7 @@ next:
printf("\n");
}
}
+#endif
}
}
@@ -527,6 +529,7 @@ next:
printf("\tCoverage class: %d (up to %dm)\n", coverage, 450 * coverage);
}
+#ifdef IW_FULL
if (tb_msg[NL80211_ATTR_CIPHER_SUITES]) {
int num = nla_len(tb_msg[NL80211_ATTR_CIPHER_SUITES]) / sizeof(__u32);
int i;
@@ -538,6 +541,7 @@ next:
cipher_name(ciphers[i]));
}
}
+#endif
if (tb_msg[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_TX] &&
tb_msg[NL80211_ATTR_WIPHY_ANTENNA_AVAIL_RX])
@@ -555,9 +559,11 @@ next:
print_iftype_list("\tSupported interface modes", "\t\t",
tb_msg[NL80211_ATTR_SUPPORTED_IFTYPES]);
+#ifdef IW_FULL
if (tb_msg[NL80211_ATTR_SOFTWARE_IFTYPES])
print_iftype_list("\tsoftware interface modes (can always be added)",
"\t\t", tb_msg[NL80211_ATTR_SOFTWARE_IFTYPES]);
+#endif
if (tb_msg[NL80211_ATTR_INTERFACE_COMBINATIONS]) {
struct nlattr *nl_combi;
@@ -647,6 +653,7 @@ broken_combination:
printf("\tinterface combinations are not supported\n");
}
+#ifdef IW_FULL
if (tb_msg[NL80211_ATTR_SUPPORTED_COMMANDS]) {
printf("\tSupported commands:\n");
nla_for_each_nested(nl_cmd, tb_msg[NL80211_ATTR_SUPPORTED_COMMANDS], rem_cmd)
@@ -744,6 +751,7 @@ broken_combination:
printf("\t\t * wake up on TCP connection\n");
}
}
+#endif
if (tb_msg[NL80211_ATTR_ROAM_SUPPORT])
printf("\tDevice supports roaming.\n");
@@ -782,6 +790,7 @@ broken_combination:
}
}
+#ifdef IW_FULL
if (tb_msg[NL80211_ATTR_FEATURE_FLAGS]) {
unsigned int features = nla_get_u32(tb_msg[NL80211_ATTR_FEATURE_FLAGS]);
@@ -846,6 +855,7 @@ broken_combination:
if (features & NL80211_FEATURE_ND_RANDOM_MAC_ADDR)
printf("\tDevice supports randomizing MAC-addr in net-detect scans.\n");
}
+#endif
if (tb_msg[NL80211_ATTR_TDLS_SUPPORT])
printf("\tDevice supports T-DLS.\n");
@@ -914,6 +924,7 @@ TOPLEVEL(list, NULL, NL80211_CMD_GET_WIP
"List all wireless devices and their capabilities.");
TOPLEVEL(phy, NULL, NL80211_CMD_GET_WIPHY, NLM_F_DUMP, CIB_NONE, handle_info, NULL);
+#ifdef IW_FULL
static int handle_commands(struct nl80211_state *state, struct nl_msg *msg,
int argc, char **argv, enum id_input id)
{
@@ -925,6 +936,7 @@ static int handle_commands(struct nl8021
}
TOPLEVEL(commands, NULL, NL80211_CMD_GET_WIPHY, 0, CIB_NONE, handle_commands,
"list all known commands and their decimal & hex value");
+#endif
static int print_feature_handler(struct nl_msg *msg, void *arg)
{
--- a/scan.c
+++ b/scan.c
@@ -1308,6 +1308,9 @@ static void print_ht_op(const uint8_t ty
printf("\t\t * secondary channel offset: %s\n",
ht_secondary_offset[data[1] & 0x3]);
printf("\t\t * STA channel width: %s\n", sta_chan_width[(data[1] & 0x4)>>2]);
+#ifndef IW_FULL
+ return;
+#endif
printf("\t\t * RIFS: %d\n", (data[1] & 0x8)>>3);
printf("\t\t * HT protection: %s\n", protection[data[2] & 0x3]);
printf("\t\t * non-GF present: %d\n", (data[2] & 0x4) >> 2);
@@ -1818,30 +1821,31 @@ static void print_ie(const struct ie_pri
static const struct ie_print ieprinters[] = {
[0] = { "SSID", print_ssid, 0, 32,
BIT(PRINT_SCAN) | BIT(PRINT_LINK) | BIT(PRINT_LINK_MLO_MLD), },
+ [11] = { "BSS Load", print_bss_load, 5, 5, BIT(PRINT_SCAN), },
+ [45] = { "HT capabilities", print_ht_capa, 26, 26, BIT(PRINT_SCAN), },
+ [48] = { "RSN", print_rsn, 2, 255, BIT(PRINT_SCAN), },
+ [61] = { "HT operation", print_ht_op, 22, 22, BIT(PRINT_SCAN), },
+ [62] = { "Secondary Channel Offset", print_secchan_offs, 1, 1, BIT(PRINT_SCAN), },
+ [114] = { "MESH ID", print_ssid, 0, 32, BIT(PRINT_SCAN) | BIT(PRINT_LINK), },
+ [191] = { "VHT capabilities", print_vht_capa, 12, 255, BIT(PRINT_SCAN), },
+ [192] = { "VHT operation", print_vht_oper, 5, 255, BIT(PRINT_SCAN), },
+#ifdef IW_FULL
[1] = { "Supported rates", print_supprates, 0, 255, BIT(PRINT_SCAN), },
[3] = { "DS Parameter set", print_ds, 1, 1, BIT(PRINT_SCAN), },
[5] = { "TIM", print_tim, 4, 255, BIT(PRINT_SCAN), },
[6] = { "IBSS ATIM window", print_ibssatim, 2, 2, BIT(PRINT_SCAN), },
[7] = { "Country", print_country, 3, 255, BIT(PRINT_SCAN), },
- [11] = { "BSS Load", print_bss_load, 5, 5, BIT(PRINT_SCAN), },
[32] = { "Power constraint", print_powerconstraint, 1, 1, BIT(PRINT_SCAN), },
[35] = { "TPC report", print_tpcreport, 2, 2, BIT(PRINT_SCAN), },
[42] = { "ERP", print_erp, 1, 255, BIT(PRINT_SCAN), },
- [45] = { "HT capabilities", print_ht_capa, 26, 26, BIT(PRINT_SCAN), },
[47] = { "ERP D4.0", print_erp, 1, 255, BIT(PRINT_SCAN), },
[51] = { "AP Channel Report", print_ap_channel_report, 1, 255, BIT(PRINT_SCAN), },
[59] = { "Supported operating classes", print_supp_op_classes, 1, 255, BIT(PRINT_SCAN), },
[66] = { "Measurement Pilot Transmission", print_measurement_pilot_tx, 1, 255, BIT(PRINT_SCAN), },
[74] = { "Overlapping BSS scan params", print_obss_scan_params, 14, 255, BIT(PRINT_SCAN), },
- [61] = { "HT operation", print_ht_op, 22, 22, BIT(PRINT_SCAN), },
- [62] = { "Secondary Channel Offset", print_secchan_offs, 1, 1, BIT(PRINT_SCAN), },
- [191] = { "VHT capabilities", print_vht_capa, 12, 255, BIT(PRINT_SCAN), },
- [192] = { "VHT operation", print_vht_oper, 5, 255, BIT(PRINT_SCAN), },
- [48] = { "RSN", print_rsn, 2, 255, BIT(PRINT_SCAN), },
[50] = { "Extended supported rates", print_supprates, 0, 255, BIT(PRINT_SCAN), },
[70] = { "RM enabled capabilities", print_rm_enabled_capabilities, 5, 5, BIT(PRINT_SCAN), },
[113] = { "MESH Configuration", print_mesh_conf, 7, 7, BIT(PRINT_SCAN), },
- [114] = { "MESH ID", print_ssid, 0, 32, BIT(PRINT_SCAN) | BIT(PRINT_LINK), },
[127] = { "Extended capabilities", print_capabilities, 0, 255, BIT(PRINT_SCAN), },
[107] = { "802.11u Interworking", print_interworking, 0, 255, BIT(PRINT_SCAN), },
[108] = { "802.11u Advertisement", print_11u_advert, 0, 255, BIT(PRINT_SCAN), },
@@ -1850,6 +1854,7 @@ static const struct ie_print ieprinters[
[214] = { "Short beacon interval", print_short_beacon_int, 2, 2, BIT(PRINT_SCAN), },
[217] = { "S1G capabilities", print_s1g_capa, 15, 15, BIT(PRINT_SCAN), },
[232] = { "S1G operation", print_s1g_oper, 6, 6, BIT(PRINT_SCAN), },
+#endif
};
static void print_wifi_wpa(const uint8_t type, uint8_t len, const uint8_t *data,
@@ -2185,8 +2190,10 @@ static void print_wifi_wps(const uint8_t
static const struct ie_print wifiprinters[] = {
[1] = { "WPA", print_wifi_wpa, 2, 255, BIT(PRINT_SCAN), },
+#ifdef IW_FULL
[2] = { "WMM", print_wifi_wmm, 1, 255, BIT(PRINT_SCAN), },
[4] = { "WPS", print_wifi_wps, 0, 255, BIT(PRINT_SCAN), },
+#endif
};
static inline void print_p2p(const uint8_t type, uint8_t len,
@@ -2349,6 +2356,10 @@ static void print_vendor(unsigned char l
return;
}
+#ifdef IW_FULL
+ return;
+#endif
+
if (len >= 4 && memcmp(data, wfa_oui, 3) == 0) {
if (data[3] < ARRAY_SIZE(wfa_printers) &&
wfa_printers[data[3]].name &&
@@ -2483,6 +2494,7 @@ static void print_capa_non_dmg(__u16 cap
printf(" ESS");
if (capa & WLAN_CAPABILITY_IBSS)
printf(" IBSS");
+#ifdef IW_FULL
if (capa & WLAN_CAPABILITY_CF_POLLABLE)
printf(" CfPollable");
if (capa & WLAN_CAPABILITY_CF_POLL_REQUEST)
@@ -2511,6 +2523,7 @@ static void print_capa_non_dmg(__u16 cap
printf(" DelayedBACK");
if (capa & WLAN_CAPABILITY_IMM_BACK)
printf(" ImmediateBACK");
+#endif
}
static int print_bss_handler(struct nl_msg *msg, void *arg)
@@ -2601,8 +2614,10 @@ static int print_bss_handler(struct nl_m
else
printf("\tfreq: %d\n", freq);
+#ifdef IW_FULL
if (freq > 45000)
is_dmg = true;
+#endif
}
if (bss[NL80211_BSS_BEACON_INTERVAL])
printf("\tbeacon interval: %d TUs\n",
@@ -2796,6 +2811,7 @@ static int handle_stop_sched_scan(struct
return 0;
}
+#ifdef IW_FULL
COMMAND(scan, sched_start,
SCHED_SCAN_OPTIONS,
NL80211_CMD_START_SCHED_SCAN, 0, CIB_NETDEV, handle_start_sched_scan,
@@ -2806,3 +2822,4 @@ COMMAND(scan, sched_start,
COMMAND(scan, sched_stop, "",
NL80211_CMD_STOP_SCHED_SCAN, 0, CIB_NETDEV, handle_stop_sched_scan,
"Stop an ongoing scheduled scan.");
+#endif
--- a/util.c
+++ b/util.c
@@ -153,6 +153,7 @@ static const char *commands[NL80211_CMD_
static char cmdbuf[100];
+#ifdef IW_FULL
const char *command_name(enum nl80211_commands cmd)
{
if (cmd <= NL80211_CMD_MAX && commands[cmd])
@@ -160,6 +161,7 @@ const char *command_name(enum nl80211_co
sprintf(cmdbuf, "Unknown command (%d)", cmd);
return cmdbuf;
}
+#endif
int ieee80211_channel_to_frequency(int chan, enum nl80211_band band)
{
@@ -313,6 +315,9 @@ int parse_keys(struct nl_msg *msg, char
char keybuf[13];
int pos = 0;
+#ifndef IW_FULL
+ return 1;
+#endif
if (!*argc)
return 1;
--- a/Makefile
+++ b/Makefile
@@ -24,6 +24,12 @@ _OBJS := $(sort $(patsubst %.c,%.o,$(wil
VERSION_OBJS := $(filter-out version.o, $(_OBJS))
OBJS := $(VERSION_OBJS) version.o
+OBJS_FULL = ocb offch cqm wowlan coalesce roc p2p vendor mgmt ap sha256 nan bloom measurements ftm
+ifdef IW_FULL
+ CFLAGS += -DIW_FULL
+else
+ OBJS:=$(filter-out $(patsubst %,%.o,$(OBJS_FULL)),$(OBJS))
+endif
ALL = iw
ifeq ($(NO_PKG_CONFIG),)
--- a/station.c
+++ b/station.c
@@ -801,10 +801,12 @@ static int handle_station_set_plink(stru
nla_put_failure:
return -ENOBUFS;
}
+#ifdef IW_FULL
COMMAND_ALIAS(station, set, "<MAC address> plink_action <open|block>",
NL80211_CMD_SET_STATION, 0, CIB_NETDEV, handle_station_set_plink,
"Set mesh peer link action for this station (peer).",
select_station_cmd, station_set_plink);
+#endif
static int handle_station_set_vlan(struct nl80211_state *state,
struct nl_msg *msg,
@@ -899,11 +901,13 @@ static int handle_station_set_mesh_power
nla_put_failure:
return -ENOBUFS;
}
+#ifdef IW_FULL
COMMAND_ALIAS(station, set, "<MAC address> mesh_power_mode "
"<active|light|deep>", NL80211_CMD_SET_STATION, 0, CIB_NETDEV,
handle_station_set_mesh_power_mode,
"Set link-specific mesh power mode for this station",
select_station_cmd, station_set_mesh_power_mode);
+#endif
static int handle_station_set_airtime_weight(struct nl80211_state *state,
struct nl_msg *msg,
--- a/interface.c
+++ b/interface.c
@@ -668,9 +668,11 @@ static int handle_interface_wds_peer(str
nla_put_failure:
return -ENOBUFS;
}
+#ifdef IW_FULL
COMMAND(set, peer, "<MAC address>",
NL80211_CMD_SET_WDS_PEER, 0, CIB_NETDEV, handle_interface_wds_peer,
"Set interface WDS peer.");
+#endif
static int set_mcast_rate(struct nl80211_state *state,
struct nl_msg *msg,
@@ -760,6 +762,7 @@ static int handle_chan(struct nl80211_st
return handle_chanfreq(state, msg, true, argc, argv, id);
}
+#ifdef IW_FULL
SECTION(switch);
COMMAND(switch, freq,
"<freq> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz] [beacons <count>] [block-tx]\n"
@@ -1031,3 +1034,4 @@ COMMAND(set, tidconf, "[peer <MAC addres
" $ iw dev wlan0 set tidconf peer xx:xx:xx:xx:xx:xx tids 0x2 bitrates auto\n"
" $ iw dev wlan0 set tidconf peer xx:xx:xx:xx:xx:xx tids 0x2 bitrates limit vht-mcs-5 4:9\n"
);
+#endif
--- a/phy.c
+++ b/phy.c
@@ -403,6 +403,7 @@ err_out:
free(cac_trigger_argv);
return err;
}
+#ifdef IW_FULL
TOPLEVEL(cac, "channel <channel> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz]\n"
"freq <freq> [NOHT|HT20|HT40+|HT40-|5MHz|10MHz|80MHz]\n"
"freq <control freq> [5|10|20|40|80|80+80|160] [<center1_freq> [<center2_freq>]]",
@@ -422,6 +423,7 @@ COMMAND(cac, background,
NL80211_CMD_RADAR_DETECT, 0, CIB_NETDEV, handle_cac_background,
"Start background channel availability check (CAC) looking to look for\n"
"radars on the given channel.");
+#endif
static int handle_fragmentation(struct nl80211_state *state,
struct nl_msg *msg,

View File

@@ -0,0 +1,252 @@
--- a/info.c
+++ b/info.c
@@ -295,6 +295,151 @@ static void print_pmsr_capabilities(stru
}
}
+static void print_interface_combinations(struct nlattr *ifcomb, bool radio)
+{
+ const char *indent = radio ? "\t" : "";
+ struct nlattr *nl_combi;
+ bool have_combinations = false;
+ int rem;
+
+ nla_for_each_nested(nl_combi, ifcomb, rem) {
+ static struct nla_policy iface_combination_policy[NUM_NL80211_IFACE_COMB] = {
+ [NL80211_IFACE_COMB_LIMITS] = { .type = NLA_NESTED },
+ [NL80211_IFACE_COMB_MAXNUM] = { .type = NLA_U32 },
+ [NL80211_IFACE_COMB_STA_AP_BI_MATCH] = { .type = NLA_FLAG },
+ [NL80211_IFACE_COMB_NUM_CHANNELS] = { .type = NLA_U32 },
+ [NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS] = { .type = NLA_U32 },
+ };
+ struct nlattr *tb_comb[NUM_NL80211_IFACE_COMB];
+ static struct nla_policy iface_limit_policy[NUM_NL80211_IFACE_LIMIT] = {
+ [NL80211_IFACE_LIMIT_TYPES] = { .type = NLA_NESTED },
+ [NL80211_IFACE_LIMIT_MAX] = { .type = NLA_U32 },
+ };
+ struct nlattr *tb_limit[NUM_NL80211_IFACE_LIMIT];
+ struct nlattr *nl_limit;
+ int err, rem_limit;
+ bool comma = false;
+
+ if (radio && nla_type(nl_combi) !=
+ NL80211_WIPHY_RADIO_ATTR_INTERFACE_COMBINATION)
+ continue;
+
+ if (!have_combinations) {
+ printf("\t%svalid interface combinations:\n", indent);
+ have_combinations = true;
+ }
+
+ printf("\t\t%s * ", indent);
+
+ err = nla_parse_nested(tb_comb, MAX_NL80211_IFACE_COMB,
+ nl_combi, iface_combination_policy);
+ if (err || !tb_comb[NL80211_IFACE_COMB_LIMITS] ||
+ !tb_comb[NL80211_IFACE_COMB_MAXNUM] ||
+ !tb_comb[NL80211_IFACE_COMB_NUM_CHANNELS]) {
+ printf(" <failed to parse>\n");
+ goto broken_combination;
+ }
+
+ nla_for_each_nested(nl_limit, tb_comb[NL80211_IFACE_COMB_LIMITS], rem_limit) {
+ err = nla_parse_nested(tb_limit, MAX_NL80211_IFACE_LIMIT,
+ nl_limit, iface_limit_policy);
+ if (err || !tb_limit[NL80211_IFACE_LIMIT_TYPES]) {
+ printf("<failed to parse>\n");
+ goto broken_combination;
+ }
+
+ if (comma)
+ printf(", ");
+ comma = true;
+ printf("#{ ");
+ print_iftype_line(tb_limit[NL80211_IFACE_LIMIT_TYPES]);
+ printf(" } <= %u", nla_get_u32(tb_limit[NL80211_IFACE_LIMIT_MAX]));
+ }
+ printf(",\n\t\t%s ", indent);
+
+ printf("total <= %d, #channels <= %d%s",
+ nla_get_u32(tb_comb[NL80211_IFACE_COMB_MAXNUM]),
+ nla_get_u32(tb_comb[NL80211_IFACE_COMB_NUM_CHANNELS]),
+ tb_comb[NL80211_IFACE_COMB_STA_AP_BI_MATCH] ?
+ ", STA/AP BI must match" : "");
+ if (tb_comb[NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS]) {
+ unsigned long widths = nla_get_u32(tb_comb[NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS]);
+
+ if (widths) {
+ int width;
+ bool first = true;
+
+ printf(", radar detect widths: {");
+ for (width = 0; width < 32; width++)
+ if (widths & (1 << width)) {
+ printf("%s %s",
+ first ? "":",",
+ channel_width_name(width));
+ first = false;
+ }
+ printf(" }\n");
+ }
+ }
+ printf("\n");
+broken_combination:
+ ;
+ }
+
+ if (!have_combinations)
+ printf("\t%sinterface combinations are not supported\n", indent);
+}
+
+static void print_radio_freq(struct nlattr *freqs)
+{
+ struct nlattr *freq;
+ int rem;
+
+ nla_for_each_nested(freq, freqs, rem) {
+ static struct nla_policy freq_policy[NL80211_WIPHY_RADIO_FREQ_ATTR_MAX + 1] = {
+ [NL80211_WIPHY_RADIO_FREQ_ATTR_START] = { .type = NLA_U32 },
+ [NL80211_WIPHY_RADIO_FREQ_ATTR_END] = { .type = NLA_U32 },
+ };
+ struct nlattr *tb[NL80211_WIPHY_RADIO_FREQ_ATTR_MAX + 1];
+ uint32_t start, end;
+
+ if (nla_type(freq) != NL80211_WIPHY_RADIO_ATTR_FREQ_RANGE)
+ continue;
+
+ if (nla_parse_nested(tb, NL80211_WIPHY_RADIO_ATTR_MAX + 1,
+ freq, freq_policy) ||
+ !tb[NL80211_WIPHY_RADIO_FREQ_ATTR_START] ||
+ !tb[NL80211_WIPHY_RADIO_FREQ_ATTR_END])
+ continue;
+
+ start = nla_get_u32(tb[NL80211_WIPHY_RADIO_FREQ_ATTR_START]);
+ end = nla_get_u32(tb[NL80211_WIPHY_RADIO_FREQ_ATTR_END]);
+
+ printf("\t\tfreq range: %.1f MHz - %.1f MHz\n", (float)start / 1000, (float)end / 1000);
+ }
+}
+
+static void print_radios(struct nlattr *radios)
+{
+ struct nlattr *radio;
+ int rem, idx = 0;
+
+ nla_for_each_nested(radio, radios, rem) {
+ static struct nla_policy radio_policy[NL80211_WIPHY_RADIO_ATTR_MAX + 1] = {
+ [NL80211_WIPHY_RADIO_ATTR_INDEX] = { .type = NLA_U32 },
+ };
+ struct nlattr *tb[NL80211_WIPHY_RADIO_ATTR_MAX + 1];
+
+ if (nla_parse_nested(tb, NL80211_WIPHY_RADIO_ATTR_MAX + 1,
+ radio, radio_policy) ||
+ !tb[NL80211_WIPHY_RADIO_ATTR_INDEX])
+ continue;
+
+ printf("\twiphy radio %d:\n", nla_get_u32(tb[NL80211_WIPHY_RADIO_ATTR_INDEX]));
+ print_radio_freq(radio);
+ print_interface_combinations(radio, true);
+ }
+}
+
static int print_phy_handler(struct nl_msg *msg, void *arg)
{
struct nlattr *tb_msg[NL80211_ATTR_MAX + 1];
@@ -565,93 +710,11 @@ next:
"\t\t", tb_msg[NL80211_ATTR_SOFTWARE_IFTYPES]);
#endif
- if (tb_msg[NL80211_ATTR_INTERFACE_COMBINATIONS]) {
- struct nlattr *nl_combi;
- int rem_combi;
- bool have_combinations = false;
-
- nla_for_each_nested(nl_combi, tb_msg[NL80211_ATTR_INTERFACE_COMBINATIONS], rem_combi) {
- static struct nla_policy iface_combination_policy[NUM_NL80211_IFACE_COMB] = {
- [NL80211_IFACE_COMB_LIMITS] = { .type = NLA_NESTED },
- [NL80211_IFACE_COMB_MAXNUM] = { .type = NLA_U32 },
- [NL80211_IFACE_COMB_STA_AP_BI_MATCH] = { .type = NLA_FLAG },
- [NL80211_IFACE_COMB_NUM_CHANNELS] = { .type = NLA_U32 },
- [NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS] = { .type = NLA_U32 },
- };
- struct nlattr *tb_comb[NUM_NL80211_IFACE_COMB];
- static struct nla_policy iface_limit_policy[NUM_NL80211_IFACE_LIMIT] = {
- [NL80211_IFACE_LIMIT_TYPES] = { .type = NLA_NESTED },
- [NL80211_IFACE_LIMIT_MAX] = { .type = NLA_U32 },
- };
- struct nlattr *tb_limit[NUM_NL80211_IFACE_LIMIT];
- struct nlattr *nl_limit;
- int err, rem_limit;
- bool comma = false;
-
- if (!have_combinations) {
- printf("\tvalid interface combinations:\n");
- have_combinations = true;
- }
-
- printf("\t\t * ");
+ if (tb_msg[NL80211_ATTR_INTERFACE_COMBINATIONS])
+ print_interface_combinations(tb_msg[NL80211_ATTR_INTERFACE_COMBINATIONS], false);
- err = nla_parse_nested(tb_comb, MAX_NL80211_IFACE_COMB,
- nl_combi, iface_combination_policy);
- if (err || !tb_comb[NL80211_IFACE_COMB_LIMITS] ||
- !tb_comb[NL80211_IFACE_COMB_MAXNUM] ||
- !tb_comb[NL80211_IFACE_COMB_NUM_CHANNELS]) {
- printf(" <failed to parse>\n");
- goto broken_combination;
- }
-
- nla_for_each_nested(nl_limit, tb_comb[NL80211_IFACE_COMB_LIMITS], rem_limit) {
- err = nla_parse_nested(tb_limit, MAX_NL80211_IFACE_LIMIT,
- nl_limit, iface_limit_policy);
- if (err || !tb_limit[NL80211_IFACE_LIMIT_TYPES]) {
- printf("<failed to parse>\n");
- goto broken_combination;
- }
-
- if (comma)
- printf(", ");
- comma = true;
- printf("#{ ");
- print_iftype_line(tb_limit[NL80211_IFACE_LIMIT_TYPES]);
- printf(" } <= %u", nla_get_u32(tb_limit[NL80211_IFACE_LIMIT_MAX]));
- }
- printf(",\n\t\t ");
-
- printf("total <= %d, #channels <= %d%s",
- nla_get_u32(tb_comb[NL80211_IFACE_COMB_MAXNUM]),
- nla_get_u32(tb_comb[NL80211_IFACE_COMB_NUM_CHANNELS]),
- tb_comb[NL80211_IFACE_COMB_STA_AP_BI_MATCH] ?
- ", STA/AP BI must match" : "");
- if (tb_comb[NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS]) {
- unsigned long widths = nla_get_u32(tb_comb[NL80211_IFACE_COMB_RADAR_DETECT_WIDTHS]);
-
- if (widths) {
- int width;
- bool first = true;
-
- printf(", radar detect widths: {");
- for (width = 0; width < 32; width++)
- if (widths & (1 << width)) {
- printf("%s %s",
- first ? "":",",
- channel_width_name(width));
- first = false;
- }
- printf(" }\n");
- }
- }
- printf("\n");
-broken_combination:
- ;
- }
-
- if (!have_combinations)
- printf("\tinterface combinations are not supported\n");
- }
+ if (tb_msg[NL80211_ATTR_WIPHY_RADIOS])
+ print_radios(tb_msg[NL80211_ATTR_WIPHY_RADIOS]);
#ifdef IW_FULL
if (tb_msg[NL80211_ATTR_SUPPORTED_COMMANDS]) {

View File

@@ -0,0 +1,99 @@
--- a/interface.c
+++ b/interface.c
@@ -226,6 +226,43 @@ nla_put_failure:
return 1;
}
+static int parse_radio_list(char *str, struct nl_msg *msg)
+{
+ unsigned int mask = 0;
+ unsigned long id;
+ char *end;
+
+ if (!str)
+ return 1;
+
+ if (!strcmp(str, "all"))
+ goto out;
+
+ while (1) {
+ if (!*str)
+ return 1;
+
+ id = strtoul(str, &end, 0);
+ if (id > 31)
+ return 1;
+
+ mask |= 1 << id;
+ if (!*end)
+ break;
+
+ if (end == str || *end != ',')
+ return 1;
+
+ str = end + 1;
+ }
+
+out:
+ NLA_PUT_U32(msg, NL80211_ATTR_VIF_RADIO_MASK, mask);
+ return 0;
+nla_put_failure:
+ return 1;
+}
+
static int handle_interface_add(struct nl80211_state *state,
struct nl_msg *msg,
int argc, char **argv,
@@ -287,6 +324,15 @@ try_another:
fprintf(stderr, "flags error\n");
return 2;
}
+ } else if (strcmp(argv[0], "radios") == 0) {
+ argc--;
+ argv++;
+ if (parse_radio_list(argv[0], msg)) {
+ fprintf(stderr, "Invalid radio list\n");
+ return 2;
+ }
+ argc--;
+ argv++;
} else {
return 1;
}
@@ -306,14 +352,14 @@ try_another:
nla_put_failure:
return -ENOBUFS;
}
-COMMAND(interface, add, "<name> type <type> [mesh_id <meshid>] [4addr on|off] [flags <flag>*] [addr <mac-addr>]",
+COMMAND(interface, add, "<name> type <type> [mesh_id <meshid>] [4addr on|off] [flags <flag>*] [addr <mac-addr>] [radios all|<id>[,<id>...]]",
NL80211_CMD_NEW_INTERFACE, 0, CIB_PHY, handle_interface_add,
"Add a new virtual interface with the given configuration.\n"
IFACE_TYPES "\n\n"
"The flags are only used for monitor interfaces, valid flags are:\n"
VALID_FLAGS "\n\n"
"The mesh_id is used only for mesh mode.");
-COMMAND(interface, add, "<name> type <type> [mesh_id <meshid>] [4addr on|off] [flags <flag>*] [addr <mac-addr>]",
+COMMAND(interface, add, "<name> type <type> [mesh_id <meshid>] [4addr on|off] [flags <flag>*] [addr <mac-addr>] [radios all|<id>[,<id>...]]",
NL80211_CMD_NEW_INTERFACE, 0, CIB_NETDEV, handle_interface_add, NULL);
static int handle_interface_del(struct nl80211_state *state,
@@ -493,6 +539,19 @@ static int print_iface_handler(struct nl
printf("\n");
}
}
+
+ if (tb_msg[NL80211_ATTR_VIF_RADIO_MASK]) {
+ uint32_t mask = nla_get_u32(tb_msg[NL80211_ATTR_VIF_RADIO_MASK]);
+ int i;
+
+ if (mask) {
+ printf("%s\tRadios:", indent);
+ for (i = 0; mask; i++, mask >>= 1)
+ if (mask & 1)
+ printf(" %d", i);
+ printf("\n");
+ }
+ }
return NL_SKIP;
}

View File

@@ -0,0 +1,46 @@
#
# Copyright (C) 2012 Jo-Philipp Wich <jo@mein.io>
#
# This is free software, licensed under the Apache 2 license.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=iwcap
PKG_RELEASE:=1
PKG_LICENSE:=Apache-2.0
include $(INCLUDE_DIR)/package.mk
define Package/iwcap
SECTION:=utils
CATEGORY:=Utilities
TITLE:=Simple radiotap capture utility
MAINTAINER:=Jo-Philipp Wich <jo@mein.io>
endef
define Package/iwcap/description
The iwcap utility receives radiotap packet data from wifi monitor interfaces
and outputs it to pcap format. It gathers recived packets in a fixed ring
buffer to dump them on demand which is useful for background monitoring.
Alternatively the utility can stream the data to stdout to act as remote
capture drone for Wireshark or similar programs.
endef
define Build/Configure
endef
define Build/Compile
$(TARGET_CC) $(TARGET_CFLAGS) \
-o $(PKG_BUILD_DIR)/iwcap $(PKG_BUILD_DIR)/iwcap.c
endef
define Package/iwcap/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/iwcap $(1)/usr/sbin/iwcap
endef
$(eval $(call BuildPackage,iwcap))

View File

@@ -0,0 +1,583 @@
/*
* iwcap.c - A simply radiotap capture utility outputting pcap dumps
*
* Copyright 2012 Jo-Philipp Wich <jo@mein.io>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdarg.h>
#include <unistd.h>
#include <string.h>
#include <signal.h>
#include <syslog.h>
#include <errno.h>
#include <byteswap.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/ethernet.h>
#include <net/if.h>
#include <netinet/in.h>
#include <linux/if_packet.h>
#define ARPHRD_IEEE80211_RADIOTAP 803
#define DLT_IEEE802_11_RADIO 127
#define LEN_IEEE802_11_HDR 32
#define FRAMETYPE_MASK 0xFC
#define FRAMETYPE_BEACON 0x80
#define FRAMETYPE_DATA 0x08
#if __BYTE_ORDER == __BIG_ENDIAN
#define le16(x) __bswap_16(x)
#else
#define le16(x) (x)
#endif
uint8_t run_dump = 0;
uint8_t run_stop = 0;
uint8_t run_daemon = 0;
uint32_t frames_captured = 0;
uint32_t frames_filtered = 0;
int capture_sock = -1;
const char *ifname = NULL;
struct ringbuf {
uint32_t len; /* number of slots */
uint32_t fill; /* last used slot */
uint32_t slen; /* slot size */
void *buf; /* ring memory */
};
struct ringbuf_entry {
uint32_t len; /* used slot memory */
uint32_t olen; /* original data size */
uint32_t sec; /* epoch of slot creation */
uint32_t usec; /* epoch microseconds */
};
typedef struct pcap_hdr_s {
uint32_t magic_number; /* magic number */
uint16_t version_major; /* major version number */
uint16_t version_minor; /* minor version number */
int32_t thiszone; /* GMT to local correction */
uint32_t sigfigs; /* accuracy of timestamps */
uint32_t snaplen; /* max length of captured packets, in octets */
uint32_t network; /* data link type */
} pcap_hdr_t;
typedef struct pcaprec_hdr_s {
uint32_t ts_sec; /* timestamp seconds */
uint32_t ts_usec; /* timestamp microseconds */
uint32_t incl_len; /* number of octets of packet saved in file */
uint32_t orig_len; /* actual length of packet */
} pcaprec_hdr_t;
typedef struct ieee80211_radiotap_header {
u_int8_t it_version; /* set to 0 */
u_int8_t it_pad;
u_int16_t it_len; /* entire length */
u_int32_t it_present; /* fields present */
} __attribute__((__packed__)) radiotap_hdr_t;
int check_type(void)
{
struct ifreq ifr;
strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
if (ioctl(capture_sock, SIOCGIFHWADDR, &ifr) < 0)
return -1;
return (ifr.ifr_hwaddr.sa_family == ARPHRD_IEEE80211_RADIOTAP);
}
int set_promisc(int on)
{
struct ifreq ifr;
strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
if (ioctl(capture_sock, SIOCGIFFLAGS, &ifr) < 0)
return -1;
if (on && !(ifr.ifr_flags & IFF_PROMISC))
{
ifr.ifr_flags |= IFF_PROMISC;
if (ioctl(capture_sock, SIOCSIFFLAGS, &ifr))
return -1;
return 1;
}
else if (!on && (ifr.ifr_flags & IFF_PROMISC))
{
ifr.ifr_flags &= ~IFF_PROMISC;
if (ioctl(capture_sock, SIOCSIFFLAGS, &ifr))
return -1;
return 1;
}
return 0;
}
void sig_dump(int sig)
{
run_dump = 1;
}
void sig_teardown(int sig)
{
run_stop = 1;
}
void write_pcap_header(FILE *o)
{
pcap_hdr_t ghdr = {
.magic_number = 0xa1b2c3d4,
.version_major = 2,
.version_minor = 4,
.thiszone = 0,
.sigfigs = 0,
.snaplen = 0xFFFF,
.network = DLT_IEEE802_11_RADIO
};
fwrite(&ghdr, 1, sizeof(ghdr), o);
}
void write_pcap_frame(FILE *o, uint32_t *sec, uint32_t *usec,
uint16_t len, uint16_t olen)
{
struct timeval tv;
pcaprec_hdr_t fhdr;
if (!sec || !usec)
{
gettimeofday(&tv, NULL);
}
else
{
tv.tv_sec = *sec;
tv.tv_usec = *usec;
}
fhdr.ts_sec = tv.tv_sec;
fhdr.ts_usec = tv.tv_usec;
fhdr.incl_len = len;
fhdr.orig_len = olen;
fwrite(&fhdr, 1, sizeof(fhdr), o);
}
struct ringbuf * ringbuf_init(uint32_t num_item, uint16_t len_item)
{
static struct ringbuf r;
if (len_item <= 0)
return NULL;
r.buf = malloc(num_item * (len_item + sizeof(struct ringbuf_entry)));
if (r.buf)
{
r.len = num_item;
r.fill = 0;
r.slen = (len_item + sizeof(struct ringbuf_entry));
memset(r.buf, 0, num_item * len_item);
return &r;
}
return NULL;
}
struct ringbuf_entry * ringbuf_add(struct ringbuf *r)
{
struct timeval t;
struct ringbuf_entry *e;
gettimeofday(&t, NULL);
e = r->buf + (r->fill++ * r->slen);
r->fill %= r->len;
memset(e, 0, r->slen);
e->sec = t.tv_sec;
e->usec = t.tv_usec;
return e;
}
struct ringbuf_entry * ringbuf_get(struct ringbuf *r, int i)
{
struct ringbuf_entry *e = r->buf + (((r->fill + i) % r->len) * r->slen);
if (e->len > 0)
return e;
return NULL;
}
void ringbuf_free(struct ringbuf *r)
{
free(r->buf);
memset(r, 0, sizeof(*r));
}
void msg(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
if (run_daemon)
vsyslog(LOG_INFO | LOG_USER, fmt, ap);
else
vfprintf(stderr, fmt, ap);
va_end(ap);
}
int main(int argc, char **argv)
{
int i, n;
struct ringbuf *ring;
struct ringbuf_entry *e;
struct sockaddr_ll local = {
.sll_family = AF_PACKET,
.sll_protocol = htons(ETH_P_ALL)
};
radiotap_hdr_t *rhdr;
uint8_t frametype;
uint8_t pktbuf[0xFFFF];
ssize_t pktlen;
FILE *o;
int opt;
uint8_t promisc = 0;
uint8_t streaming = 0;
uint8_t foreground = 0;
uint8_t filter_data = 0;
uint8_t filter_beacon = 0;
uint8_t header_written = 0;
uint32_t ringsz = 1024 * 1024; /* 1 Mbyte ring buffer */
uint16_t pktcap = 256; /* truncate frames after 265KB */
const char *output = NULL;
while ((opt = getopt(argc, argv, "i:r:c:o:sfhBD")) != -1)
{
switch (opt)
{
case 'i':
ifname = optarg;
if (!(local.sll_ifindex = if_nametoindex(ifname)))
{
msg("Unknown interface '%s'\n", ifname);
return 2;
}
break;
case 'r':
ringsz = atoi(optarg);
if (ringsz < (3 * pktcap))
{
msg("Ring size of %d bytes is too short, "
"must be at least %d bytes\n", ringsz, 3 * pktcap);
return 3;
}
break;
case 'c':
pktcap = atoi(optarg);
if (pktcap <= (sizeof(radiotap_hdr_t) + LEN_IEEE802_11_HDR))
{
msg("Packet truncate after %d bytes is too short, "
"must be at least %d bytes\n",
pktcap, sizeof(radiotap_hdr_t) + LEN_IEEE802_11_HDR);
return 4;
}
break;
case 's':
streaming = 1;
break;
case 'o':
output = optarg;
break;
case 'B':
filter_beacon = 1;
break;
case 'D':
filter_data = 1;
break;
case 'f':
foreground = 1;
break;
case 'h':
msg(
"Usage:\n"
" %s -i {iface} -s [-b] [-d]\n"
" %s -i {iface} -o {file} [-r len] [-c len] [-B] [-D] [-f]\n"
"\n"
" -i iface\n"
" Specify interface to use, must be in monitor mode and\n"
" produce IEEE 802.11 Radiotap headers.\n\n"
" -s\n"
" Stream to stdout instead of Dumping to file on USR1.\n\n"
" -o file\n"
" Write current ringbuffer contents to given output file\n"
" on receipt of SIGUSR1.\n\n"
" -r len\n"
" Specify the amount of bytes to use for the ringbuffer.\n"
" The default length is %d bytes.\n\n"
" -c len\n"
" Truncate captured packets after given amount of bytes.\n"
" The default size limit is %d bytes.\n\n"
" -B\n"
" Don't store beacon frames in ring, default is keep.\n\n"
" -D\n"
" Don't store data frames in ring, default is keep.\n\n"
" -f\n"
" Do not daemonize but keep running in foreground.\n\n"
" -h\n"
" Display this help.\n\n",
argv[0], argv[0], ringsz, pktcap);
return 1;
}
}
if (!streaming && !output)
{
msg("No output file specified\n");
return 1;
}
if (streaming && output)
{
msg("The -s and -o options are exclusive\n");
return 1;
}
if (streaming && isatty(1))
{
msg("Refusing to stream into a terminal\n");
return 1;
}
if (!local.sll_ifindex)
{
msg("No interface specified\n");
return 2;
}
if (!check_type())
{
msg("Bad interface: not ARPHRD_IEEE80211_RADIOTAP\n");
return 2;
}
if ((capture_sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL))) < 0)
{
msg("Unable to create raw socket: %s\n",
strerror(errno));
return 6;
}
if (bind(capture_sock, (struct sockaddr *)&local, sizeof(local)) == -1)
{
msg("Unable to bind to interface: %s\n",
strerror(errno));
return 7;
}
if (!streaming)
{
if (!foreground)
{
switch (fork())
{
case -1:
msg("Unable to fork: %s\n", strerror(errno));
return 8;
case 0:
umask(0077);
chdir("/");
freopen("/dev/null", "r", stdin);
freopen("/dev/null", "w", stdout);
freopen("/dev/null", "w", stderr);
run_daemon = 1;
break;
default:
msg("Daemon launched ...\n");
return 0;
}
}
msg("Monitoring interface %s ...\n", ifname);
if (!(ring = ringbuf_init(ringsz / pktcap, pktcap)))
{
msg("Unable to allocate ring buffer: %s\n",
strerror(errno));
return 5;
}
msg(" * Using %d bytes ringbuffer with %d slots\n", ringsz, ring->len);
msg(" * Truncating frames at %d bytes\n", pktcap);
msg(" * Dumping data to file %s\n", output);
signal(SIGUSR1, sig_dump);
}
else
{
msg("Monitoring interface %s ...\n", ifname);
msg(" * Streaming data to stdout\n");
}
msg(" * Beacon frames are %sfiltered\n", filter_beacon ? "" : "not ");
msg(" * Data frames are %sfiltered\n", filter_data ? "" : "not ");
signal(SIGINT, sig_teardown);
signal(SIGTERM, sig_teardown);
promisc = set_promisc(1);
/* capture loop */
while (1)
{
if (run_dump)
{
msg("Dumping ring to %s ...\n", output);
if (!(o = fopen(output, "w")))
{
msg("Unable to open %s: %s\n",
output, strerror(errno));
}
else
{
write_pcap_header(o);
/* sig_dump packet buffer */
for (i = 0, n = 0; i < ring->len; i++)
{
if (!(e = ringbuf_get(ring, i)))
continue;
write_pcap_frame(o, &(e->sec), &(e->usec), e->len, e->olen);
fwrite((void *)e + sizeof(*e), 1, e->len, o);
n++;
}
fclose(o);
msg(" * %d frames captured\n", frames_captured);
msg(" * %d frames filtered\n", frames_filtered);
msg(" * %d frames dumped\n", n);
}
run_dump = 0;
}
if (run_stop)
{
msg("Shutting down ...\n");
if (promisc)
set_promisc(0);
if (ring)
ringbuf_free(ring);
return 0;
}
pktlen = recvfrom(capture_sock, pktbuf, sizeof(pktbuf), 0, NULL, 0);
frames_captured++;
/* check received frametype, if we should filter it, rewind the ring */
rhdr = (radiotap_hdr_t *)pktbuf;
if (pktlen <= sizeof(radiotap_hdr_t) || le16(rhdr->it_len) >= pktlen)
{
frames_filtered++;
continue;
}
frametype = *(uint8_t *)(pktbuf + le16(rhdr->it_len));
if ((filter_data && (frametype & FRAMETYPE_MASK) == FRAMETYPE_DATA) ||
(filter_beacon && (frametype & FRAMETYPE_MASK) == FRAMETYPE_BEACON))
{
frames_filtered++;
continue;
}
if (streaming)
{
if (!header_written)
{
write_pcap_header(stdout);
header_written = 1;
}
write_pcap_frame(stdout, NULL, NULL, pktlen, pktlen);
fwrite(pktbuf, 1, pktlen, stdout);
fflush(stdout);
}
else
{
e = ringbuf_add(ring);
e->olen = pktlen;
e->len = (pktlen > pktcap) ? pktcap : pktlen;
memcpy((void *)e + sizeof(*e), pktbuf, e->len);
}
}
return 0;
}

View File

@@ -0,0 +1,122 @@
#
# Copyright (C) 2010-2016 Jo-Philipp Wich <jo@mein.io>
#
# This is free software, licensed under the GPL 2 license.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=libiwinfo
PKG_RELEASE:=1
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL=$(PROJECT_GIT)/project/iwinfo.git
PKG_SOURCE_DATE:=2024-10-20
PKG_SOURCE_VERSION:=b94f066e3f5839b8509483cdd8f4f582a45fa233
PKG_MIRROR_HASH:=ee0bce167707fe78f68a951b7ee1e0e61a92cae281e0e24eb709857ae849777e
PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io>
PKG_LICENSE:=GPL-2.0
PKG_BUILD_FLAGS:=no-lto
PKG_CONFIG_DEPENDS:=CONFIG_WIFI_SCRIPTS_UCODE
IWINFO_ABI_VERSION:=20230701
include $(INCLUDE_DIR)/package.mk
define Package/libiwinfo
SECTION:=libs
CATEGORY:=Libraries
TITLE:=Generalized Wireless Information Library (iwinfo)
DEPENDS:=+libnl-tiny +libuci +libubus +libiwinfo-data
ABI_VERSION:=$(IWINFO_ABI_VERSION)
endef
define Package/libiwinfo/description
Wireless information library with simplified API for nl80211
and wext driver interfaces.
endef
define Package/libiwinfo-lua
SUBMENU:=Lua
SECTION:=lang
CATEGORY:=Languages
TITLE:=libiwinfo Lua binding
DEPENDS:=+libiwinfo +liblua
endef
define Package/libiwinfo-lua/description
This is the Lua binding for the iwinfo library. It provides access to all enabled
backends.
endef
define Package/libiwinfo-data
TITLE:=libiwinfo Lua binding
HIDDEN:=1
endef
define Package/iwinfo
SECTION:=utils
CATEGORY:=Utilities
TITLE:=Generalized Wireless Information utility
DEPENDS:=+libiwinfo @!WIFI_SCRIPTS_UCODE
endef
define Package/iwinfo/description
Command line frontend for the wireless information library.
endef
define Build/Configure
endef
TARGET_CFLAGS += \
-I$(STAGING_DIR)/usr/include/libnl-tiny \
-I$(STAGING_DIR)/usr/include \
-D_GNU_SOURCE
MAKE_FLAGS += \
FPIC="$(FPIC)" \
CFLAGS="$(TARGET_CFLAGS)" \
LDFLAGS="$(TARGET_LDFLAGS)" \
BACKENDS="nl80211" \
SOVERSION="$(IWINFO_ABI_VERSION)"
define Build/InstallDev
$(INSTALL_DIR) $(1)/usr/include/iwinfo
$(CP) $(PKG_BUILD_DIR)/include/iwinfo.h $(1)/usr/include/
$(CP) $(PKG_BUILD_DIR)/include/iwinfo/* $(1)/usr/include/iwinfo/
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_BUILD_DIR)/libiwinfo.so* $(1)/usr/lib/
$(INSTALL_DIR) $(1)/usr/lib/lua
$(INSTALL_BIN) $(PKG_BUILD_DIR)/iwinfo.so $(1)/usr/lib/lua/iwinfo.so
endef
define Package/libiwinfo/install
$(INSTALL_DIR) $(1)/usr/lib
$(INSTALL_BIN) $(PKG_BUILD_DIR)/libiwinfo.so.$(IWINFO_ABI_VERSION) $(1)/usr/lib/libiwinfo.so.$(IWINFO_ABI_VERSION)
endef
define Package/libiwinfo-lua/install
$(INSTALL_DIR) $(1)/usr/lib/lua
$(INSTALL_BIN) $(PKG_BUILD_DIR)/iwinfo.so $(1)/usr/lib/lua/iwinfo.so
endef
define Package/libiwinfo-data/install
$(INSTALL_DIR) $(1)/usr/share/libiwinfo
$(INSTALL_DATA) $(PKG_BUILD_DIR)/devices.txt $(1)/usr/share/libiwinfo/devices.txt
endef
define Package/iwinfo/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/iwinfo $(1)/usr/bin/iwinfo
endef
$(eval $(call BuildPackage,libiwinfo))
$(eval $(call BuildPackage,libiwinfo-lua))
$(eval $(call BuildPackage,libiwinfo-data))
$(eval $(call BuildPackage,iwinfo))

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,39 @@
#
# Copyright 2017 NXP
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=restool
PKG_VERSION:=6.6.23.2.0.0
PKG_RELEASE:=1
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/nxp-qoriq/restool
PKG_SOURCE_VERSION:=lf-6.6.23-2.0.0
PKG_MIRROR_HASH:=e669c9faf5a00e36d763dbbd6dd866d878b0101df086582c38908d281fa3b465
PKG_FLAGS:=nonshared
include $(INCLUDE_DIR)/package.mk
define Package/restool
SECTION:=net
CATEGORY:=Network
TITLE:=Layerscape DPAA2 dynamical management tool
DEPENDS:=@TARGET_layerscape_armv8_64b
endef
MAKE_FLAGS += \
DESTDIR="$(PKG_BUILD_DIR)"/output/ \
install
define Package/restool/install
$(INSTALL_DIR) $(1)/usr/bin/
$(CP) $(PKG_BUILD_DIR)/output/usr/local/bin/* $(1)/usr/bin/
endef
$(eval $(call BuildPackage,restool))

View File

@@ -0,0 +1,18 @@
--- a/Makefile
+++ b/Makefile
@@ -55,14 +55,13 @@ restool: $(OBJ)
%.1: %.md
pandoc --standalone --to man $^ -o $@
-install: restool scripts/ls-main scripts/ls-append-dpl scripts/ls-debug scripts/restool_completion.sh $(MANPAGE)
+install: restool scripts/ls-main scripts/ls-append-dpl scripts/ls-debug scripts/restool_completion.sh
install -D -m 755 restool $(DESTDIR)$(bindir)/restool
install -D -m 755 scripts/ls-main $(DESTDIR)$(bindir)/ls-main
install -D -m 755 scripts/ls-append-dpl $(DESTDIR)$(bindir)/ls-append-dpl
install -D -m 755 scripts/ls-debug $(DESTDIR)$(bindir)/ls-debug
$(foreach symlink, $(RESTOOL_SCRIPT_SYMLINKS), sh -c "cd $(DESTDIR)$(bindir) && ln -sf ls-main $(symlink)" ;)
install -D -m 755 scripts/restool_completion.sh $(DESTDIR)$(bindir_completion)/restool
- install -m 0644 -D $(MANPAGE) $(call get_manpage_destination,$(MANPAGE))
clean:
rm -f $(OBJ) $(MANPAGE) \

View File

@@ -0,0 +1,200 @@
#
# Copyright (C) 2006-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:=linux-atm
PKG_VERSION:=2.5.2
PKG_RELEASE:=8
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=@SF/$(PKG_NAME)
PKG_HASH:=9645481a2b16476b59220aa2d6bc5bc41043f291326c9b37581018fbd16dd53a
PKG_INSTALL:=1
PKG_BUILD_PARALLEL:=1
PKG_LICENSE:=GPL-2.0+
PKG_CPE_ID:=cpe:/a:linux-atm:linux-atm
PKG_FIXUP:=autoreconf
PKG_FLAGS:=nonshared
include $(INCLUDE_DIR)/package.mk
ATM_DEBUG_BINS:=aread awrite atmdiag atmdump atmswitch saaldump \
sonetdiag svc_recv svc_send ttcp_atm
ATM_DEBUG_SBINS:=atmaddr atmloop atmtcp esi atmsigd bus \
ilmid ilmidiag lecs les mpcd zeppelin
ATM_DEBUG_TOOLS:=$(ATM_DEBUG_BINS) $(ATM_DEBUG_SBINS)
define Package/linux-atm
SECTION:=libs
CATEGORY:=Libraries
TITLE:=Linux ATM library
URL:=http://linux-atm.sourceforge.net/
endef
define Package/linux-atm/description
This package contains a library for accessing the Linux ATM subsystem.
endef
define Package/linux-atm/Default
SECTION:=net
CATEGORY:=Network
DEPENDS:=+linux-atm
URL:=http://linux-atm.sourceforge.net/
SUBMENU:=Linux ATM tools
endef
define Package/atm-tools
$(call Package/linux-atm/Default)
TITLE:=Linux ATM tools
endef
define Package/atm-tools/description
This package contains the Linux ATM tools.
endef
define Package/atm-diagnostics
$(call Package/linux-atm/Default)
TITLE:=Linux ATM Diagnostics
endef
define Package/atm-diagnostics/description
This package contains the Linux ATM diagnostics.
endef
define Package/atm-debug-tools
$(call Package/linux-atm/Default)
TITLE:=Linux ATM debugging tools
endef
define Package/atm-debug-tools/description
This package contains the Linux ATM debugging tools.
endef
define Package/br2684ctl
$(call Package/linux-atm/Default)
TITLE:=ATM Ethernet bridging configuration utility
endef
define Package/br2684ctl/description
Support for AAL5 encapsulation (RFC-1483/RFC-2684) over ATM.
endef
define GenAtmPlugin
define Package/$(1)
$(call Package/linux-atm/Default)
TITLE:=Linux ATM tool $(2)
endef
define Package/$(1)/description
Linux ATM tool $(2).
endef
endef
$(foreach t,$(ATM_DEBUG_TOOLS),$(eval $(call GenAtmPlugin,atm-$(t),$(t))))
TARGET_CFLAGS += -I$(LINUX_DIR)/user_headers/include
define Build/Configure
$(call Build/Configure/Default)
# prevent autoheader invocation
touch $(PKG_BUILD_DIR)/stamp-h.in
endef
unexport PREFIX
define Build/Compile
# src/qgen is built with HOSTCC, which does not really like our LDFLAGS
+$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/src/qgen \
LDFLAGS="" \
all
+$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) OBJCOPY=$(TARGET_CROSS)objcopy all
endef
define Build/InstallDev
$(INSTALL_DIR) $(1)/usr
$(CP) \
$(PKG_INSTALL_DIR)/usr/include \
$(PKG_INSTALL_DIR)/usr/lib \
$(1)/usr/
endef
define Package/linux-atm/install
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libatm.so* $(1)/usr/lib/
endef
define Package/atm-tools/install
$(INSTALL_DIR) $(1)/usr/sbin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/atmarp{,d} $(1)/usr/sbin/
endef
define BuildAtmPlugin
define Package/$(1)/install
$(INSTALL_DIR) $$(1)/usr/$(3)
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/$(3)/$(2) $$(1)/usr/$(3)
endef
$$(eval $$(call BuildPackage,$(1)))
endef
define Package/atm-debug-tools/install
$(INSTALL_DIR) $(1)/usr/bin/
$(INSTALL_DIR) $(1)/usr/sbin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/atmaddr $(1)/usr/sbin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/atmloop $(1)/usr/sbin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/atmtcp $(1)/usr/sbin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/esi $(1)/usr/sbin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/aread $(1)/usr/bin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/awrite $(1)/usr/bin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/atmdiag $(1)/usr/bin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/atmdump $(1)/usr/bin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/atmsigd $(1)/usr/sbin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/bus $(1)/usr/sbin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/ilmid $(1)/usr/sbin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/ilmidiag $(1)/usr/sbin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/lecs $(1)/usr/sbin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/les $(1)/usr/sbin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/mpcd $(1)/usr/sbin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/zeppelin $(1)/usr/sbin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/atmswitch $(1)/usr/bin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/saaldump $(1)/usr/bin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/sonetdiag $(1)/usr/bin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/svc_recv $(1)/usr/bin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/svc_send $(1)/usr/bin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/ttcp_atm $(1)/usr/bin/
endef
define Package/atm-diagnostics/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/aread $(1)/usr/bin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/awrite $(1)/usr/bin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/atmdiag $(1)/usr/bin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/atmdump $(1)/usr/bin/
endef
define Package/br2684ctl/install
$(INSTALL_DIR) $(1)/etc/init.d $(1)/etc/hotplug.d/atm $(1)/usr/sbin $(1)/lib/netifd
$(INSTALL_BIN) ./files/br2684-up $(1)/lib/netifd/br2684-up
$(INSTALL_BIN) ./files/br2684ctl $(1)/etc/init.d/
$(INSTALL_CONF) ./files/atm.hotplug $(1)/etc/hotplug.d/atm/00-trigger
$(INSTALL_BIN) \
./files/br2684ctl_wrap \
$(PKG_INSTALL_DIR)/usr/sbin/br2684ctl \
$(1)/usr/sbin/
endef
$(eval $(call BuildPackage,linux-atm))
$(eval $(call BuildPackage,atm-tools))
$(eval $(call BuildPackage,atm-debug-tools))
$(eval $(call BuildPackage,atm-diagnostics))
$(eval $(call BuildPackage,br2684ctl))
$(foreach t,$(ATM_DEBUG_BINS),$(eval $(call BuildAtmPlugin,atm-$(t),$(t),bin)))
$(foreach t,$(ATM_DEBUG_SBINS),$(eval $(call BuildAtmPlugin,atm-$(t),$(t),sbin)))

View File

@@ -0,0 +1 @@
ubus call service event '{ "type": "hotplug.atm", "data": { "name": "'"$DEVICENAME"'" } }'

View File

@@ -0,0 +1,3 @@
#!/bin/sh
. /lib/functions/network.sh
network_ready_device "$1"

View File

@@ -0,0 +1,84 @@
#!/bin/sh /etc/rc.common
START=50
USE_PROCD=1
start_daemon() {
local cfg="$1"
local atmdev disabled
config_get_bool disabled "$cfg" disabled 0
[ "$disabled" -eq 1 ] && return
config_get atmdev "$cfg" atmdev 0
local nameprefix
config_get nameprefix "$cfg" nameprefix "nas"
local unit
config_get unit "$cfg" unit 0
local vpi
config_get vpi "$cfg" vpi 8
local vci
config_get vci "$cfg" vci 35
local encaps
config_get encaps "$cfg" encaps
case "$encaps" in
1|vc) encaps=1;;
*) encaps=0;;
esac
local payload
config_get payload "$cfg" payload
case "$payload" in
0|routed) payload=0;;
*) payload=1;;
esac
local qos
config_get qos "$cfg" qos
local sendsize
config_get sendsize "$cfg" sendsize
found=
for device in /sys/class/atm/*; do
[ -d "$device" ] || break
[ "$(cat $device/atmindex)" = "$atmdev" ] || continue
found=1
break
done
[ -n "$found" ] || return
local circuit="$atmdev.$vpi.$vci"
procd_open_instance
procd_set_param command \
/usr/sbin/br2684ctl_wrap "${nameprefix}${unit}" \
-n "$nameprefix" -c "$unit" -e "$encaps" -p "$payload" \
-a "$circuit" ${qos:+-q "$qos"} ${sendsize:+-s "$sendsize"} \
-S /lib/netifd/br2684-up
procd_close_instance
}
service_triggers() {
local script=$(readlink "$initscript")
local name=$(basename ${script:-$initscript})
procd_open_trigger
procd_add_raw_trigger hotplug.atm 2000 /etc/init.d/$name reload
procd_add_config_trigger "config.change" "network" /etc/init.d/$name reload
procd_close_trigger
}
start_service() {
config_load network
config_foreach start_daemon atm-bridge
}

View File

@@ -0,0 +1,5 @@
#!/bin/sh
. /lib/functions/network.sh
device="$1"; shift
network_defer_device "$device"
exec /usr/sbin/br2684ctl "$@"

View File

@@ -0,0 +1,319 @@
--- a/src/mpoad/mpcd.8
+++ b/src/mpoad/mpcd.8
@@ -28,7 +28,7 @@ mpcd \- ATM MPOA (Multi\-Protocol Over A
.B ]]
.SH DESCRIPTION
MPOA client
-.SM(MPC) is responsible for creating and receiving
+.SM (MPC) is responsible for creating and receiving
internetwork layer shortcuts. Using these shortcuts MPCs forward
unicast internetwork layer packets effectively over ATM without need
for routing protocols.
@@ -43,7 +43,7 @@ accepts shortcuts and packets arriving o
shortcuts is done with the help of
.SM MPOA
server
-.SM(MPS).
+.SM (MPS).
.PP
Just as the Linux
.SM LAN
--- a/src/led/zeppelin.8
+++ b/src/led/zeppelin.8
@@ -99,7 +99,7 @@ Ring and ATM parts of the ELAN, so using
recommended. Token Ring support has received less testing than its
Ethernet counterpart.
.SH FILES
-.IP \fI/var/run/lec[interface number].pid\fP
+.IP \fI/var/run/lec[interface\ number].pid\fP
The file containing the process id of zeppelin.
.SH BUGS
John Bonham died 1980 and Led Zeppelin broke.
--- a/src/sigd/atmsigd.conf.4
+++ b/src/sigd/atmsigd.conf.4
@@ -125,7 +125,7 @@ a comment. The `#' character cannot be e
.P
If an option is specified in \fBatmsigd.conf\fP and on the command
line, the command line has priority.
-.COMPATIBILITY
+.SH COMPATIBILITY
Certain options used by past versions of \fBatmsigd\fP but no longer documented
on the man page are still recognized and supported, but they also yield a
warning message. Future versions of \fBatmsigd\fP will not recognize those
--- a/src/arpd/io.c
+++ b/src/arpd/io.c
@@ -277,7 +277,8 @@ static void accept_new(void)
struct atm_qos qos;
ENTRY *entry;
VCC *vcc;
- int fd,len,size,error;
+ int fd,error;
+ socklen_t len,size;
len = sizeof(addr);
if ((fd = accept(incoming,(struct sockaddr *) &addr,&len)) < 0) {
@@ -614,7 +615,8 @@ int ip_itf_info(int number,uint32_t *ip,
int get_local(int fd,struct sockaddr_atmsvc *addr)
{
- int length,result;
+ int result;
+ size_t length;
length = sizeof(struct sockaddr_atmsvc);
result = getsockname(fd,(struct sockaddr *) addr,&length);
--- a/src/arpd/table.c
+++ b/src/arpd/table.c
@@ -101,7 +101,8 @@ static void dump_vcc(VCC *vcc)
char addr_buf[MAX_ATM_ADDR_LEN+1];
char qos_buf[MAX_ATM_QOS_LEN+1];
struct atm_qos qos;
- int size,sndbuf;
+ int sndbuf;
+ socklen_t size;
size = sizeof(addr);
if (getpeername(vcc->fd,(struct sockaddr *) &addr,&size) < 0) {
--- a/src/ilmid/asn1/asn_int.c
+++ b/src/ilmid/asn1/asn_int.c
@@ -185,7 +185,7 @@ FILE* f _AND_
AsnInt* v _AND_
unsigned short int indent)
{
- fprintf(f,"%d", *v);
+ fprintf(f,"%ld", *v);
}
@@ -370,5 +370,5 @@ FILE* f _AND_
UAsnInt* v _AND_
unsigned short int indent)
{
- fprintf(f,"%u", *v);
+ fprintf(f,"%lu", *v);
}
--- a/src/ilmid/asn1/asn_oid.c
+++ b/src/ilmid/asn1/asn_oid.c
@@ -127,7 +127,7 @@ unsigned short int indent)
if (firstArcNum > 2)
firstArcNum = 2;
- fprintf(f,"%u %u", firstArcNum, arcNum - (firstArcNum * 40));
+ fprintf(f,"%d %lu", firstArcNum, arcNum - (firstArcNum * 40));
for (; i < v->octetLen ; )
{
@@ -136,7 +136,7 @@ unsigned short int indent)
arcNum = (arcNum << 7) + (v->octs[i] & 0x7f);
i++;
- fprintf(f," %u", arcNum);
+ fprintf(f," %lu", arcNum);
}
fprintf(f,"}");
--- a/src/lane/connect.c
+++ b/src/lane/connect.c
@@ -258,7 +258,8 @@ static int
data_handler(const Event_t *event, void *funcdata)
{
Conn_t *tmp, *newconn;
- int fd, nbytes;
+ int fd;
+ socklen_t nbytes;
static char buffer[BUFSIZE];
LaneControl_t *ctmp;
struct sockaddr_atmsvc addr;
--- a/src/lane/connect_bus.c
+++ b/src/lane/connect_bus.c
@@ -170,7 +170,8 @@ static int
data_handler(const Event_t *event, void *funcdata)
{
Conn_t *tmp, *newconn;
- int fd, nbytes;
+ int fd;
+ socklen_t nbytes;
static char buffer[BUFSIZE];
struct sockaddr_atmsvc addr;
--- a/src/lane/lane_atm.c
+++ b/src/lane/lane_atm.c
@@ -138,7 +138,7 @@ atm_connect_back(const AtmAddr_t *our_ad
struct atm_blli blli;
struct atm_qos qos;
int fd, ret;
- int len = sizeof(address);
+ socklen_t len = sizeof(address);
fd = socket(PF_ATMSVC, SOCK_DGRAM, 0);
if (fd <0) {
--- a/src/lane/lecs.c
+++ b/src/lane/lecs.c
@@ -119,7 +119,7 @@ int main(int argc, char **argv)
int just_dump=0;
fd_set fds;
struct sockaddr_atmsvc client;
- int len;
+ socklen_t len;
unsigned char buffer[P_SIZE];
while(i!=-1) {
--- a/src/lib/ans.c
+++ b/src/lib/ans.c
@@ -41,7 +41,7 @@
static int ans(const char *text,int wanted,void *result,int res_len)
{
unsigned char answer[MAX_ANSWER];
- unsigned char name[MAX_NAME];
+ char name[MAX_NAME];
unsigned char *pos,*data,*found;
int answer_len,name_len,data_len,found_len;
int questions,answers;
--- a/src/lib/sdu2cell.c
+++ b/src/lib/sdu2cell.c
@@ -15,7 +15,8 @@ int sdu2cell(int s,int sizes,const int *
{
struct atm_qos qos;
int trailer,total,cells;
- int size,i;
+ int i;
+ socklen_t size;
size = sizeof(qos);
if (getsockopt(s,SOL_AAL,SO_ATMQOS,&qos,&size) < 0) return -1;
--- a/src/lib/unix.c
+++ b/src/lib/unix.c
@@ -63,8 +63,8 @@ int un_attach(const char *path)
int un_recv_connect(int s,void *buf,int size)
{
struct sockaddr_un addr;
- int addr_size;
int len;
+ socklen_t addr_size;
addr_size = sizeof(addr);
len = recvfrom(s,buf,size,0,(struct sockaddr *) &addr,&addr_size);
--- a/src/maint/atmtcp.c
+++ b/src/maint/atmtcp.c
@@ -817,7 +817,8 @@ int main(int argc,char **argv)
}
else if (!strcmp(ARG,"listen") ||
(do_background = !strcmp(ARG,"listen-bg"))) {
- int fd,port,addr_len;
+ int fd,port;
+ socklen_t addr_len;
int *fd2 = alloc_t(int);
if ((fd = socket(PF_INET,SOCK_STREAM,0)) < 0) {
--- a/src/maint/hediag.c
+++ b/src/maint/hediag.c
@@ -1,6 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+#include <string.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/socket.h>
--- a/src/mpoad/io.c
+++ b/src/mpoad/io.c
@@ -521,7 +521,8 @@ static int msg_from_mps(int slot)
static int accept_conn(int slot)
{
struct sockaddr_atmsvc sa;
- int i, new_fd, sa_len;
+ int i, new_fd;
+ socklen_t sa_len;
sa_len = sizeof(sa);
new_fd = accept(fds[slot].fd, (struct sockaddr *)&sa, &sa_len);
--- a/src/sigd/io.c
+++ b/src/sigd/io.c
@@ -355,7 +355,7 @@ int get_pvc(int itf,int *vci)
error = 0;
if (bind(s,(struct sockaddr *) &addr,sizeof(addr)) < 0) error = errno;
else {
- int size;
+ socklen_t size;
size = sizeof(addr);
if (getsockname(s,(struct sockaddr *) &addr,&size) < 0)
--- a/src/test/ttcp.c
+++ b/src/test/ttcp.c
@@ -92,7 +92,8 @@ struct sockaddr_in frominet;
struct sockaddr_atmsvc satm;
struct atm_qos qos;
-int domain, fromlen;
+int domain;
+socklen_t fromlen;
int fd; /* fd of network socket */
int buflen = 8 * 1024; /* length of buffer */
@@ -466,7 +467,7 @@ int no_check = 0;
{
struct sockaddr_atmsvc peer;
- int peerlen = sizeof(peer);
+ socklen_t peerlen = sizeof(peer);
if (getpeername(fd, (struct sockaddr *) &peer,
&peerlen) < 0) {
err("getpeername");
@@ -498,7 +499,7 @@ int no_check = 0;
/* set socket buffer size */
#if defined(SO_SNDBUF) || defined(SO_RCVBUF)
if (sockbufsize) {
- int len;
+ socklen_t len;
if (trans) {
/* set send socket buffer if we are transmitting */
@@ -663,7 +664,7 @@ int no_check = 0;
exit(0);
usage:
- fprintf(stderr, Usage);
+ fprintf(stderr, "%s", Usage);
exit(1);
}
--- a/src/arpd/arp.c
+++ b/src/arpd/arp.c
@@ -17,6 +17,7 @@
#include <netinet/in.h> /* for ntohs, etc. */
#define _LINUX_NETDEVICE_H /* very crude hack for glibc2 */
#include <linux/types.h>
+#include <linux/if.h>
#include <linux/if_arp.h>
#include <linux/if_ether.h>
#include <atm.h>
--- a/src/arpd/itf.c
+++ b/src/arpd/itf.c
@@ -14,6 +14,7 @@
#include <sys/socket.h>
#define _LINUX_NETDEVICE_H /* glibc2 */
#include <linux/types.h>
+#include <linux/if.h>
#include <linux/if_arp.h>
#include "atmd.h"
--- a/src/maint/atmdump.c
+++ b/src/maint/atmdump.c
@@ -14,6 +14,7 @@
#include <sys/types.h>
#include <sys/time.h>
#include <sys/socket.h>
+#include <linux/sockios.h>
#include <netinet/in.h> /* for htonl and ntohl */
#include <atm.h>
--- a/src/maint/saaldump.c
+++ b/src/maint/saaldump.c
@@ -15,6 +15,7 @@
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
+#include <linux/sockios.h>
#include <atm.h>
#include "pdu.h"

View File

@@ -0,0 +1,179 @@
--- a/src/qgen/Makefile.am
+++ b/src/qgen/Makefile.am
@@ -2,7 +2,7 @@ noinst_PROGRAMS = qgen
qgen_SOURCES = common.c common.h file.c file.h first.c ql_y.y ql_l.l qgen.c \
qgen.h second.c third.c
-qgen_LDADD = -lfl
+qgen_LDADD =
COMPILE = @CC_FOR_BUILD@ @CFLAGS_FOR_BUILD@
LINK = @CC_FOR_BUILD@ @CFLAGS_FOR_BUILD@ -o $@
--- a/src/qgen/Makefile.in
+++ b/src/qgen/Makefile.in
@@ -204,7 +204,7 @@ top_srcdir = @top_srcdir@
qgen_SOURCES = common.c common.h file.c file.h first.c ql_y.y ql_l.l qgen.c \
qgen.h second.c third.c
-qgen_LDADD = -lfl
+qgen_LDADD =
COMPILE = @CC_FOR_BUILD@ @CFLAGS_FOR_BUILD@
LINK = @CC_FOR_BUILD@ @CFLAGS_FOR_BUILD@ -o $@
--- a/src/sigd/Makefile.am
+++ b/src/sigd/Makefile.am
@@ -8,7 +8,7 @@ atmsigd_XTRAS = mess.o $(top_builddir)/s
$(top_builddir)/src/q2931/qd.dump.o \
$(top_builddir)/src/lib/libatm.la \
$(top_builddir)/src/saal/libsaal.a
-atmsigd_LDADD = $(atmsigd_XTRAS) -lfl
+atmsigd_LDADD = $(atmsigd_XTRAS)
atmsigd_DEPENDENCIES = mess.c $(atmsigd_XTRAS)
CLEANFILES = mess.c
--- a/src/sigd/Makefile.in
+++ b/src/sigd/Makefile.in
@@ -245,7 +245,7 @@ atmsigd_XTRAS = mess.o $(top_builddir)/s
$(top_builddir)/src/lib/libatm.la \
$(top_builddir)/src/saal/libsaal.a
-atmsigd_LDADD = $(atmsigd_XTRAS) -lfl
+atmsigd_LDADD = $(atmsigd_XTRAS)
atmsigd_DEPENDENCIES = mess.c $(atmsigd_XTRAS)
CLEANFILES = mess.c
sysconf_DATA = atmsigd.conf
--- a/src/switch/debug/debug.c
+++ b/src/switch/debug/debug.c
@@ -20,6 +20,11 @@
#define PRV(call) ((FAB *) (call)->fab)
+int yywrap(void)
+{
+ return 1;
+}
+
typedef struct _fab {
CALL *next; /* relay.c may not keep track of calls, but WE are */
--- a/src/switch/debug/Makefile.am
+++ b/src/switch/debug/Makefile.am
@@ -5,7 +5,7 @@ INCLUDES = -I$(srcdir)/../../q2931
sw_debug_SOURCES = debug.c
sw_debug_XTRAS = $(top_builddir)/src/switch/libsw.a \
$(top_builddir)/src/lib/libatm.la
-sw_debug_LDADD = $(sw_debug_XTRAS) -lfl
+sw_debug_LDADD = $(sw_debug_XTRAS)
sw_debug_DEPENDENCIES = $(sw_debug_XTRAS)
--- a/src/switch/debug/Makefile.in
+++ b/src/switch/debug/Makefile.in
@@ -200,7 +200,8 @@ sw_debug_SOURCES = debug.c
sw_debug_XTRAS = $(top_builddir)/src/switch/libsw.a \
$(top_builddir)/src/lib/libatm.la
-sw_debug_LDADD = $(sw_debug_XTRAS) -lfl
+sw_debug_LDADD = $(sw_debug_XTRAS)
+
sw_debug_DEPENDENCIES = $(sw_debug_XTRAS)
EXTRA_DIST = demo README
all: all-am
--- a/src/switch/tcp/Makefile.am
+++ b/src/switch/tcp/Makefile.am
@@ -5,7 +5,7 @@ INCLUDES = -I$(srcdir)/../../q2931
sw_tcp_SOURCES = tcpsw.c
sw_tcp_XTRAS = $(top_builddir)/src/switch/libsw.a \
$(top_builddir)/src/lib/libatm.la
-sw_tcp_LDADD = $(sw_tcp_XTRAS) -lfl
+sw_tcp_LDADD = $(sw_tcp_XTRAS)
sw_tcp_DEPENDENCIES = $(sw_tcp_XTRAS)
EXTRA_DIST = mkfiles README
--- a/src/switch/tcp/Makefile.in
+++ b/src/switch/tcp/Makefile.in
@@ -200,7 +200,7 @@ sw_tcp_SOURCES = tcpsw.c
sw_tcp_XTRAS = $(top_builddir)/src/switch/libsw.a \
$(top_builddir)/src/lib/libatm.la
-sw_tcp_LDADD = $(sw_tcp_XTRAS) -lfl
+sw_tcp_LDADD = $(sw_tcp_XTRAS)
sw_tcp_DEPENDENCIES = $(sw_tcp_XTRAS)
EXTRA_DIST = mkfiles README
all: all-am
--- a/src/switch/tcp/tcpsw.c
+++ b/src/switch/tcp/tcpsw.c
@@ -35,6 +35,10 @@
#define MAX_PACKET (ATM_MAX_AAL5_PDU+sizeof(struct atmtcp_hdr))
#define BUFFER_SIZE (MAX_PACKET*2)
+int yywrap(void)
+{
+ return 1;
+}
typedef struct _table {
struct _link *out; /* output port */
--- a/src/test/Makefile.am
+++ b/src/test/Makefile.am
@@ -20,7 +20,7 @@ br_SOURCES = br.c
bw_SOURCES = bw.c
isp_SOURCES = isp.c isp.h ispl_y.y ispl_l.l
isp_XTRAS = $(LDADD)
-isp_LDADD = $(isp_XTRAS) -lfl
+isp_LDADD = $(isp_XTRAS)
isp_DEPENDENCIES = $(isp_XTRAS)
window_SOURCES = window.c
--- a/src/test/Makefile.in
+++ b/src/test/Makefile.in
@@ -283,7 +283,7 @@ br_SOURCES = br.c
bw_SOURCES = bw.c
isp_SOURCES = isp.c isp.h ispl_y.y ispl_l.l
isp_XTRAS = $(LDADD)
-isp_LDADD = $(isp_XTRAS) -lfl
+isp_LDADD = $(isp_XTRAS)
isp_DEPENDENCIES = $(isp_XTRAS)
window_SOURCES = window.c
CLEANFILES = errnos.inc
--- a/src/test/ispl_l.l
+++ b/src/test/ispl_l.l
@@ -18,6 +18,11 @@
#include "ispl_y.h"
+int yywrap(void)
+{
+ return 1;
+}
+
static int lineno = 1;
%}
--- a/src/qgen/ql_l.l
+++ b/src/qgen/ql_l.l
@@ -11,6 +11,11 @@
#include "ql_y.h"
+int yywrap(void)
+{
+ return 1;
+}
+
typedef struct _tree {
struct _tree *left,*right;
const char str[0];
--- a/src/sigd/cfg_l.l
+++ b/src/sigd/cfg_l.l
@@ -16,6 +16,10 @@
#include "cfg_y.h"
+int yywrap(void)
+{
+ return 1;
+}
static int lineno = 1;
static int token; /* f@#%ing flex doesn't grok return after BEGIN */

View File

@@ -0,0 +1,40 @@
--- a/src/extra/Makefile.am
+++ b/src/extra/Makefile.am
@@ -7,6 +7,8 @@ EXTRA_DIST = linux-atm.spec.in \
BUILT_SOURCES = pca200e.bin pca200e_ecd.bin2 sba200e_ecd.bin2
CLEANFILES = pca200e.bin pca200e_ecd.bin2 sba200e_ecd.bin2
+OBJCOPY = objcopy
+
install-exec-hook:
$(MKDIR_P) $(DESTDIR)/lib/firmware
$(INSTALL_DATA) $(srcdir)/pca200e.bin $(DESTDIR)/lib/firmware
@@ -14,7 +16,7 @@ install-exec-hook:
$(INSTALL_DATA) $(srcdir)/sba200e_ecd.bin2 $(DESTDIR)/lib/firmware
%.bin %.bin2: %.data
- objcopy -Iihex $< -Obinary $@.gz
+ $(OBJCOPY) -Iihex $< -Obinary $@.gz
gzip -n -df $@.gz
--- a/src/extra/Makefile.in
+++ b/src/extra/Makefile.in
@@ -187,6 +187,8 @@ CLEANFILES = pca200e.bin pca200e_ecd.bin
all: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) all-am
+OBJCOPY = objcopy
+
.SUFFIXES:
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
@@ -385,7 +387,7 @@ install-exec-hook:
$(INSTALL_DATA) $(srcdir)/sba200e_ecd.bin2 $(DESTDIR)/lib/firmware
%.bin %.bin2: %.data
- objcopy -Iihex $< -Obinary $@.gz
+ $(OBJCOPY) -Iihex $< -Obinary $@.gz
gzip -n -df $@.gz
# Tell versions [3.59,3.63) of GNU make to not export all variables.

View File

@@ -0,0 +1,70 @@
--- a/src/ilmid/io.c
+++ b/src/ilmid/io.c
@@ -48,6 +48,14 @@
be manually configured (after ilmid has
registered the "official" address) - HACK */
+#ifndef SUN_LEN
+# include <string.h> /* For prototype of `strlen'. */
+
+/* Evaluate to actual length of the `sockaddr_un' structure. */
+# define SUN_LEN(ptr) ((size_t) (((struct sockaddr_un *) 0)->sun_path) \
+ + strlen ((ptr)->sun_path))
+#endif
+
extern SysGroup *remsys;
extern State ilmi_state;
static short atm_itf = -1; /* bad value */
--- a/src/mpoad/io.c
+++ b/src/mpoad/io.c
@@ -10,14 +10,7 @@
#include <errno.h>
#include <sys/ioctl.h>
#include <sys/param.h> /* for OPEN_MAX */
-#if __GLIBC__ >= 2
#include <sys/poll.h>
-#else /* ugly hack to make it compile on RH 4.2 - WA */
-#include <syscall.h>
-#include <linux/poll.h>
-#define SYS_poll 168
-_syscall3(int,poll,struct pollfd *,ufds,unsigned int,nfds,int,timeout);
-#endif
#include <atm.h>
#include <linux/types.h>
#include <linux/atmioc.h>
--- a/src/sigd/atmsigd.c
+++ b/src/sigd/atmsigd.c
@@ -283,12 +283,11 @@ static void setup_signals(void)
/* ------------------------------- main ... ------------------------------- */
-static void trace_on_exit(int status,void *dummy)
+static void trace_on_exit(void)
{
char path[PATH_MAX+1];
FILE *file;
- if (!status) return;
if (!dump_dir) file = stderr;
else {
sprintf(path,"atmsigd.%d.trace.exit",getpid());
@@ -517,7 +516,7 @@ int main(int argc,char **argv)
exit(0);
}
}
- (void) on_exit(trace_on_exit,NULL);
+ (void) atexit(trace_on_exit);
poll_loop();
close_all();
for (sig = entities; sig; sig = sig->next) stop_saal(&sig->saal);
--- a/src/test/align.c
+++ b/src/test/align.c
@@ -24,7 +24,7 @@
#include <signal.h>
#include <sys/types.h>
#include <sys/socket.h>
-#include <sys/errno.h>
+#include <errno.h>
#include <atm.h>

View File

@@ -0,0 +1,63 @@
--- a/src/br2684/br2684ctl.c
+++ b/src/br2684/br2684ctl.c
@@ -1,3 +1,4 @@
+#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -43,6 +44,7 @@ struct br2684_params {
int lastsock, lastitf;
+static char *up_script;
void fatal(const char *str, int err)
@@ -185,6 +187,8 @@ int assign_vcc(char *astr, int encap, in
void start_interface(struct br2684_params* params)
{
+ char *cmd;
+
if (params->astr==NULL) {
syslog(LOG_ERR, "Required ATM parameters not specified.");
exit(1);
@@ -193,13 +197,18 @@ void start_interface(struct br2684_param
create_br(params->itfnum, params->payload);
assign_vcc(params->astr, params->encap, params->payload, params->sndbuf,
params->reqqos);
+ if (up_script) {
+ asprintf(&cmd, "%s nas%d", up_script, lastitf);
+ system(cmd);
+ free(cmd);
+ }
}
void usage(char *s)
{
printf("usage: %s [-b] [[-c number] [-e 0|1] [-s sndbuf] [-q qos] [-p 0|1] "
- "[-a [itf.]vpi.vci]*]*\n", s);
+ "[-a [itf.]vpi.vci]*]* [-S script]\n", s);
printf(" encapsulations: 0=llc, 1=vcmux\n payloads: 0=routed, 1=bridged\n");
exit(1);
}
@@ -225,7 +234,7 @@ int main (int argc, char **argv)
openlog (LOG_NAME,LOG_OPTION,LOG_FACILITY);
if (argc>1)
- while ((c = getopt(argc, argv,"q:a:bc:e:s:p:?h")) !=EOF)
+ while ((c = getopt(argc, argv,"q:a:bc:e:s:S:p:?h")) !=EOF)
switch (c) {
case 'q':
printf ("optarg : %s",optarg);
@@ -258,6 +267,9 @@ int main (int argc, char **argv)
params.sndbuf=8192;
}
break;
+ case 'S':
+ up_script = optarg;
+ break;
case 'p': /* payload type: routed (0) or bridged (1) */
#ifdef BR2684_FLAG_ROUTED
params.payload = atoi(optarg);

View File

@@ -0,0 +1,74 @@
--- a/src/br2684/br2684ctl.c
+++ b/src/br2684/br2684ctl.c
@@ -45,6 +45,7 @@ struct br2684_params {
int lastsock, lastitf;
static char *up_script;
+const char *itfname = "nas";
void fatal(const char *str, int err)
@@ -73,7 +74,7 @@ int create_pidfile(int num)
if (num < 0) return -1;
- snprintf(name, 32, "/var/run/br2684ctl-nas%d.pid", num);
+ snprintf(name, 32, "/var/run/br2684ctl-%s%d.pid", itfname, num);
pidfile = fopen(name, "w");
if (pidfile == NULL) return -1;
fprintf(pidfile, "%d", getpid());
@@ -102,7 +103,7 @@ int create_br(int itfnum, int payload)
ni.media |= BR2684_FLAG_ROUTED;
#endif
ni.mtu = 1500;
- sprintf(ni.ifname, "nas%d", itfnum);
+ sprintf(ni.ifname, "%s%d", itfname, itfnum);
err=ioctl (lastsock, ATM_NEWBACKENDIF, &ni);
if (err == 0)
@@ -167,7 +168,7 @@ int assign_vcc(char *astr, int encap, in
be.backend_num = ATM_BACKEND_BR2684;
be.ifspec.method = BR2684_FIND_BYIFNAME;
- sprintf(be.ifspec.spec.ifname, "nas%d", lastitf);
+ sprintf(be.ifspec.spec.ifname, "%s%d", itfname, lastitf);
be.fcs_in = BR2684_FCSIN_NO;
be.fcs_out = BR2684_FCSOUT_NO;
be.fcs_auto = 0;
@@ -198,7 +199,7 @@ void start_interface(struct br2684_param
assign_vcc(params->astr, params->encap, params->payload, params->sndbuf,
params->reqqos);
if (up_script) {
- asprintf(&cmd, "%s nas%d", up_script, lastitf);
+ asprintf(&cmd, "%s %s%d", up_script, itfname, lastitf);
system(cmd);
free(cmd);
}
@@ -207,7 +208,7 @@ void start_interface(struct br2684_param
void usage(char *s)
{
- printf("usage: %s [-b] [[-c number] [-e 0|1] [-s sndbuf] [-q qos] [-p 0|1] "
+ printf("usage: %s [-b] [-n name] [[-c number] [-e 0|1] [-s sndbuf] [-q qos] [-p 0|1] "
"[-a [itf.]vpi.vci]*]* [-S script]\n", s);
printf(" encapsulations: 0=llc, 1=vcmux\n payloads: 0=routed, 1=bridged\n");
exit(1);
@@ -234,7 +235,7 @@ int main (int argc, char **argv)
openlog (LOG_NAME,LOG_OPTION,LOG_FACILITY);
if (argc>1)
- while ((c = getopt(argc, argv,"q:a:bc:e:s:S:p:?h")) !=EOF)
+ while ((c = getopt(argc, argv,"q:a:bn:c:e:s:S:p:?h")) !=EOF)
switch (c) {
case 'q':
printf ("optarg : %s",optarg);
@@ -247,6 +248,9 @@ int main (int argc, char **argv)
case 'b':
background=1;
break;
+ case 'n':
+ itfname = optarg;
+ break;
case 'c':
/* temporary, to make it work with multiple interfaces: */
if (params.itfnum>=0) start_interface(&params);

View File

@@ -0,0 +1,52 @@
This fixes the following compile problem with kernel 4.20:
In file included from arp.c:20:0:
include/linux/if_arp.h:121:16: error: 'IFNAMSIZ' undeclared here (not in a function)
char arp_dev[IFNAMSIZ];
^~~~~~~~
make[7]: *** [Makefile:459: arp.o] Error 1
This is caused by commit 6a12709da354 ("net: if_arp: use define instead
of hard-coded value") in the upstream Linux kernel which is integrated
in Linux 4.20.
--- a/src/oamd/io.c
+++ b/src/oamd/io.c
@@ -20,7 +20,6 @@
#include <net/if.h>
#include <netinet/in.h>
#include <atm.h>
-#define _LINUX_NETDEVICE_H /* glibc2 */
#include <linux/types.h>
#include <linux/if_arp.h>
--- a/src/arpd/itf.c
+++ b/src/arpd/itf.c
@@ -12,7 +12,6 @@
#include <sys/types.h>
#include <linux/atmclip.h>
#include <sys/socket.h>
-#define _LINUX_NETDEVICE_H /* glibc2 */
#include <linux/types.h>
#include <linux/if.h>
#include <linux/if_arp.h>
--- a/src/arpd/io.c
+++ b/src/arpd/io.c
@@ -21,7 +21,6 @@
#include <atm.h>
#include <linux/atmclip.h> /* for CLIP_DEFAULT_IDLETIMER */
#include <linux/atmarp.h>
-#define _LINUX_NETDEVICE_H /* glibc2 */
#include <linux/types.h>
#include <linux/if_arp.h>
--- a/src/arpd/arp.c
+++ b/src/arpd/arp.c
@@ -15,7 +15,6 @@
#include <sys/types.h>
#include <sys/socket.h> /* for linux/if_arp.h */
#include <netinet/in.h> /* for ntohs, etc. */
-#define _LINUX_NETDEVICE_H /* very crude hack for glibc2 */
#include <linux/types.h>
#include <linux/if.h>
#include <linux/if_arp.h>

View File

@@ -0,0 +1,30 @@
--- a/src/include/atmd.h
+++ b/src/include/atmd.h
@@ -10,6 +10,7 @@
#include <stdint.h>
#include <stdio.h>
+#include <string.h>
#include <sys/types.h>
#include <sys/time.h>
--- a/src/lib/unix.c
+++ b/src/lib/unix.c
@@ -8,6 +8,7 @@
#include <stdlib.h>
#include <stdio.h>
+#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
--- a/src/sigd/kernel.c
+++ b/src/sigd/kernel.c
@@ -8,6 +8,7 @@
#include <stdlib.h>
#include <stdio.h>
+#include <string.h>
#include <errno.h>
#include <assert.h>

View File

@@ -0,0 +1,82 @@
--- a/src/arpd/io.c
+++ b/src/arpd/io.c
@@ -615,7 +615,7 @@ int ip_itf_info(int number,uint32_t *ip,
int get_local(int fd,struct sockaddr_atmsvc *addr)
{
int result;
- size_t length;
+ socklen_t length;
length = sizeof(struct sockaddr_atmsvc);
result = getsockname(fd,(struct sockaddr *) addr,&length);
--- a/src/led/conn.c
+++ b/src/led/conn.c
@@ -405,7 +405,7 @@ Conn_t *accept_conn(Conn_t *conn)
{
Conn_t *new;
struct sockaddr_atmsvc addr;
- size_t len;
+ socklen_t len;
int fd;
char buff[MAX_ATM_ADDR_LEN+1];
@@ -538,7 +538,7 @@ static int handle_accept(Conn_t *conn)
*/
static int handle_data(Conn_t *conn)
{
- char buff[MAX_CTRL_FRAME];
+ unsigned char buff[MAX_CTRL_FRAME];
int retval;
retval = recv_frame(conn, buff, sizeof(buff));
--- a/src/led/frames.c
+++ b/src/led/frames.c
@@ -312,7 +312,7 @@ static void handle_ready_ind(Conn_t *con
* dependant handler functions.
* Returns < 0 for serious error
*/
-int handle_frame(Conn_t *conn, char *buff, int size)
+int handle_frame(Conn_t *conn, unsigned char *buff, int size)
{
struct ctrl_frame *frame;
--- a/src/led/frames.h
+++ b/src/led/frames.h
@@ -13,7 +13,7 @@ int validate_frame(unsigned char *buff,
void send_ready_ind(Conn_t *conn);
void send_register_req(void);
-int handle_frame(Conn_t *conn, char *buff, int size);
+int handle_frame(Conn_t *conn, unsigned char *buff, int size);
uint32_t send_flush_req(Conn_t *conn);
void parse_tlvs(uint16_t opcode, unsigned char *tlvp, int numtlvs, int sizeoftlvs);
--- a/src/led/join.c
+++ b/src/led/join.c
@@ -43,7 +43,7 @@ static int read_join_rsp(char *buff, int
static int parse_join_rsp(unsigned char *buff, int size);
static int get_bus_addr(struct sockaddr_atmsvc *addr);
-static int read_bus_arp(Conn_t *conn, struct sockaddr_atmsvc *addr, char *buff, int buffsize);
+static int read_bus_arp(Conn_t *conn, struct sockaddr_atmsvc *addr, unsigned char *buff, int buffsize);
/*
* 5.1, Initial state
@@ -693,7 +693,7 @@ static int get_bus_addr(struct sockaddr_
fd_set rfds;
struct timeval tv;
int n = 0, retval, timeout;
- char buff[MAX_CTRL_FRAME];
+ unsigned char buff[MAX_CTRL_FRAME];
timeout = 4; /* wait response for 4 seconds */
lec_params.c7c_current_timeout = 1;
@@ -740,7 +740,7 @@ static int get_bus_addr(struct sockaddr_
* Tries to read BUS ATM address in *addr
* returns < 0 for error, 0 for not found > 0 for success
*/
-static int read_bus_arp(Conn_t *conn, struct sockaddr_atmsvc *addr, char *buff, int buffsize)
+static int read_bus_arp(Conn_t *conn, struct sockaddr_atmsvc *addr, unsigned char *buff, int buffsize)
{
int frame_size;
struct ctrl_frame *frame;

View File

@@ -0,0 +1,34 @@
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=ltq-dsl-base
PKG_RELEASE:=3
PKG_FLAGS:=nonshared
include $(INCLUDE_DIR)/package.mk
define Package/ltq-dsl-base
SECTION:=net
CATEGORY:=Network
TITLE:=DSL related files for Intel/Lantiq DSL Chipsets
URL:=http://openwrt.org/
DEPENDS:=@(TARGET_lantiq||TARGET_ipq40xx) +jshn
endef
define Package/ltq-dsl-base/description
This package contains DSL related files for Intel/Lantiq DSL Chipsets.
endef
define Build/Compile
endef
define Package/ltq-dsl-base/install
$(CP) ./files/* $(1)/
endef
$(eval $(call BuildPackage,ltq-dsl-base))

View File

@@ -0,0 +1,32 @@
#!/bin/sh
[ "$DSL_NOTIFICATION_TYPE" = "DSL_INTERFACE_STATUS" ] || exit 0
. /lib/functions.sh
. /lib/functions/leds.sh
led_dsl_up() {
case "$(config_get led_dsl trigger)" in
"netdev")
led_set_attr $1 "trigger" "netdev"
led_set_attr $1 "device_name" "$(config_get led_dsl dev)"
for m in $(config_get led_dsl mode); do
led_set_attr $1 "$m" "1"
done
;;
*)
led_on $1
;;
esac
}
config_load system
config_get led led_dsl sysfs
if [ -n "$led" ]; then
case "$DSL_INTERFACE_STATUS" in
"HANDSHAKE") led_timer $led 500 500;;
"TRAINING") led_timer $led 200 200;;
"UP") led_dsl_up $led;;
*) led_off $led
esac
fi

View File

@@ -0,0 +1,37 @@
#!/bin/sh
[ "$DSL_NOTIFICATION_TYPE" = "DSL_INTERFACE_STATUS" ] || exit 0
. /usr/share/libubox/jshn.sh
. /lib/functions.sh
include /lib/network
scan_interfaces
interfaces=$(ubus list network.interface.\* | cut -d"." -f3)
for ifc in $interfaces; do
json_load "$(ifstatus $ifc)"
json_get_var proto proto
if [ "$proto" != "pppoa" ]; then
continue
fi
json_get_var up up
config_get_bool auto "$ifc" auto 1
if [ "$DSL_INTERFACE_STATUS" = "UP" ]; then
if [ "$up" != 1 ] && [ "$auto" = 1 ]; then
( sleep 1; ifup "$ifc" ) &
fi
else
if [ "$up" = 1 ] && [ "$auto" = 1 ]; then
( sleep 1; ifdown "$ifc" ) &
else
json_get_var autostart autostart
if [ "$up" != 1 ] && [ "$autostart" = 1 ]; then
( sleep 1; ifdown "$ifc" ) &
fi
fi
fi
done

View File

@@ -0,0 +1,6 @@
#!/bin/sh
#
# This script is called by dsl_cpe_control whenever there is a DSL event
# and calls any available hotplug script(s) in /etc/hotplug.d/dsl.
exec /sbin/hotplug-call dsl

View File

@@ -0,0 +1,85 @@
# SPDX-License-Identifier: GPL-2.0-only
#
# Copyright (C) 2015 OpenWrt.org
#
include $(TOPDIR)/rules.mk
PKG_NAME:=nftables
PKG_VERSION:=1.1.1
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
PKG_SOURCE_URL:=https://netfilter.org/projects/$(PKG_NAME)/files
PKG_HASH:=6358830f3a64f31e39b0ad421d7dadcd240b72343ded48d8ef13b8faf204865a
PKG_MAINTAINER:=
PKG_LICENSE:=GPL-2.0
PKG_LICENSE_FILES:=COPYING
PKG_FIXUP:=autoreconf
PKG_INSTALL:=1
PKG_BUILD_FLAGS:=lto
include $(INCLUDE_DIR)/package.mk
DISABLE_NLS:=
CONFIGURE_ARGS += \
--disable-debug \
--disable-man-doc \
--with-mini-gmp \
--without-cli \
--disable-python
define Package/nftables/Default
SECTION:=net
CATEGORY:=Network
SUBMENU:=Firewall
TITLE:=nftables userspace utility
DEPENDS:=+kmod-nft-core +libnftnl
URL:=http://netfilter.org/projects/nftables/
PROVIDES:=nftables
endef
define Package/nftables-nojson
$(Package/nftables/Default)
TITLE+= no JSON support
VARIANT:=nojson
DEFAULT_VARIANT:=1
CONFLICTS:=nftables-json
endef
define Package/nftables-json
$(Package/nftables/Default)
TITLE+= with JSON support
VARIANT:=json
DEPENDS+=+jansson
endef
ifeq ($(BUILD_VARIANT),json)
CONFIGURE_ARGS += --with-json
endif
define Build/InstallDev
$(INSTALL_DIR) $(1)/usr/lib $(1)/usr/include
$(CP) $(PKG_INSTALL_DIR)/usr/lib/*.so* $(1)/usr/lib/
$(CP) $(PKG_INSTALL_DIR)/usr/include/nftables $(1)/usr/include/
$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
$(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libnftables.pc \
$(1)/usr/lib/pkgconfig/
endef
define Package/nftables/install/Default
$(INSTALL_DIR) $(1)/usr/sbin
$(CP) $(PKG_INSTALL_DIR)/usr/sbin/nft $(1)/usr/sbin/
$(INSTALL_DIR) $(1)/usr/lib
$(CP) $(PKG_INSTALL_DIR)/usr/lib/*.so* $(1)/usr/lib/
endef
Package/nftables-nojson/install = $(Package/nftables/install/Default)
Package/nftables-json/install = $(Package/nftables/install/Default)
$(eval $(call BuildPackage,nftables-nojson))
$(eval $(call BuildPackage,nftables-json))

View File

@@ -0,0 +1,41 @@
#
# 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:=resolveip
PKG_RELEASE:=2
PKG_LICENSE:=GPL-2.0
include $(INCLUDE_DIR)/package.mk
define Package/resolveip
SECTION:=utils
CATEGORY:=Base system
TITLE:=Simple DNS resolver with configurable timeout
MAINTAINER:=Jo-Philipp Wich <jo@mein.io>
endef
define Package/resolveip/description
This package contains the small resolveip utility which
can be used by scripts to turn host names into numeric
IP addresses. It supports IPv4 and IPv6 resolving and
has a configurable timeout to guarantee a certain maximum
runtime in case of slow or defunct DNS servers.
endef
define Build/Compile
$(TARGET_CC) $(TARGET_CFLAGS) -Wall \
-o $(PKG_BUILD_DIR)/resolveip $(PKG_BUILD_DIR)/resolveip.c
endef
define Package/resolveip/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/resolveip $(1)/usr/bin/
endef
$(eval $(call BuildPackage,resolveip))

View File

@@ -0,0 +1,98 @@
/*
* Based on code found at https://dev.openwrt.org/ticket/4876 .
* Extended by Jo-Philipp Wich <jo@mein.io> for use in OpenWrt.
*
* You may use this program under the terms of the GPLv2 license.
*/
#include <string.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
static void abort_query(int sig)
{
exit(1);
}
static void show_usage(void)
{
printf("Usage:\n");
printf(" resolveip -h\n");
printf(" resolveip [-t timeout] hostname\n");
printf(" resolveip -4 [-t timeout] hostname\n");
printf(" resolveip -6 [-t timeout] hostname\n");
exit(255);
}
int main(int argc, char **argv)
{
int timeout = 3;
int opt;
char ipaddr[INET6_ADDRSTRLEN];
void *addr;
struct addrinfo *res, *rp;
struct sigaction sa = { .sa_handler = &abort_query };
struct addrinfo hints = {
.ai_family = AF_UNSPEC,
.ai_socktype = SOCK_STREAM,
.ai_protocol = IPPROTO_TCP,
.ai_flags = 0
};
while ((opt = getopt(argc, argv, "46t:h")) > -1)
{
switch ((char)opt)
{
case '4':
hints.ai_family = AF_INET;
break;
case '6':
hints.ai_family = AF_INET6;
break;
case 't':
timeout = atoi(optarg);
if (timeout <= 0)
show_usage();
break;
case 'h':
show_usage();
break;
}
}
if (!argv[optind])
show_usage();
sigaction(SIGALRM, &sa, NULL);
alarm(timeout);
if (getaddrinfo(argv[optind], NULL, &hints, &res))
exit(2);
for (rp = res; rp != NULL; rp = rp->ai_next)
{
addr = (rp->ai_family == AF_INET)
? (void *)&((struct sockaddr_in *)rp->ai_addr)->sin_addr
: (void *)&((struct sockaddr_in6 *)rp->ai_addr)->sin6_addr
;
if (!inet_ntop(rp->ai_family, addr, ipaddr, INET6_ADDRSTRLEN - 1))
exit(3);
printf("%s\n", ipaddr);
}
freeaddrinfo(res);
exit(0);
}

View File

@@ -0,0 +1,47 @@
#
# Copyright (C) 2011-2012 Daniel Golle <dgolle@allnet.de>
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=rssileds
PKG_RELEASE:=4
PKG_LICNESE:=GPL-2.0+
include $(INCLUDE_DIR)/package.mk
define Package/rssileds
SECTION:=net
CATEGORY:=Network
TITLE:=RSSI real-time LED indicator
DEPENDS:=+libiwinfo +libnl-tiny +libubox +libuci
MAINTAINER:=Daniel Golle <daniel@makrotopia.org>
endef
define Package/rssileds/description
A small process written in C to update the signal-strength indicator LEDs
endef
define Build/Configure
endef
TARGET_LDFLAGS += -liwinfo -luci -lubox -lnl-tiny
define Build/Compile
$(TARGET_CC) $(TARGET_CFLAGS) $(TARGET_CPPFLAGS) -Wall \
-o $(PKG_BUILD_DIR)/rssileds $(PKG_BUILD_DIR)/rssileds.c $(TARGET_LDFLAGS)
endef
define Package/rssileds/install
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/rssileds.init $(1)/etc/init.d/rssileds
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/rssileds $(1)/usr/sbin/
$(INSTALL_DIR) $(1)/usr/libexec/led-trigger
$(INSTALL_BIN) ./files/rssi $(1)/usr/libexec/led-trigger/
endef
$(eval $(call BuildPackage,rssileds))

View File

@@ -0,0 +1,3 @@
#!/bin/sh
logger -t led-trigger "LED trigger rssi is handled by /etc/init.d/rssileds"

View File

@@ -0,0 +1,75 @@
#!/bin/sh /etc/rc.common
# (C) 2012 Daniel Golle, Allnet GmbH <dgolle@allnet.de>
START=96
STOP=89
RSSILEDS_BIN="/usr/sbin/rssileds"
SERVICE_DAEMONIZE=1
SERVICE_WRITE_PID=1
start_rssid() {
local name
local dev
local threshold
local refresh
local leds
config_get name $1 name
config_get dev $1 dev
config_get threshold $1 threshold
config_get refresh $1 refresh
leds="$( cur_iface=$1 ; config_foreach get_led led )"
SERVICE_PID_FILE=/var/run/rssileds-$dev.pid
service_start $RSSILEDS_BIN $dev $refresh $threshold $leds
}
stop_rssid() {
local dev
config_get dev $1 dev
SERVICE_PID_FILE=/var/run/rssileds-$dev.pid
service_stop $RSSILEDS_BIN
}
get_led() {
local name
local sysfs
local trigger
local iface
config_get sysfs $1 sysfs
config_get name $1 name "$sysfs"
config_get trigger $1 trigger "none"
config_get iface $1 iface
config_get minq $1 minq
config_get maxq $1 maxq
config_get offset $1 offset
config_get factor $1 factor
[ "$trigger" = "rssi" ] || return
[ "$iface" = "$cur_iface" ] || return
[ ! "$minq" ] || [ ! "$maxq" ] || [ ! "$offset" ] || [ ! "$factor" ] && return
echo "none" > /sys/class/leds/$sysfs/trigger
echo "$sysfs $minq $maxq $offset $factor"
}
off_led() {
local name
local sysfs
local trigger
config_get sysfs $1 sysfs
config_get name $1 name "$sysfs"
config_get trigger $1 trigger "none"
[ "$trigger" = "rssi" ] || return
echo "0" > /sys/class/leds/$sysfs/brightness
}
start() {
[ -e /sys/class/leds/ ] && [ -x "$RSSILEDS_BIN" ] && {
config_load system
config_foreach start_rssid rssid
}
}
stop() {
config_load system
config_foreach stop_rssid rssid
config_foreach off_led led
}

View File

@@ -0,0 +1,290 @@
/*
* configurable RSSI LED control daemon for OpenWrt
* (c) 2012 Allnet GmbH, Daniel Golle <dgolle@allnet.de>
*
* 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, MA 02111-1307 USA
*
* The author may be reached as dgolle@allnet.de, or
* ALLNET GmbH
* Maistr. 2
* D-82110 Germering
* Germany
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <signal.h>
#include <unistd.h>
#include <syslog.h>
#include "iwinfo.h"
#define RUN_DIR "/var/run"
#define LEDS_BASEPATH "/sys/class/leds/"
#define BACKEND_RETRY_DELAY 500000
char *ifname;
int qual_max;
struct led {
char *sysfspath;
FILE *controlfd;
unsigned char state;
};
typedef struct rule rule_t;
struct rule {
struct led *led;
int minq;
int maxq;
int boffset;
int bfactor;
rule_t *next;
};
void log_rules(rule_t *rules)
{
rule_t *rule = rules;
while (rule)
{
syslog(LOG_INFO, " %s r: %d..%d, o: %d, f: %d\n",
rule->led->sysfspath,
rule->minq, rule->maxq,
rule->boffset, rule->bfactor);
rule = rule->next;
}
}
int set_led(struct led *led, unsigned char value)
{
char buf[8];
if ( ! led )
return -1;
if ( ! led->controlfd )
return -1;
if ( led->state == value )
return 0;
snprintf(buf, 8, "%d", value);
rewind(led->controlfd);
if ( ! fwrite(buf, sizeof(char), strlen(buf), led->controlfd) )
return -2;
fflush(led->controlfd);
led->state=value;
return 0;
}
int init_led(struct led **led, char *ledname)
{
struct led *newled;
struct stat statbuffer;
int status;
char *bp;
FILE *bfp;
bp = calloc(sizeof(char), strlen(ledname) + strlen(LEDS_BASEPATH) + 12);
if ( ! bp )
goto return_error;
sprintf(bp, "%s%s/brightness", LEDS_BASEPATH, ledname);
status = stat(bp, &statbuffer);
if ( status )
goto cleanup_fname;
bfp = fopen( bp, "w" );
if ( !bfp )
goto cleanup_fname;
if ( ferror(bfp) )
goto cleanup_fp;
/* sysfs path exists and, allocate LED struct */
newled = calloc(sizeof(struct led),1);
if ( !newled )
goto cleanup_fp;
newled->sysfspath = bp;
newled->controlfd = bfp;
*led = newled;
if ( set_led(newled, 255) )
goto cleanup_fp;
if ( set_led(newled, 0) )
goto cleanup_fp;
return 0;
cleanup_fp:
fclose(bfp);
cleanup_fname:
free(bp);
return_error:
syslog(LOG_CRIT, "can't open LED %s\n", ledname);
*led = NULL;
return -1;
}
void close_led(struct led **led)
{
fclose((*led)->controlfd);
free((*led)->sysfspath);
free((*led));
(*led)=NULL;
}
int quality(const struct iwinfo_ops *iw, const char *ifname)
{
int qual;
if ( ! iw ) return -1;
if (qual_max < 1)
if (iw->quality_max(ifname, &qual_max))
return -1;
if (iw->quality(ifname, &qual))
return -1;
return ( qual * 100 ) / qual_max ;
}
int open_backend(const struct iwinfo_ops **iw, const char *ifname)
{
*iw = iwinfo_backend(ifname);
if (!(*iw))
return 1;
return 0;
}
void update_leds(rule_t *rules, int q)
{
rule_t *rule = rules;
while (rule)
{
int b;
/* offset and factore correction according to rule */
b = ( q + rule->boffset ) * rule->bfactor;
if ( b < 0 )
b=0;
if ( b > 255 )
b=255;
if ( q >= rule->minq && q <= rule->maxq )
set_led(rule->led, (unsigned char)b);
else
set_led(rule->led, 0);
rule = rule->next;
}
}
int main(int argc, char **argv)
{
int i,q,q0,r,s;
const struct iwinfo_ops *iw = NULL;
rule_t *headrule = NULL, *currentrule = NULL;
if (argc < 9 || ( (argc-4) % 5 != 0 ) )
{
printf("syntax: %s (ifname) (refresh) (threshold) (rule) [rule] ...\n", argv[0]);
printf(" rule: (sysfs-name) (minq) (maxq) (offset) (factore)\n");
return 1;
}
ifname = argv[1];
/* refresh interval */
if ( sscanf(argv[2], "%d", &r) != 1 )
return 1;
/* sustain threshold */
if ( sscanf(argv[3], "%d", &s) != 1 )
return 1;
openlog("rssileds", LOG_PID, LOG_DAEMON);
syslog(LOG_INFO, "monitoring %s, refresh rate %d, threshold %d\n", ifname, r, s);
currentrule = headrule;
for (i=4; i<argc; i=i+5) {
if (! currentrule)
{
/* first element in the list */
currentrule = calloc(sizeof(rule_t),1);
headrule = currentrule;
}
else
{
/* follow-up element */
currentrule->next = calloc(sizeof(rule_t),1);
currentrule = currentrule->next;
}
if ( init_led(&(currentrule->led), argv[i]) )
return 1;
if ( sscanf(argv[i+1], "%d", &(currentrule->minq)) != 1 )
return 1;
if ( sscanf(argv[i+2], "%d", &(currentrule->maxq)) != 1 )
return 1;
if ( sscanf(argv[i+3], "%d", &(currentrule->boffset)) != 1 )
return 1;
if ( sscanf(argv[i+4], "%d", &(currentrule->bfactor)) != 1 )
return 1;
}
log_rules(headrule);
q0 = -1;
do {
q = quality(iw, ifname);
if ( q < q0 - s || q > q0 + s ) {
update_leds(headrule, q);
q0=q;
};
// re-open backend...
if ( q == -1 && q0 == -1 ) {
if (iw) {
iwinfo_finish();
iw=NULL;
usleep(BACKEND_RETRY_DELAY);
}
while (open_backend(&iw, ifname))
usleep(BACKEND_RETRY_DELAY);
}
usleep(r);
} while(1);
iwinfo_finish();
return 0;
}

View File

@@ -0,0 +1,66 @@
#
# Copyright (C) 2007-2011 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:=tcpdump
PKG_VERSION:=4.99.5
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://www.tcpdump.org/release/
PKG_HASH:=8c75856e00addeeadf70dad67c9ff3dd368536b2b8563abf6854d7c764cd3adb
PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
PKG_LICENSE:=BSD-3-Clause
PKG_CPE_ID:=cpe:/a:tcpdump:tcpdump
PKG_INSTALL:=1
PKG_BUILD_FLAGS:=gc-sections
PKG_BUILD_PARALLEL:=1
include $(INCLUDE_DIR)/package.mk
define Package/tcpdump/default
SECTION:=net
CATEGORY:=Network
DEPENDS:=+libpcap
TITLE:=Network monitoring and data acquisition tool
URL:=http://www.tcpdump.org/
endef
define Package/tcpdump
$(Package/tcpdump/default)
VARIANT:=full
endef
define Package/tcpdump-mini
$(Package/tcpdump/default)
TITLE+= (minimal version)
VARIANT:=mini
endef
CONFIGURE_ARGS += \
--without-cap-ng \
--without-crypto \
$(call autoconf_bool,CONFIG_IPV6,ipv6)
ifeq ($(BUILD_VARIANT),mini)
TARGET_CFLAGS += -DTCPDUMP_MINI
CONFIGURE_ARGS += --disable-smb
MAKE_FLAGS += TCPDUMP_MINI=1
endif
define Package/tcpdump/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/tcpdump $(1)/usr/bin/
endef
Package/tcpdump-mini/install = $(Package/tcpdump/install)
$(eval $(call BuildPackage,tcpdump))
$(eval $(call BuildPackage,tcpdump-mini))

Some files were not shown because too many files have changed in this diff Show More