[patchteam] WING version bump / updates for HNA and fixes for some scripts

git-svn-id: svn://svn.openwrt.org/openwrt/packages@22868 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
dingo
2010-09-01 14:41:49 +00:00
parent ca799d93a3
commit 82d12458d3
3 changed files with 128 additions and 129 deletions

View File

@ -1,17 +1,17 @@
# Wing configuration # Wing configuration
choice choice
prompt "Version" prompt "Version"
depends on PACKAGE_wing depends on PACKAGE_wing
default WING_STABLE default WING_STABLE
help help
This option allows you to select the version of Wing to be built. This option allows you to select the version of Wing to be built.
config WING_STABLE config WING_STABLE
bool "Use the stable version (multi-interface)" bool "Use the stable version (multi-interface)"
config WING_TESTING config WING_TESTING
bool "Use the unstable version (multi-interfaces w/ ITACA)" bool "Use the unstable version (multi-interfaces w/ ITACA)"
endchoice endchoice

View File

@ -10,13 +10,13 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=wing PKG_NAME:=wing
ifneq ($(CONFIG_WING_STABLE),) ifneq ($(CONFIG_WING_STABLE),)
PKG_VERSION:=20100805 PKG_VERSION:=20100827
PKG_RELEASE:=1 PKG_RELEASE:=2
PKG_REV:=21aae2ae5bea85426aded47b055b4fe62c2cea2e PKG_REV:=6f238baa6c4f357f1fe0e55f1b71db7816747b33
else else
PKG_VERSION:=$(shell date +%Y%m%d) PKG_VERSION:=$(shell date +%Y%m%d)
PKG_RELEASE:=1 PKG_RELEASE:=1
PKG_REV:=HEAD PKG_REV:=HEAD
endif endif
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
@ -30,12 +30,12 @@ PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/package.mk
define Package/wing define Package/wing
TITLE:=Wireless mesh networking toolkit TITLE:=Wireless mesh networking toolkit
SECTION:=net SECTION:=net
CATEGORY:=Network CATEGORY:=Network
MAINTAINER:=Roberto Riggio <roberto.riggio@create-net.org> MAINTAINER:=Roberto Riggio (roberto.riggio@create-net.org)
DEPENDS:=+kmod-tun DEPENDS:=+kmod-tun
URL:=http://www.wing-project.org/ URL:=http://www.wing-project.org/
endef endef
define Package/wing/Description define Package/wing/Description

View File

@ -1,145 +1,144 @@
scan_wing() { scan_wing() {
config_set "$1" device "wing-$1" config_set "$1" device "wing-$1"
} }
coldplug_interface_wing() { coldplug_interface_wing() {
setup_interface_wing "wing-$1" "$1" setup_interface_wing "wing-$1" "$1"
} }
stop_interface_wing() { stop_interface_wing() {
local config="$1" local config="$1"
local iface="wing-$config" local iface="wing-$config"
env -i ACTION="ifdown" INTERFACE="$config" DEVICE="$iface" PROTO=wing /sbin/hotplug-call "iface"& env -i ACTION="ifdown" INTERFACE="$config" DEVICE="$iface" PROTO=wing /sbin/hotplug-call "iface" &
[ -f "/var/run/$iface.pid" ]&& { [ -f "/var/run/$iface.pid" ] && {
kill -9 $(cat /var/run/$iface.pid) kill -9 $(cat /var/run/$iface.pid)
rm /var/run/$iface.pid rm /var/run/$iface.pid
} }
} }
setup_interface_wing() { setup_interface_wing() {
local iface="$1" local iface="$1"
local config="$2" local config="$2"
local hwmodes="" local hwmodes=""
local freqs="" local freqs=""
local ifnames="" local ifnames=""
local hwaddrs="" local hwaddrs=""
config_load wireless config_load wireless
config_foreach wing_list_interfaces wifi-iface config_foreach wing_list_interfaces wifi-iface
# start click router # start click router
if [ "$hwmodes" = "" -o "$freqs" = "" -o "$ifnames" = "" -o "$hwaddrs" = "" ]; then if [ "$hwmodes" = "" -o "$freqs" = "" -o "$ifnames" = "" -o "$hwaddrs" = "" ]; then
logger -t "$config" "No raw interfaces available. Exiting." logger -t "$config" "No raw interfaces available. Exiting."
exit 1 exit 1
fi fi
local profile rc ls prefix debug local profile rc ls prefix debug
config_get profile $config profile "bulk" config_get profile $config profile "bulk"
config_get rc $config rc "static" config_get rc $config rc "static"
config_get ls $config ls "fcfs" config_get ls $config ls "fcfs"
config_get metric $config metric "wcett" config_get metric $config metric "wcett"
config_get prefix $config prefix "6" config_get prefix $config prefix "6"
config_get period $config period "10000" config_get period $config period "10000"
config_get tau $config tau "100000" config_get tau $config tau "100000"
config_get_bool debug $config debug "False" config_get_bool debug $config debug "False"
local hwaddr=$(echo $hwaddrs | sed 's/ .*//'); local hwaddr=$(echo $hwaddrs | sed 's/ .*//');
local ipaddr=$(printf "$prefix.%d.%d.%d" $(echo $hwaddr | awk -F: '{printf "0x%s 0x%s 0x%s",$4,$5,$6}')) local ipaddr=$(printf "$prefix.%d.%d.%d" $(echo $hwaddr | awk -F: '{printf "0x%s 0x%s 0x%s",$4,$5,$6}'))
local netmask=255.0.0.0 local netmask=255.0.0.0
if ! wing_template_available "profile" "$profile" "bulk"; then if ! wing_template_available "profile" "$profile" "bulk"; then
logger -t "$config" "Unable to configure router. Exiting." logger -t "$config" "Unable to configure router. Exiting."
exit 1 exit 1
fi fi
if ! wing_template_available "rc" "$rc" "static"; then if ! wing_template_available "rc" "$rc" "static"; then
logger -t "$config" "Unable to configure rate control. Exiting." logger -t "$config" "Unable to configure rate control. Exiting."
exit 1 exit 1
fi fi
if ! wing_template_available "ls" "$ls" "radiotap"; then if ! wing_template_available "ls" "$ls" "radiotap"; then
logger -t "$config" "Unable to configure link scheduler. Exiting." logger -t "$config" "Unable to configure link scheduler. Exiting."
exit 1 exit 1
fi fi
if [ "$profile" = "" -o "$rc" = "" ]; then if [ "$profile" = "" -o "$rc" = "" ]; then
logger -t "$config" "Unable to generate template. Exiting." logger -t "$config" "Unable to generate template. Exiting."
exit 1 exit 1
fi fi
[ "$debug" == 0 ]&& dbg="" || dbg="-d" [ "$debug" == 0 ] && dbg="" || dbg="-d"
/usr/bin/click_config -p $profile -r $rc -s $ls -l $metric \ /usr/bin/click_config -p $profile -r $rc -s $ls -l $metric \
-m "$hwmodes" -c "$freqs" -n "$ifnames" -a "$hwaddrs" $dbg \ -m "$hwmodes" -c "$freqs" -n "$ifnames" -a "$hwaddrs" $dbg \
| sed -e "s/__XR_IFNAME__/$iface/g" \ | sed -e "s/__XR_IFNAME__/$iface/g" \
| sed -e "s/__XR_IP__/$ipaddr/g" \ | sed -e "s/__XR_IP__/$ipaddr/g" \
| sed -e "s/__XR_NM__/$netmask/g" \ | sed -e "s/__XR_NM__/$netmask/g" \
| sed -e "s/__XR_PERIOD__/$period/g" \ | sed -e "s/__XR_PERIOD__/$period/g" \
| sed -e "s/__XR_TAU__/$tau/g"> /tmp/$iface.click | sed -e "s/__XR_TAU__/$tau/g" > /tmp/$iface.click
/usr/bin/click-align /tmp/$iface.click> /tmp/$iface-aligned.click 2>/var/log/$iface.log /usr/bin/click-align /tmp/$iface.click > /tmp/$iface-aligned.click 2>/var/log/$iface.log
[ ! -c /dev/net/tun ]&& { [ ! -c /dev/net/tun ] && {
mkdir -p /dev/net/ mkdir -p /dev/net/
mknod /dev/net/tun c 10 200 mknod /dev/net/tun c 10 200
if [ ! -c /dev/net/tun ]; then if [ ! -c /dev/net/tun ]; then
logger -t "$config" "Device not available (/dev/net/tun). Exiting." logger -t "$config" "Device not available (/dev/net/tun). Exiting."
exit 1 exit 1
fi fi
} }
# creating the tun interface below will trigger a net subsystem event # creating the tun interface below will trigger a net subsystem event
# prevent it from touching iface by disabling .auto here # prevent it from touching iface by disabling .auto here
uci_set_state network "$config" auto 0 uci_set_state network "$config" auto 0
(/usr/bin/click /tmp/$iface-aligned.click>> /var/log/$iface.log 2>&1&)& (/usr/bin/click /tmp/$iface-aligned.click >> /var/log/$iface.log 2>&1 &) &
sleep 2 sleep 2
ps | grep /usr/bin/click | grep -q -v grep || { ps | grep /usr/bin/click | grep -q -v grep || {
logger -t "$config" "Unable to start click. Exiting." logger -t "$config" "Unable to start click. Exiting."
exit 1 exit 1
} }
ps | grep /usr/bin/click | grep -v grep | awk '{print $1}'> /var/run/$iface.pid ps | grep /usr/bin/click | grep -v grep | awk '{print $1}' > /var/run/$iface.pid
ifconfig "$iface" "$ipaddr" netmask "$netmask" ifconfig "$iface" "$ipaddr" netmask "$netmask"
uci_set_state network $config ipaddr "$ipaddr" uci_set_state network $config ipaddr "$ipaddr"
uci_set_state network $config netmask "$netmask" uci_set_state network $config netmask "$netmask"
env -i ACTION="ifup" INTERFACE="$config" DEVICE="$iface" PROTO=wing /sbin/hotplug-call "iface"& env -i ACTION="ifup" INTERFACE="$config" DEVICE="$iface" PROTO=wing /sbin/hotplug-call "iface" &
} }
wing_template_available() { # prefix, template, default wing_template_available() { # prefix, template, default
local template="/etc/wing/$1.$2.click" local template="/etc/wing/$1.$2.click"
[ ! -f $template ]&& { [ ! -f $template ] && {
template="/etc/wing/$1.$3.click" template="/etc/wing/$1.$3.click"
[ ! -f $template ]&& { [ ! -f $template ] && {
return 1 return 1
} }
} }
return 0 return 0
} }
wing_list_interfaces() { wing_list_interfaces() {
local channel freq hwmode hwaddr ifname mode local channel freq hwmode hwaddr ifname mode
config_get ifname $1 ifname config_get mode $1 mode
config_get mode $1 mode config_get_bool up $1 up
config_get device $1 device [ "$up" = "1" -a "$mode" = "monitor" ] || return 0
config_get_bool up $1 up config_get ifname $1 ifname
[ "$up" = "1" -a "$mode" = "monitor" ] || return 0 config_get device $1 device
config_get hwmode $device hwmode "11b" config_get hwmode $device hwmode "11bg"
config_get channel $device channel "1" freq=$(iwlist $ifname freq | grep "Current Frequency" | sed -n "s/^.*Current Frequency:\([0-9.]*\) GHz (Channel \([0-9]*\))/\1/p" | awk '{print $1*1000}')
freq=$(iwlist $ifname freq | sed -n "s/^.*Channel 0*$channel : \([0-9.]*\).*/\1/p" | awk '{print $1*1000}') hwaddr=$(/sbin/ifconfig $ifname 2>&1 | sed -n 's/^.*HWaddr \([0-9A-Za-z\-]*\).*/\1/p' | sed -e 's/\-/:/g' | cut -c1-17)
hwaddr=$(/sbin/ifconfig $ifname 2>&1 | sed -n 's/^.*HWaddr \([0-9A-Za-z\-]*\).*/\1/p' | sed -e 's/\-/:/g' | cut -c1-17) freqs=${freqs:+"$freqs "}$freq
freqs=${freqs:+"$freqs "}$freq hwmodes=${hwmodes:+"$hwmodes "}$hwmode
hwmodes=${hwmodes:+"$hwmodes "}$hwmode hwaddrs=${hwaddrs:+"$hwaddrs "}$hwaddr
hwaddrs=${hwaddrs:+"$hwaddrs "}$hwaddr ifnames=${ifnames:+"$ifnames "}$ifname
ifnames=${ifnames:+"$ifnames "}$ifname /sbin/ifconfig $ifname mtu 1900
/sbin/ifconfig $ifname mtu 1900 /sbin/ifconfig $ifname txqueuelen 5
/sbin/ifconfig $ifname txqueuelen 5 /sbin/ifconfig $ifname up
/sbin/ifconfig $ifname up
} }