mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2026-01-27 17:37:18 +01:00
BarrierBreaker
This commit is contained in:
commit
59972d8b74
5535 changed files with 1067736 additions and 0 deletions
57
6relayd/Makefile
Normal file
57
6relayd/Makefile
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
#
|
||||
# Copyright (C) 2012 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=6relayd
|
||||
PKG_VERSION:=2013-07-26
|
||||
PKG_RELEASE=$(PKG_SOURCE_VERSION)
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
PKG_SOURCE_URL:=git://github.com/sbyx/6relayd.git
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_VERSION:=2ed520c500b0fbb484cfad5687eb39a0da43dcf7
|
||||
|
||||
PKG_MAINTAINER:=Steven Barth <steven@midlink.org>
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(INCLUDE_DIR)/cmake.mk
|
||||
|
||||
define Package/6relayd
|
||||
SECTION:=ipv6
|
||||
CATEGORY:=IPv6
|
||||
TITLE:=DHCPv6(-PD)/RA Server & Relay
|
||||
DEPENDS:=+kmod-ipv6
|
||||
endef
|
||||
|
||||
define Package/6relayd/description
|
||||
6relayd is a daemon for serving and relaying IPv6 management protocols to
|
||||
configure clients and downstream routers.
|
||||
|
||||
6relayd provides server services for RA, stateless DHCPv6, DHCPv6-PD and can
|
||||
be used to relay RA, DHCPv6 and NDP between routed (non-bridged) interfaces
|
||||
in case no delegated prefixes are provided by the upstream router.
|
||||
endef
|
||||
|
||||
define Package/6relayd/conffiles
|
||||
/etc/config/6relayd
|
||||
endef
|
||||
|
||||
define Package/6relayd/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin/
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/6relayd $(1)/usr/sbin/
|
||||
$(INSTALL_BIN) ./files/6relayd-update $(1)/usr/sbin/
|
||||
$(INSTALL_DIR) $(1)/etc/hotplug.d/iface
|
||||
$(INSTALL_DATA) ./files/6relayd.hotplug $(1)/etc/hotplug.d/iface/30-6relay
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_DATA) ./files/6relayd.config $(1)/etc/config/6relayd
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/6relayd.init $(1)/etc/init.d/6relayd
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,6relayd))
|
||||
3
6relayd/files/6relayd-update
Executable file
3
6relayd/files/6relayd-update
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
# Make dnsmasq reread hostfile
|
||||
killall -SIGHUP dnsmasq
|
||||
8
6relayd/files/6relayd.config
Normal file
8
6relayd/files/6relayd.config
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
config server 'default'
|
||||
list network 'lan'
|
||||
option rd 'server'
|
||||
option dhcpv6 'server'
|
||||
option management_level '1'
|
||||
option compat_ula '1'
|
||||
|
||||
|
||||
32
6relayd/files/6relayd.hotplug
Normal file
32
6relayd/files/6relayd.hotplug
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#!/bin/sh
|
||||
/etc/init.d/6relayd enabled || exit 0
|
||||
[ -n "$INTERFACE" ] || exit 0
|
||||
|
||||
. /lib/functions/network.sh
|
||||
mkdir -p /tmp/ipv6
|
||||
|
||||
local prevprefix6=""
|
||||
local curprefix6=""
|
||||
local prefix6file=/tmp/ipv6/$INTERFACE-prefix6
|
||||
prevprefix6=$(cat $prefix6file 2>/dev/null)
|
||||
network_get_prefix6 curprefix6 $INTERFACE
|
||||
[ -n "$curprefix6" ] && echo $curprefix6 > $prefix6file || rm -f $prefix6file
|
||||
|
||||
local prevgateway6=""
|
||||
local curgateway6=""
|
||||
local gateway6file=/tmp/ipv6/$INTERFACE-gateway6
|
||||
prevgateway6=$(cat $gateway6file 2>/dev/null)
|
||||
network_get_gateway6 curgateway6 $INTERFACE
|
||||
[ -n "$curgateway6" ] && echo $curgateway6 > $gateway6file || rm -f $gateway6file
|
||||
|
||||
local prevsubnets6=""
|
||||
local cursubnets6=""
|
||||
local subnets6file=/tmp/ipv6/$INTERFACE-subnets6
|
||||
prevsubnets6=$(cat $subnets6file 2>/dev/null)
|
||||
network_get_subnets6 cursubnets6 $INTERFACE
|
||||
[ -n "$cursubnets6" ] && echo $cursubnets6 > $subnets6file || rm -f $subnets6file
|
||||
|
||||
[ "$prevprefix6" = "$curprefix6" -a "$prevgateway6" = "$curgateway6" -a "$prevsubnets6" = "$cursubnets6" ] && exit 0
|
||||
|
||||
. /etc/init.d/6relayd
|
||||
restart_affected "$INTERFACE"
|
||||
161
6relayd/files/6relayd.init
Normal file
161
6relayd/files/6relayd.init
Normal file
|
|
@ -0,0 +1,161 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (c) 2011-2012 OpenWrt.org
|
||||
START=80
|
||||
args=""
|
||||
|
||||
add_static_lease() {
|
||||
local cfg="$1"
|
||||
|
||||
local duid id
|
||||
config_get duid "$cfg" duid
|
||||
config_get id "$cfg" id
|
||||
|
||||
[ -n "$duid" -a -n "$id" ] && append args "-a$duid:$id"
|
||||
|
||||
}
|
||||
|
||||
start_6relayd() {
|
||||
local cfg="$1"
|
||||
local mode="$2"
|
||||
args="-l/tmp/hosts/6relayd,/usr/sbin/6relayd-update"
|
||||
|
||||
SERVICE_DAEMONIZE=1
|
||||
SERVICE_WRITE_PID=1
|
||||
SERVICE_PID_FILE="/var/run/6relayd-$cfg.pid"
|
||||
[ -f "$SERVICE_PID_FILE" ] && {
|
||||
if grep -q 6relayd "/proc/$(cat $SERVICE_PID_FILE)/cmdline"; then
|
||||
return 0
|
||||
else
|
||||
rm -f "$SERVICE_PID_FILE"
|
||||
fi
|
||||
}
|
||||
|
||||
# Detect master interface
|
||||
local master masterif
|
||||
config_get masterif "$cfg" master
|
||||
network_get_device master "$masterif"
|
||||
[ -z "$master" ] && master="."
|
||||
|
||||
# Detect slave interfaces
|
||||
local slaves=""
|
||||
local slaveifs
|
||||
config_get slaveifs "$cfg" network
|
||||
for slaveif in $slaveifs; do
|
||||
local slave
|
||||
network_get_device slave "$slaveif"
|
||||
# Compatibility with old config format
|
||||
if [ "$mode" = "relay" -a "$master" = "." ]; then
|
||||
[ -z "$slave" ] && return 0
|
||||
master="$slave"
|
||||
else
|
||||
[ -n "$slave" ] && append slaves "$slave"
|
||||
fi
|
||||
done
|
||||
|
||||
# Bail if no slaves are active
|
||||
[ -z "$slaves" ] && return 0
|
||||
|
||||
# Configure services
|
||||
local rd dhcpv6 ndp
|
||||
config_get rd "$cfg" rd
|
||||
config_get dhcpv6 "$cfg" dhcpv6
|
||||
config_get ndp "$cfg" ndp
|
||||
|
||||
# Test for fallback mode
|
||||
local fallback fallback_relay
|
||||
config_get fallback_relay "$cfg" fallback_relay
|
||||
|
||||
if [ -n "$fallback_relay" -a "$master" != "." ]; then
|
||||
local prefix
|
||||
network_get_prefix6 prefix "$masterif"
|
||||
[ -z "$prefix" ] && fallback=1
|
||||
fi
|
||||
|
||||
if [ -n "$fallback" ]; then
|
||||
for service in $fallback_relay; do
|
||||
eval "$service=relay"
|
||||
done
|
||||
fi
|
||||
|
||||
# Configure feature options
|
||||
local always_rewrite_dns rewrite_dns_addr
|
||||
config_get_bool always_rewrite_dns "$cfg" always_rewrite_dns 0
|
||||
config_get rewrite_dns_addr "$cfg" rewrite_dns_addr
|
||||
[ "$always_rewrite_dns" -eq 1 -o -n "$rewrite_dns_addr" ] && append args "-n$rewrite_dns_addr"
|
||||
|
||||
local always_assume_default
|
||||
config_get_bool always_assume_default "$cfg" always_assume_default 0
|
||||
[ "$always_assume_default" -eq 1 ] && append args "-u"
|
||||
|
||||
local compat_ula
|
||||
config_get_bool compat_ula "$cfg" compat_ula 0
|
||||
[ "$compat_ula" -eq 1 ] && append args "-c"
|
||||
|
||||
local management_level
|
||||
config_get management_level "$cfg" management_level
|
||||
[ -n "$management_level" ] && append args "-m$management_level"
|
||||
|
||||
local management_offlink
|
||||
config_get_bool management_offlink "$cfg" management_offlink 0
|
||||
[ "$management_offlink" -eq 1 ] && append args "-o"
|
||||
|
||||
local management_preference
|
||||
config_get management_preference "$cfg" management_preference
|
||||
[ -n "$management_preference" ] && append args "-i$management_preference"
|
||||
|
||||
config_foreach add_static_lease lease
|
||||
|
||||
[ "$ndp" = "relay" ] && append args "-N -s"
|
||||
[ "$rd" = "relay" ] && append args "-Rrelay"
|
||||
[ "$rd" = "server" ] && append args "-Rserver"
|
||||
[ "$dhcpv6" = "relay" ] && append args "-Drelay"
|
||||
[ "$dhcpv6" = "server" ] && append args "-Dserver"
|
||||
[ "$ndp" != "relay" -a "$rd" != "relay" -a "$dhcpv6" != "relay" ] && master="."
|
||||
|
||||
service_start /usr/sbin/6relayd $args $master $slaves
|
||||
}
|
||||
|
||||
restart_affected_6relayd() {
|
||||
local cfg="$1"
|
||||
local net="$2"
|
||||
local mode="$3"
|
||||
|
||||
local master slaves
|
||||
config_get master "$cfg" master
|
||||
config_get slaves "$cfg" network
|
||||
|
||||
for iface in $master $slaves; do
|
||||
if [ "$iface" = "$net" ]; then
|
||||
SERVICE_PID_FILE="/var/run/6relayd-$cfg.pid"
|
||||
service_stop /usr/sbin/6relayd
|
||||
rm -f "$SERVICE_PID_FILE"
|
||||
start_6relayd "$cfg" "$mode"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
restart_affected() {
|
||||
. /lib/functions/service.sh
|
||||
. /lib/functions/network.sh
|
||||
local net="$1"
|
||||
config_load 6relayd
|
||||
config_foreach restart_affected_6relayd server "$net"
|
||||
config_foreach restart_affected_6relayd relay "$net" "relay"
|
||||
}
|
||||
|
||||
stop() {
|
||||
. /lib/functions/service.sh
|
||||
for pid in /var/run/6relayd-*.pid; do
|
||||
SERVICE_PID_FILE="$pid"
|
||||
service_stop /usr/sbin/6relayd
|
||||
rm -f "$SERVICE_PID_FILE"
|
||||
done
|
||||
}
|
||||
|
||||
start() {
|
||||
. /lib/functions/service.sh
|
||||
. /lib/functions/network.sh
|
||||
config_load 6relayd
|
||||
config_foreach start_6relayd server
|
||||
config_foreach start_6relayd relay relay
|
||||
}
|
||||
57
af_alg/Makefile
Normal file
57
af_alg/Makefile
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
#
|
||||
# Copyright (C) 2006-2010 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_RELEASE:=1
|
||||
PKG_VERSION:=1
|
||||
PKG_SOURCE_URL:=git://git.carnivore.it/users/common/af_alg.git
|
||||
PKG_SOURCE_VERSION:=1851bbb010c38878c83729be844f168192059189
|
||||
|
||||
PKG_NAME:=af_alg
|
||||
PKG_VERSION:=0.1
|
||||
|
||||
DEPENDS:=libopenssl
|
||||
|
||||
export BUILD_DIR
|
||||
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
|
||||
|
||||
TARGET_LDFLAGS+= \
|
||||
-Wl,-rpath-link=$(STAGING_DIR)/usr/lib
|
||||
MAKE_FLAGS += TARGET="$(target)"
|
||||
TARGET_CFLAGS += -Dtarget_$(target)=1 -Wall
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
|
||||
define Package/af_alg
|
||||
CATEGORY:=Libraries
|
||||
TITLE:=Openssl af_alg engine
|
||||
URL:=
|
||||
endef
|
||||
|
||||
define Package/af_alg/description
|
||||
Openssl af_alg engine
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
$(MAKE_VARS) \
|
||||
$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/$(MAKE_PATH) \
|
||||
$(MAKE_FLAGS)
|
||||
endef
|
||||
|
||||
define Package/af_alg/install
|
||||
$(INSTALL_DIR) $(1)/usr
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(INSTALL_DIR) $(1)/usr/lib/engines
|
||||
cp $(PKG_BUILD_DIR)/libaf_alg.so $(1)/usr/lib/engines/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,af_alg))
|
||||
11
af_alg/patches/001-Makefile_fix.patch
Normal file
11
af_alg/patches/001-Makefile_fix.patch
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
--- a/Makefile 2014-02-17 13:00:44.161670649 +0100
|
||||
+++ b/Makefile 2014-02-17 13:00:51.633670316 +0100
|
||||
@@ -24,7 +24,7 @@
|
||||
LDFLAGS =
|
||||
|
||||
SPEC_LDFLAGS = \
|
||||
- -lcrypto
|
||||
+ -lcrypt
|
||||
|
||||
CC = cc
|
||||
LD = $(CC)
|
||||
188
alleato-base/Makefile
Normal file
188
alleato-base/Makefile
Normal file
|
|
@ -0,0 +1,188 @@
|
|||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=alleato-base
|
||||
|
||||
PKG_VERSION:=14.49.2
|
||||
PKG_RELEASE=$(PKG_SOURCE_VERSION)
|
||||
PKG_SOURCE_URL:=git@iopsys.inteno.se:alleato_base.git
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_VERSION:=8314aed451255410a2cd4fa43ac3235504e8f018
|
||||
|
||||
PKG_MAINTAINER:=Martin Assarsson, ALLEATO
|
||||
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
######################################################
|
||||
|
||||
define Package/alleato3
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
SUBMENU:=Alleato
|
||||
DEPENDS:=+python
|
||||
TITLE:=Alleato python libraries
|
||||
endef
|
||||
|
||||
define Package/zwaved
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
SUBMENU:=Alleato
|
||||
DEPENDS:=+jansson
|
||||
TITLE:=Alleato zwave daemon
|
||||
endef
|
||||
|
||||
define Package/zwave-mgr
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
SUBMENU:=Alleato
|
||||
DEPENDS:=+alleato3
|
||||
TITLE:=Alleato zwave manager
|
||||
endef
|
||||
|
||||
define Package/zwave-profiler
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
SUBMENU:=Alleato
|
||||
DEPENDS:=+alleato3
|
||||
TITLE:=Alleato zwave profiler
|
||||
endef
|
||||
|
||||
define Package/alleato-scheduler
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
SUBMENU:=Alleato
|
||||
DEPENDS:=+alleato3
|
||||
TITLE:=Alleato scheduler
|
||||
endef
|
||||
|
||||
define Package/alleato-boxconfig
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
SUBMENU:=Alleato
|
||||
DEPENDS:=+alleato3
|
||||
TITLE:=Alleato boxconfig
|
||||
endef
|
||||
|
||||
define Package/all-omc
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
SUBMENU:=Alleato
|
||||
DEPENDS:=+alleato3 +screen
|
||||
TITLE:=Alleato remote tunnel
|
||||
endef
|
||||
|
||||
define Package/ubus-kicker
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
SUBMENU:=Alleato
|
||||
DEPENDS:=
|
||||
TITLE:=Alleato ubus-kicker
|
||||
endef
|
||||
|
||||
define Package/mqttnagios
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
SUBMENU:=Alleato
|
||||
DEPENDS:=
|
||||
TITLE:=Alleato mqttnagios
|
||||
endef
|
||||
|
||||
define Package/all4-alleato-tools
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
SUBMENU:=Alleato
|
||||
DEPENDS:=
|
||||
TITLE:=Alleato tools
|
||||
endef
|
||||
|
||||
######################################################
|
||||
|
||||
define Package/alleato3/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib/python2.7/
|
||||
$(CP) -r $(PKG_BUILD_DIR)/python-2.7/* $(1)/usr/lib/python2.7/
|
||||
endef
|
||||
|
||||
define Package/zwaved/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/init.d
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/init.d/zwaved $(1)/etc/init.d/zwaved
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/binaries/zwaved $(1)/usr/sbin/zwaved
|
||||
endef
|
||||
|
||||
define Package/zwave-mgr/install
|
||||
$(INSTALL_DIR) $(1)/usr/mqttrules $(1)/etc/init.d $(1)/etc/alleato/
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/init.d/zwave-mgr $(1)/etc/init.d/zwave-mgr
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/binaries/zwave_mgr $(1)/usr/mqttrules/zwave_mgr
|
||||
endef
|
||||
|
||||
define Package/zwave-profiler/install
|
||||
$(INSTALL_DIR) $(1)/usr/mqttrules $(1)/etc/init.d
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/init.d/zwave-profiler $(1)/etc/init.d/zwave-profiler
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/binaries/zwave-profiler $(1)/usr/mqttrules/zwave-profiler
|
||||
endef
|
||||
|
||||
define Package/alleato-scheduler/install
|
||||
$(INSTALL_DIR) $(1)/usr/mqttrules $(1)/etc/init.d $(1)/etc/crontabs/sched
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/init.d/scheduler $(1)/etc/init.d/scheduler
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/binaries/scheduler $(1)/usr/mqttrules/scheduler
|
||||
$(INSTALL_DATA) $(PKG_BUILD_DIR)/data/schedule $(1)/etc/crontabs/sched/schedule
|
||||
$(INSTALL_DATA) $(PKG_BUILD_DIR)/data/schedule $(1)/etc/crontabs/schedule
|
||||
endef
|
||||
|
||||
define Package/alleato-boxconfig/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin $(1)/usr/bin $(1)/etc/init.d $(1)/etc/alleato $(1)/home/mosquitto
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/init.d/boxconfig $(1)/etc/init.d/boxconfig
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/binaries/boxconfig $(1)/usr/bin/boxconfig
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/binaries/genmosquittoconf $(1)/usr/bin/genmosquittoconf
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/binaries/check_client_id $(1)/usr/sbin/check_client_id
|
||||
$(INSTALL_DATA) $(PKG_BUILD_DIR)/data/boxconfig.conf $(1)/etc/boxconfig.conf
|
||||
endef
|
||||
|
||||
define Package/all-omc/install
|
||||
$(INSTALL_DIR) $(1)/root $(1)/etc/init.d $(1)/etc/config $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/init.d/omc $(1)/etc/init.d/omc
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/root/ssh_key $(1)/root/ssh_key
|
||||
$(INSTALL_DATA) $(PKG_BUILD_DIR)/data/alleato.config $(1)/etc/config/alleato
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/binaries/omc $(1)/usr/bin/omc
|
||||
endef
|
||||
|
||||
define Package/ubus-kicker/install
|
||||
$(INSTALL_DIR) $(1)/etc/init.d $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/init.d/ubus-kicker $(1)/etc/init.d/ubus-kicker
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/binaries/ubus-kicker $(1)/usr/sbin/ubus-kicker
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/binaries/akick $(1)/usr/sbin/akick
|
||||
endef
|
||||
|
||||
define Package/mqttnagios/install
|
||||
$(INSTALL_DIR) $(1)/etc/nagios.d $(1)/usr/bin $(1)/etc/crontabs $(1)/etc/init.d
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/init.d/mqttnagios $(1)/etc/init.d/mqttnagios
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/binaries/send_mqtt_nag $(1)/usr/bin/send_mqtt_nag
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/nagios.d/dropbear $(1)/etc/nagios.d/dropbear.nag
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/nagios.d/mosquitto $(1)/etc/nagios.d/mosquitto.nag
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/nagios.d/ssh $(1)/etc/nagios.d/ssh.nag
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/nagios.d/zwaved $(1)/etc/nagios.d/zwaved.nag
|
||||
$(INSTALL_DATA) $(PKG_BUILD_DIR)/data/mqttnagios $(1)/etc/crontabs/mqttnagios
|
||||
echo '/5 * * * * /usr/sbin/check_client_id' >> $(1)/etc/crontabs/root
|
||||
endef
|
||||
|
||||
define Package/all4-alleato-tools/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin $(1)/etc/init.d $(1)/opt/alleato
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/init.d/house $(1)/etc/init.d/house
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/init.d/rulesd $(1)/etc/init.d/rulesd
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/binaries/alleato_tools $(1)/usr/bin/alleato_tools
|
||||
endef
|
||||
|
||||
######################################################
|
||||
|
||||
$(eval $(call BuildPackage,alleato3))
|
||||
$(eval $(call BuildPackage,zwaved))
|
||||
$(eval $(call BuildPackage,zwave-mgr))
|
||||
$(eval $(call BuildPackage,zwave-profiler))
|
||||
$(eval $(call BuildPackage,alleato-scheduler))
|
||||
$(eval $(call BuildPackage,alleato-boxconfig))
|
||||
$(eval $(call BuildPackage,all-omc))
|
||||
$(eval $(call BuildPackage,ubus-kicker))
|
||||
$(eval $(call BuildPackage,mqttnagios))
|
||||
$(eval $(call BuildPackage,all4-alleato-tools))
|
||||
51
ami_tool/Makefile
Normal file
51
ami_tool/Makefile
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
#
|
||||
# Copyright (C) 2013 Inteno
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=ami
|
||||
PKG_VERSION:=1.0.0
|
||||
PKG_RELEASE:=1
|
||||
|
||||
#PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
|
||||
#STAMP_PREPARED := $(STAMP_PREPARED)_$(call confvar,CONFIG_MTD_REDBOOT_PARTS)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
target=$(firstword $(subst -, ,$(BOARD)))
|
||||
|
||||
TARGET_LDFLAGS+= \
|
||||
-Wl,-rpath-link=$(STAGING_DIR)/usr/lib \
|
||||
-Wl,-rpath-link=$(STAGING_DIR)/lib -luci -lubus -lubox -lpthread
|
||||
|
||||
TARGET_CFLAGS += $(FPIC) -Dtarget_$(target)=1 -Wall
|
||||
MAKE_FLAGS += TARGET="$(target)"
|
||||
|
||||
define Package/ami
|
||||
CATEGORY:=Utilities
|
||||
DEPENDS:= +libubox +ubus
|
||||
TITLE:=Asterisk management interface listener
|
||||
endef
|
||||
|
||||
define Package/ami/description
|
||||
Application that listen on the asterisk management interface to handle the leds
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
mkdir -p $(PKG_BUILD_DIR)
|
||||
$(CP) ./src/* $(PKG_BUILD_DIR)/
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
$(MAKE) -C $(PKG_BUILD_DIR) \
|
||||
$(TARGET_CONFIGURE_OPTS) LINUX_DIR=$(LINUX_DIR) LDFLAGS="$(TARGET_LDFLAGS)" CFLAGS="$(TARGET_CFLAGS) -I$(LINUX_DIR)/include -I$(STAGING_DIR)/usr/include"
|
||||
endef
|
||||
|
||||
define Package/ami/install
|
||||
$(INSTALL_DIR) $(1)/sbin
|
||||
$(CP) ./files/* $(1)/
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/ami_tool $(1)/sbin/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,ami))
|
||||
30
ami_tool/files/etc/init.d/ami
Executable file
30
ami_tool/files/etc/init.d/ami
Executable file
|
|
@ -0,0 +1,30 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
START=99
|
||||
|
||||
SERVICE_DAEMONIZE=1
|
||||
SERVICE_WRITE_PID=1
|
||||
|
||||
boot() {
|
||||
start
|
||||
}
|
||||
|
||||
|
||||
start() {
|
||||
service_start /sbin/ami_tool
|
||||
}
|
||||
|
||||
|
||||
stop() {
|
||||
service_stop /sbin/ami_tool
|
||||
}
|
||||
|
||||
|
||||
restart() {
|
||||
stop
|
||||
start
|
||||
|
||||
}
|
||||
|
||||
26
ami_tool/src/Makefile
Normal file
26
ami_tool/src/Makefile
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
# Makefile for Asterisk management interface listener application
|
||||
|
||||
CC = gcc
|
||||
MAKEDEPEND = makedepend
|
||||
CDEBUG = -g
|
||||
CFLAGS = ${CDEBUG} ${INCL} -Wall
|
||||
LDFLAGS = ${CDEBUG}
|
||||
LIBDIR =
|
||||
LOCLIBS =
|
||||
LIBS = ${LOCLIBS} ${SYSLIBS}
|
||||
OBJS = ami_tool.o ami_connection.o ucix.o
|
||||
SRCS = ami_tool.c ami_connection.c ucix.c
|
||||
LIBSRCS =
|
||||
ISRCS = ami_tool.h ami_connection.h ucix.h
|
||||
ALLSRCS = ${SRCS} ${ISRCS} ${LIBSRCS}
|
||||
|
||||
all: ami_tool
|
||||
|
||||
ami_tool: ${OBJS}
|
||||
${CC} ${LDFLAGS} -o ami_tool ${OBJS} ${LIBDIR} ${LIBS}
|
||||
|
||||
clean:
|
||||
rm -f ami_tool ${OBJS}
|
||||
|
||||
depend:
|
||||
${MAKEDEPEND} ${INCL} ${SRCS} ${LIBSRCS}
|
||||
832
ami_tool/src/ami_connection.c
Normal file
832
ami_tool/src/ami_connection.c
Normal file
|
|
@ -0,0 +1,832 @@
|
|||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <netdb.h>
|
||||
#include <sys/socket.h>
|
||||
#include <unistd.h>
|
||||
#include "ami_connection.h"
|
||||
|
||||
typedef enum ami_message {
|
||||
UNKNOWN_MESSAGE,
|
||||
LOGIN_MESSAGE,
|
||||
EVENT_MESSAGE,
|
||||
RESPONSE_MESSAGE
|
||||
} ami_message;
|
||||
|
||||
/*
|
||||
* message_frame: String defining message border
|
||||
* buffer: Buffer to parse
|
||||
* framed_message: Pointer to framed message (mallocd)
|
||||
* buffer_read: Bytes read from buffer in previous run
|
||||
*/
|
||||
static ami_message parse_buffer(char *message_frame, char *buffer, char **framed_message, int *buffer_read)
|
||||
{
|
||||
//Skip bytes already read
|
||||
buffer = &buffer[*buffer_read];
|
||||
|
||||
if (strlen(buffer) == 0) {
|
||||
return UNKNOWN_MESSAGE;
|
||||
}
|
||||
|
||||
//Locate message frame
|
||||
char *message_end = strstr(buffer, message_frame);
|
||||
if (!message_end) {
|
||||
//Could not find message frame, use left over
|
||||
//data in next call to parse_buffer
|
||||
return UNKNOWN_MESSAGE;
|
||||
}
|
||||
|
||||
//Found a message boundry
|
||||
int message_length = message_end - buffer;
|
||||
|
||||
//printf("Framed message:\n[%s]\n\n", *framed_message);
|
||||
|
||||
//Update byte counter
|
||||
*buffer_read += message_length + strlen(message_frame);
|
||||
|
||||
//Find out what type of message this is
|
||||
ami_message message_type;
|
||||
|
||||
if (!strncmp(buffer, "Asterisk Call Manager", 21)) {
|
||||
//printf("Login prompt detected\n");
|
||||
message_type = LOGIN_MESSAGE;
|
||||
} else if(!strncmp(buffer, "Event", 5)) {
|
||||
//printf("Event detected: ");
|
||||
message_type = EVENT_MESSAGE;
|
||||
} else if(!strncmp(buffer, "Response", 8)) {
|
||||
//printf("Response detected: ");
|
||||
message_type = RESPONSE_MESSAGE;
|
||||
} else {
|
||||
//printf("Unknown event: ");
|
||||
return UNKNOWN_MESSAGE;
|
||||
}
|
||||
|
||||
*framed_message = malloc(message_length +1);
|
||||
strncpy(*framed_message, buffer, message_length);
|
||||
(*framed_message)[message_length] = '\0';
|
||||
|
||||
return message_type;
|
||||
}
|
||||
|
||||
/*
|
||||
* Find the type on an event and advance the idx buffer pointer
|
||||
* to the beginning of the event.
|
||||
*/
|
||||
static ami_event_type get_event_type(char* buf, int* idx) {
|
||||
int i = 0;
|
||||
|
||||
if (!memcmp(buf, "RegistryEntry", 13)) {
|
||||
i +=13;
|
||||
while((buf[i] == '\n') || (buf[i] == '\r'))
|
||||
i++;
|
||||
|
||||
*idx = i;
|
||||
return REGISTRY_ENTRY;
|
||||
} else if (!memcmp(buf, "Registry", 8)) {
|
||||
i +=8;
|
||||
while((buf[i] == '\n') || (buf[i] == '\r'))
|
||||
i++;
|
||||
|
||||
*idx = i;
|
||||
return REGISTRY;
|
||||
} else if (!memcmp(buf, "RegistrationsComplete", 4)) {
|
||||
i +=21;
|
||||
while((buf[i] == '\n') || (buf[i] == '\r'))
|
||||
i++;
|
||||
|
||||
*idx = i;
|
||||
return REGISTRATIONS_COMPLETE;
|
||||
} else if (!memcmp(buf, "BRCM", 4)) {
|
||||
i +=8;
|
||||
while((buf[i] == '\n') || (buf[i] == '\r'))
|
||||
i++;
|
||||
|
||||
*idx = i;
|
||||
return BRCM;
|
||||
} else if (!memcmp(buf, "ChannelReload", 13)) {
|
||||
i +=8;
|
||||
while((buf[i] == '\n') || (buf[i] == '\r'))
|
||||
i++;
|
||||
|
||||
*idx = i;
|
||||
return CHANNELRELOAD;
|
||||
} else if (!memcmp(buf, "FullyBooted", 11)) {
|
||||
i +=11;
|
||||
while((buf[i] == '\n') || (buf[i] == '\r'))
|
||||
i++;
|
||||
|
||||
*idx = i;
|
||||
return FULLYBOOTED;
|
||||
} else if (!memcmp(buf, "VarSet", 6)) {
|
||||
i +=6;
|
||||
while((buf[i] == '\n') || (buf[i] == '\r'))
|
||||
i++;
|
||||
|
||||
*idx = i;
|
||||
return VARSET;
|
||||
|
||||
} // else if() handle other events
|
||||
|
||||
while(buf[i] || i > AMI_BUFLEN) {
|
||||
if (buf[i] == '\n') {
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
*idx = i;
|
||||
printf("Unhandled event\n%s\n", buf);
|
||||
return UNKNOWN_EVENT;
|
||||
}
|
||||
|
||||
static char *trim_whitespace(char *str)
|
||||
{
|
||||
char *end;
|
||||
while (isspace(*str)) {
|
||||
str++;
|
||||
}
|
||||
if(*str == 0) {
|
||||
return str;
|
||||
}
|
||||
end = str + strlen(str) - 1;
|
||||
while(end > str && isspace(*end)) {
|
||||
end--;
|
||||
}
|
||||
*(end+1) = 0;
|
||||
return str;
|
||||
}
|
||||
|
||||
ami_event parse_registry_event(char* buf)
|
||||
{
|
||||
ami_event event;
|
||||
event.type = REGISTRY;
|
||||
event.registry_event = malloc(sizeof(registry_event));
|
||||
event.registry_event->status = REGISTRY_UNKNOWN_EVENT;
|
||||
event.registry_event->account_name = NULL;
|
||||
|
||||
char* domain = strstr(buf, "Domain: ");
|
||||
if (domain) {
|
||||
domain += 8; //Increment pointer to start of domain name
|
||||
int len = 0;
|
||||
while (domain[len] && !isspace(domain[len])) {
|
||||
len++;
|
||||
}
|
||||
char* account_name = calloc(len + 1, sizeof(char));
|
||||
strncpy(account_name, domain, len);
|
||||
event.registry_event->account_name = account_name;
|
||||
printf("Found domain: %s of length %d\n", account_name, len);
|
||||
}
|
||||
else {
|
||||
printf("Warning: No domain found in Registry event\n");
|
||||
}
|
||||
|
||||
char* status = NULL;
|
||||
if ((status = strstr(buf, "Status: Request Sent"))) {
|
||||
event.registry_event->status = REGISTRY_REQUEST_SENT_EVENT;
|
||||
}
|
||||
else if ((status = strstr(buf, "Status: Unregistered"))) {
|
||||
event.registry_event->status = REGISTRY_UNREGISTERED_EVENT;
|
||||
}
|
||||
else if ((status = strstr(buf, "Status: Registered"))) {
|
||||
event.registry_event->status = REGISTRY_REGISTERED_EVENT;
|
||||
}
|
||||
else {
|
||||
printf("Warning: No status found in Registry event\n");
|
||||
}
|
||||
|
||||
return event;
|
||||
}
|
||||
|
||||
ami_event parse_registry_entry_event(char* buf)
|
||||
{
|
||||
ami_event event;
|
||||
memset(&event, 0, sizeof(event));
|
||||
|
||||
event.type = REGISTRY_ENTRY;
|
||||
event.registry_entry_event = (registry_entry_event*)malloc(sizeof(registry_entry_event));
|
||||
event.registry_entry_event->host = 0;
|
||||
event.registry_entry_event->port = 0;
|
||||
event.registry_entry_event->username = 0;
|
||||
event.registry_entry_event->domain = 0;
|
||||
event.registry_entry_event->refresh = 0;
|
||||
event.registry_entry_event->state = 0;
|
||||
event.registry_entry_event->registration_time = 0;
|
||||
|
||||
char* host_start = strstr(buf, "Host:");
|
||||
if (host_start) {
|
||||
//Found host
|
||||
host_start += 6; //Advance to start of content
|
||||
char* host_end = strstr(host_start, "\r\n");
|
||||
if (host_end) {
|
||||
//Found end of host
|
||||
int host_len = host_end - host_start;
|
||||
event.registry_entry_event->host = (char*)calloc(host_len + 1, 1);
|
||||
strncpy(event.registry_entry_event->host, host_start, host_len);
|
||||
}
|
||||
}
|
||||
|
||||
char* port_start = strstr(buf, "Port:");
|
||||
if (port_start) {
|
||||
//Found port
|
||||
port_start += 6; //Advance to start of content
|
||||
event.registry_entry_event->port = strtol(port_start, NULL, 10);
|
||||
}
|
||||
|
||||
char* username_start = strstr(buf, "Username:");
|
||||
if (username_start) {
|
||||
//Found username
|
||||
username_start += 10; //Advance to start of content
|
||||
char* username_end = strstr(username_start, "\r\n");
|
||||
if (username_end) {
|
||||
//Found end of username
|
||||
int username_len = username_end - username_start;
|
||||
event.registry_entry_event->username = (char*)calloc(username_len + 1, 1);
|
||||
strncpy(event.registry_entry_event->username, username_start, username_len);
|
||||
}
|
||||
}
|
||||
|
||||
char* domain_start = strstr(buf, "Domain:");
|
||||
if (domain_start) {
|
||||
//Found domain
|
||||
domain_start += 8; //Advance to start of content
|
||||
char* domain_end = strstr(domain_start, "\r\n");
|
||||
if (domain_end) {
|
||||
//Found end of domain
|
||||
int domain_len = domain_end - domain_start;
|
||||
event.registry_entry_event->domain = (char*)calloc(domain_len + 1, 1);
|
||||
strncpy(event.registry_entry_event->domain, domain_start, domain_len);
|
||||
}
|
||||
}
|
||||
|
||||
char* domain_port_start = strstr(buf, "DomainPort:");
|
||||
if (domain_port_start) {
|
||||
//Found port
|
||||
domain_port_start += 12; //Advance to start of content
|
||||
event.registry_entry_event->port = strtol(domain_port_start, NULL, 10);
|
||||
}
|
||||
|
||||
char* refresh_start = strstr(buf, "Refresh:");
|
||||
if (refresh_start) {
|
||||
//Found refresh interval
|
||||
refresh_start += 9; //Advance to start of content
|
||||
event.registry_entry_event->refresh = strtol(refresh_start, NULL, 10);
|
||||
}
|
||||
|
||||
char* state_start = strstr(buf, "State:");
|
||||
if (state_start) {
|
||||
//Found state
|
||||
state_start += 7; //Advance to start of content
|
||||
char* state_end = strstr(state_start, "\r\n");
|
||||
if (state_end) {
|
||||
//Found end of state
|
||||
int state_len = state_end - state_start;
|
||||
event.registry_entry_event->state = (char*)calloc(state_len + 1, 1);
|
||||
strncpy(event.registry_entry_event->state, state_start, state_len);
|
||||
}
|
||||
}
|
||||
|
||||
char* registration_time_start = strstr(buf, "RegistrationTime:");
|
||||
if (registration_time_start) {
|
||||
//Found reg timestamp
|
||||
registration_time_start += 18; //Advance to start of content
|
||||
event.registry_entry_event->registration_time = strtol(registration_time_start, NULL, 10);
|
||||
}
|
||||
|
||||
return event;
|
||||
}
|
||||
|
||||
ami_event parse_brcm_event(char* buf)
|
||||
{
|
||||
ami_event event;
|
||||
memset(&event, 0, sizeof(event));
|
||||
|
||||
event.type = BRCM;
|
||||
event.brcm_event = malloc(sizeof(brcm_event));
|
||||
event.brcm_event->type = BRCM_UNKNOWN_EVENT;
|
||||
|
||||
char* event_type = NULL;
|
||||
char parse_buffer[AMI_BUFLEN];
|
||||
char delimiter = ' ';
|
||||
char *value;
|
||||
|
||||
if ((event_type = strstr(buf, "Status: "))) {
|
||||
event.brcm_event->type = BRCM_STATUS_EVENT;
|
||||
strncpy(parse_buffer, event_type + 8, AMI_BUFLEN);
|
||||
parse_buffer[AMI_BUFLEN -1] = '\0';
|
||||
//strcpy(parse_buffer, event_type + 8);
|
||||
|
||||
value = strtok(parse_buffer, &delimiter);
|
||||
if (value && !strcmp(value, "OFF")) {
|
||||
event.brcm_event->status.off_hook = 1;
|
||||
}
|
||||
else if (value && !strcmp(value, "ON")) {
|
||||
event.brcm_event->status.off_hook = 0;
|
||||
}
|
||||
else {
|
||||
printf("Warning: No/Unknown status in brcm status event\n");
|
||||
}
|
||||
|
||||
value = strtok(NULL, &delimiter);
|
||||
if (value) {
|
||||
event.brcm_event->status.line_id = strtol(value, NULL, 10);
|
||||
}
|
||||
else {
|
||||
printf("Warning: No/Unknown line id in brcm status event\n");
|
||||
event.brcm_event->status.line_id = 0;
|
||||
}
|
||||
}
|
||||
else if ((event_type = strstr(buf, "State: "))) {
|
||||
event.brcm_event->type = BRCM_STATE_EVENT;
|
||||
strncpy(parse_buffer, event_type + 7, AMI_BUFLEN);
|
||||
parse_buffer[AMI_BUFLEN -1] = '\0';
|
||||
//strcpy(parse_buffer, event_type + 7);
|
||||
|
||||
value = strtok(parse_buffer, &delimiter);
|
||||
if (value) {
|
||||
value = trim_whitespace(value);
|
||||
event.brcm_event->state.state = calloc(strlen(value) + 1, sizeof(char));
|
||||
strcpy(event.brcm_event->state.state, value);
|
||||
}
|
||||
else {
|
||||
printf("Warning: No state in brcm state event\n");
|
||||
event.brcm_event->state.state = NULL;
|
||||
}
|
||||
|
||||
value = strtok(NULL, &delimiter);
|
||||
if (value) {
|
||||
event.brcm_event->state.line_id = strtol(value, NULL, 10);
|
||||
}
|
||||
else {
|
||||
printf("Warning: No line_id in brcm state event\n");
|
||||
event.brcm_event->state.line_id = -1;
|
||||
}
|
||||
|
||||
value = strtok(NULL, &delimiter);
|
||||
if (value) {
|
||||
event.brcm_event->state.subchannel_id = strtol(value, NULL, 10);
|
||||
}
|
||||
else {
|
||||
printf("Warning: No subchannel_id in brcm state event\n");
|
||||
event.brcm_event->state.subchannel_id = -1;
|
||||
}
|
||||
}
|
||||
else if ((event_type = strstr(buf, "Module unload"))) {
|
||||
event.brcm_event->type = BRCM_MODULE_EVENT;
|
||||
event.brcm_event->module_loaded = 0;
|
||||
}
|
||||
else if ((event_type = strstr(buf, "Module load"))) {
|
||||
event.brcm_event->type = BRCM_MODULE_EVENT;
|
||||
event.brcm_event->module_loaded = 1;
|
||||
}
|
||||
|
||||
return event;
|
||||
}
|
||||
|
||||
ami_event parse_varset_event(char* buf)
|
||||
{
|
||||
int len;
|
||||
ami_event event;
|
||||
memset(&event, 0, sizeof(event));
|
||||
event.type = VARSET;
|
||||
event.varset_event = malloc(sizeof(varset_event));
|
||||
|
||||
char* channel = strstr(buf, "Channel: ");
|
||||
if (channel) {
|
||||
channel += 9; //Increment pointer to start of channel
|
||||
len = 0;
|
||||
while (channel[len] && !isspace(channel[len])) {
|
||||
len++;
|
||||
}
|
||||
event.varset_event->channel = calloc(len + 1, sizeof(char));
|
||||
strncpy(event.varset_event->channel, channel, len);
|
||||
}
|
||||
else {
|
||||
printf("Warning: No Channel in varset event\n");
|
||||
event.varset_event->channel = NULL;
|
||||
}
|
||||
|
||||
char* variable = strstr(buf, "Variable: ");
|
||||
if (variable) {
|
||||
variable += 10; //Increment pointer to start of variable
|
||||
len = 0;
|
||||
while (variable[len] && !isspace(variable[len])) {
|
||||
len++;
|
||||
}
|
||||
event.varset_event->variable = calloc(len + 1, sizeof(char));
|
||||
strncpy(event.varset_event->variable, variable, len);
|
||||
}
|
||||
else {
|
||||
printf("Warning: No Variable in varset event\n");
|
||||
event.varset_event->variable = NULL;
|
||||
}
|
||||
|
||||
char* value = strstr(buf, "Value: ");
|
||||
if (value) {
|
||||
value += 7; //Increment pointer to start of value
|
||||
len = 0;
|
||||
while (value[len] && !isspace(value[len])) {
|
||||
len++;
|
||||
}
|
||||
event.varset_event->value = calloc(len + 1, sizeof(char));
|
||||
strncpy(event.varset_event->value, value, len);
|
||||
}
|
||||
else {
|
||||
printf("Warning: No Value in varset event\n");
|
||||
event.varset_event->value = NULL;
|
||||
}
|
||||
return event;
|
||||
}
|
||||
|
||||
ami_event parse_channel_reload_event(char* buf) {
|
||||
ami_event event;
|
||||
memset(&event, 0, sizeof(event));
|
||||
event.type = CHANNELRELOAD;
|
||||
event.channel_reload_event = malloc(sizeof(channel_reload_event));
|
||||
|
||||
char* result;
|
||||
if ((result = strstr(buf, "ChannelType: SIP"))) {
|
||||
event.channel_reload_event->channel_type = CHANNELRELOAD_SIP_EVENT;
|
||||
}
|
||||
else {
|
||||
printf("Warning: unknown channel in ChannelReload event\n");
|
||||
event.channel_reload_event->channel_type = CHANNELRELOAD_UNKNOWN_EVENT;
|
||||
}
|
||||
return event;
|
||||
}
|
||||
|
||||
ami_event parse_fully_booted_event(char* buf) {
|
||||
ami_event event;
|
||||
memset(&event, 0, sizeof(event));
|
||||
event.type = FULLYBOOTED;
|
||||
return event;
|
||||
}
|
||||
|
||||
void ami_free_event(ami_event event) {
|
||||
switch (event.type) {
|
||||
case REGISTRY:
|
||||
free(event.registry_event->account_name);
|
||||
free(event.registry_event);
|
||||
break;
|
||||
case BRCM:
|
||||
if (event.brcm_event->type == BRCM_STATE_EVENT) {
|
||||
free(event.brcm_event->state.state);
|
||||
}
|
||||
free(event.brcm_event);
|
||||
break;
|
||||
case CHANNELRELOAD:
|
||||
free(event.channel_reload_event);
|
||||
break;
|
||||
case VARSET:
|
||||
free(event.varset_event->channel);
|
||||
free(event.varset_event->value);
|
||||
free(event.varset_event->variable);
|
||||
free(event.varset_event);
|
||||
break;
|
||||
case REGISTRY_ENTRY:
|
||||
free(event.registry_entry_event->host);
|
||||
free(event.registry_entry_event->domain);
|
||||
free(event.registry_entry_event->state);
|
||||
free(event.registry_entry_event->username);
|
||||
free(event.registry_entry_event);
|
||||
break;
|
||||
case FULLYBOOTED:
|
||||
case LOGIN:
|
||||
case DISCONNECT:
|
||||
case REGISTRATIONS_COMPLETE:
|
||||
/* no event data to free */
|
||||
break;
|
||||
case UNKNOWN_EVENT:
|
||||
break;
|
||||
default:
|
||||
printf("WARNING: Unhandled event type, can't free (may leak)\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void ami_handle_event(ami_connection* con, char* message)
|
||||
{
|
||||
int idx = 0;
|
||||
ami_event_type type = get_event_type(message, &idx);
|
||||
ami_event event;
|
||||
memset(&event, 0, sizeof(event));
|
||||
|
||||
switch(type) {
|
||||
case BRCM:
|
||||
event = parse_brcm_event(&message[idx]);
|
||||
break;
|
||||
case CHANNELRELOAD:
|
||||
event = parse_channel_reload_event(&message[idx]);
|
||||
break;
|
||||
case FULLYBOOTED:
|
||||
event = parse_fully_booted_event(&message[idx]);
|
||||
break;
|
||||
case VARSET:
|
||||
event = parse_varset_event(&message[idx]);
|
||||
break;
|
||||
case REGISTRY:
|
||||
event = parse_registry_event(&message[idx]);
|
||||
break;
|
||||
case REGISTRY_ENTRY:
|
||||
event = parse_registry_entry_event(&message[idx]);
|
||||
break;
|
||||
case REGISTRATIONS_COMPLETE:
|
||||
/*
|
||||
* Probably not needed.
|
||||
* (this happens after all registry entry events have been received)
|
||||
* Event: RegistrationsComplete
|
||||
* EventList: Complete
|
||||
* ListItems: 1
|
||||
*/
|
||||
event.type = REGISTRATIONS_COMPLETE;
|
||||
break;
|
||||
case UNKNOWN_EVENT:
|
||||
default:
|
||||
event.type = UNKNOWN_EVENT;
|
||||
break;
|
||||
}
|
||||
|
||||
//Let client handle the event
|
||||
if (con->event_callback) {
|
||||
con->event_callback(con, event);
|
||||
}
|
||||
|
||||
ami_free_event(event);
|
||||
}
|
||||
|
||||
static void ami_send_action(ami_connection* con, ami_action* action) {
|
||||
if (con->current_action) {
|
||||
printf("ERROR: Attempt to send AMI action, but there is already an action pending\n");
|
||||
return;
|
||||
}
|
||||
con->current_action = action;
|
||||
write(con->sd, action->message, strlen(action->message));
|
||||
}
|
||||
|
||||
static void ami_handle_response(ami_connection* con, char* message)
|
||||
{
|
||||
ami_action* current = con->current_action;
|
||||
assert(current);
|
||||
|
||||
ami_action* next = current->next_action;
|
||||
con->current_action = NULL;
|
||||
|
||||
if (next) {
|
||||
ami_send_action(con, next);
|
||||
}
|
||||
|
||||
if (current->callback) {
|
||||
current->callback(con, message);
|
||||
}
|
||||
|
||||
free(current);
|
||||
}
|
||||
|
||||
static void queue_action(ami_connection* con, ami_action* action)
|
||||
{
|
||||
action->next_action = NULL;
|
||||
if (con->current_action) {
|
||||
ami_action* a = con->current_action;
|
||||
while(a->next_action) {
|
||||
a = a->next_action;
|
||||
}
|
||||
a->next_action = action;
|
||||
}
|
||||
else {
|
||||
ami_send_action(con, action);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* PUBLIC FUNCTION IMPLEMENTATIONS
|
||||
*/
|
||||
|
||||
ami_connection* ami_init(ami_event_cb on_event) {
|
||||
ami_connection* con;
|
||||
con = calloc(1, sizeof(*con));
|
||||
|
||||
con->connected = 0;
|
||||
con->sd = -1;
|
||||
bzero(con->message_frame, sizeof(con->message_frame));
|
||||
memset(con->left_over, 0, AMI_BUFLEN * 2 + 1);
|
||||
con->current_action = NULL;
|
||||
con->event_callback = on_event;
|
||||
|
||||
return con;
|
||||
}
|
||||
|
||||
int ami_connect(ami_connection* con, const char* hostname, const char* portno)
|
||||
{
|
||||
ami_disconnect(con);
|
||||
int result = 0;
|
||||
strncpy(con->message_frame, MESSAGE_FRAME_LOGIN, MESSAGE_FRAME_LEN);
|
||||
|
||||
struct addrinfo *host;
|
||||
int err = getaddrinfo(hostname, portno, NULL, &host);
|
||||
if (err) {
|
||||
fprintf(stderr, "Unable to connect to AMI: %s\n", gai_strerror(err));
|
||||
con->connected = 0;
|
||||
return result;
|
||||
}
|
||||
con->sd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
int res = connect(con->sd, host->ai_addr, host->ai_addrlen);
|
||||
if (res == 0) {
|
||||
//printf("Connected to AMI\n");
|
||||
con->connected = 1;
|
||||
result = 1;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "Unable to connect to AMI: %s\n", strerror(errno));
|
||||
con->connected = 0;
|
||||
result = 0;
|
||||
}
|
||||
freeaddrinfo(host);
|
||||
return result;
|
||||
}
|
||||
|
||||
void ami_disconnect(ami_connection* con)
|
||||
{
|
||||
if (con->connected) {
|
||||
close(con->sd);
|
||||
con->sd = -1;
|
||||
con->connected = 0;
|
||||
|
||||
//Let client know about disconnect
|
||||
ami_event event;
|
||||
memset(&event, 0, sizeof(event));
|
||||
event.type = DISCONNECT;
|
||||
con->event_callback(con, event);
|
||||
}
|
||||
}
|
||||
|
||||
void ami_free(ami_connection* con) {
|
||||
ami_disconnect(con);
|
||||
free(con);
|
||||
}
|
||||
|
||||
/*
|
||||
* Called by client when ami_connection has new data to process
|
||||
*/
|
||||
void ami_handle_data(ami_connection* con)
|
||||
{
|
||||
//printf("Handling data on AMI connection\n");
|
||||
int idx = 0; //buffer position
|
||||
char* message = NULL;
|
||||
char buf[AMI_BUFLEN * 2 + 1];
|
||||
|
||||
//Read data from ami
|
||||
memset(buf, 0, AMI_BUFLEN * 2 + 1);
|
||||
if (read(con->sd, buf, AMI_BUFLEN-1) <= 0) {
|
||||
ami_disconnect(con); //we have been disconnected
|
||||
return;
|
||||
}
|
||||
|
||||
//Concatenate left over data with newly read
|
||||
if (strlen(con->left_over)) {
|
||||
char tmp[AMI_BUFLEN * 2 + 1];
|
||||
strcpy(tmp, con->left_over);
|
||||
strcat(tmp, buf);
|
||||
strcpy(buf, tmp);
|
||||
con->left_over[0] = '\0';
|
||||
}
|
||||
|
||||
ami_message message_type = UNKNOWN_MESSAGE;
|
||||
ami_event event;
|
||||
memset(&event, 0, sizeof(event));
|
||||
|
||||
while(idx < strlen(buf)) {
|
||||
message_type = parse_buffer(con->message_frame, buf, &message, &idx);
|
||||
if (message_type == UNKNOWN_MESSAGE) {
|
||||
break;
|
||||
}
|
||||
switch (message_type) {
|
||||
case LOGIN_MESSAGE:
|
||||
//Send login event to client (time to log in...)
|
||||
event.type = LOGIN;
|
||||
con->event_callback(con, event);
|
||||
ami_free_event(event);
|
||||
break;
|
||||
case EVENT_MESSAGE:
|
||||
ami_handle_event(con, message + 7);
|
||||
break;
|
||||
case RESPONSE_MESSAGE:
|
||||
ami_handle_response(con, message);
|
||||
break;
|
||||
default:
|
||||
printf("Unknown data from AMI: %s\n", message);
|
||||
break;
|
||||
}
|
||||
free(message);
|
||||
}
|
||||
|
||||
//store remaining buffer until next packet is read
|
||||
if (idx < strlen(buf)) {
|
||||
strcpy(con->left_over, &buf[idx]);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* ACTIONS
|
||||
* Send an Action to AMI. We expect a response to this, so its possible to provide
|
||||
* a callback that will be executed when a response is retrieved. There can only
|
||||
* be one action pending at a time. If one is already pending, any new attempts
|
||||
* will be ignored.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Send command to reload sip channel.
|
||||
* CHANNELRELOAD event will be received when reload is completed.
|
||||
*
|
||||
* Example response:
|
||||
* "Response: Follows
|
||||
* Privilege: Command
|
||||
* --END COMMAND--"
|
||||
*/
|
||||
void ami_send_sip_reload(ami_connection* con, ami_response_cb on_response) {
|
||||
//printf("Queueing Action: ami_send_sip_reload\n");
|
||||
ami_action* action = malloc(sizeof(ami_action));
|
||||
action->callback = on_response;
|
||||
sprintf(action->message,"Action: Command\r\nCommand: sip reload\r\n\r\n");
|
||||
queue_action(con, action);
|
||||
}
|
||||
|
||||
/*
|
||||
* Send username and password to AMI
|
||||
*
|
||||
* Example response:
|
||||
* "Response: Success
|
||||
* Message: Authentication accepted"
|
||||
*/
|
||||
void ami_send_login(ami_connection* con, char* username, char* password, ami_response_cb on_response)
|
||||
{
|
||||
//printf("Queueing Action: ami_send_login\n");
|
||||
strncpy(con->message_frame, MESSAGE_FRAME, MESSAGE_FRAME_LEN); //Login sent, now there's always <CR><LF><CR><LR> after a message
|
||||
ami_action* action = malloc(sizeof(ami_action));
|
||||
action->callback = on_response;
|
||||
sprintf(action->message,"Action: Login\r\nUsername: %s\r\nSecret: %s\r\n\r\n", username, password);
|
||||
queue_action(con, action);
|
||||
}
|
||||
|
||||
/*
|
||||
* Request an indication on if BRCM module is loaded or not
|
||||
*
|
||||
* Example response:
|
||||
* "Response: Follows
|
||||
* Privilege: Command
|
||||
* --END COMMAND--"
|
||||
*/
|
||||
void ami_send_brcm_module_show(ami_connection* con, ami_response_cb on_response) {
|
||||
//printf("Queueing Action: ami_send_brcm_module_show\n");
|
||||
ami_action* action = malloc(sizeof(ami_action));
|
||||
action->callback = on_response;
|
||||
sprintf(action->message, "Action: Command\r\nCommand: module show like chan_brcm\r\n\r\n");
|
||||
queue_action(con, action);
|
||||
}
|
||||
|
||||
/*
|
||||
* Request an indication on the port configuration
|
||||
*
|
||||
* Example response:
|
||||
* "Response: Success
|
||||
* Message:
|
||||
* FXS 2
|
||||
* DECT 4"
|
||||
*/
|
||||
void ami_send_brcm_ports_show(ami_connection* con, ami_response_cb on_response) {
|
||||
//printf("Queueing Action: ami_send_brcm_ports_show\n");
|
||||
ami_action* action = malloc(sizeof(ami_action));
|
||||
action->callback = on_response;
|
||||
sprintf(action->message, "Action: BRCMPortsShow\r\n\r\n");
|
||||
queue_action(con, action);
|
||||
}
|
||||
|
||||
/*
|
||||
* Request SIP Registry information
|
||||
* (response is a simple message, then the registry events
|
||||
* follow separately, one per registered account)
|
||||
* Example response:
|
||||
* Response: Success
|
||||
* EventList: start
|
||||
* Message: Registrations will follow
|
||||
*
|
||||
* Event: RegistryEntry
|
||||
* Host: sip0
|
||||
* Port: 5060
|
||||
* Username: 0510409896
|
||||
* Domain: 62.80.209.10
|
||||
* DomainPort: 5060
|
||||
* Refresh: 5385
|
||||
* State: Registered
|
||||
* RegistrationTime: 1401282865
|
||||
*
|
||||
* Event: RegistrationsComplete
|
||||
* EventList: Complete
|
||||
* ListItems: 1
|
||||
*/
|
||||
void ami_send_sip_show_registry(ami_connection* con, ami_response_cb on_response) {
|
||||
ami_action* action = (ami_action*)malloc(sizeof(ami_action));
|
||||
action->callback = on_response;
|
||||
sprintf(action->message, "Action: SIPshowregistry\r\n\r\n");
|
||||
queue_action(con, action);
|
||||
}
|
||||
131
ami_tool/src/ami_connection.h
Normal file
131
ami_tool/src/ami_connection.h
Normal file
|
|
@ -0,0 +1,131 @@
|
|||
/*
|
||||
* ami_connection.h
|
||||
*
|
||||
* Manage connections to AMI.
|
||||
*
|
||||
* Callbacks in client code will be called when events or responses have been received
|
||||
* from AMI. There is no event loop built in, client should call ami_handle_data whenever
|
||||
* new data is available on the connections filedescriptor.
|
||||
*/
|
||||
|
||||
#define MESSAGE_FRAME "\r\n\r\n"
|
||||
#define MESSAGE_FRAME_LOGIN "\r\n"
|
||||
#define MESSAGE_FRAME_LEN 5
|
||||
|
||||
#define AMI_BUFLEN 512
|
||||
|
||||
typedef struct {
|
||||
enum {
|
||||
BRCM_UNKNOWN_EVENT,
|
||||
BRCM_STATUS_EVENT,
|
||||
BRCM_STATE_EVENT,
|
||||
BRCM_MODULE_EVENT
|
||||
} type;
|
||||
struct {
|
||||
int line_id;
|
||||
int off_hook;
|
||||
} status;
|
||||
struct {
|
||||
int line_id;
|
||||
int subchannel_id;
|
||||
char* state;
|
||||
} state;
|
||||
int module_loaded;
|
||||
} brcm_event;
|
||||
|
||||
typedef struct {
|
||||
char* account_name;
|
||||
enum {
|
||||
REGISTRY_UNKNOWN_EVENT,
|
||||
REGISTRY_REQUEST_SENT_EVENT,
|
||||
REGISTRY_UNREGISTERED_EVENT,
|
||||
REGISTRY_REGISTERED_EVENT
|
||||
} status;
|
||||
} registry_event;
|
||||
|
||||
typedef struct {
|
||||
char* host; //Account name (e.g. sip0)
|
||||
int port; //5060
|
||||
char* username; //0510409896
|
||||
char* domain; //62.80.209.10
|
||||
int domain_port; //5060
|
||||
int refresh; //Refresh interval, 285
|
||||
char* state; //Registration state Registered
|
||||
int registration_time; //Registration timestamp, 1401282865
|
||||
} registry_entry_event;
|
||||
|
||||
typedef struct {
|
||||
enum {
|
||||
CHANNELRELOAD_UNKNOWN_EVENT,
|
||||
CHANNELRELOAD_SIP_EVENT
|
||||
} channel_type;
|
||||
} channel_reload_event;
|
||||
|
||||
typedef struct {
|
||||
char* channel;
|
||||
char* variable;
|
||||
char* value;
|
||||
} varset_event;
|
||||
|
||||
typedef enum ami_event_type {
|
||||
LOGIN,
|
||||
REGISTRY,
|
||||
REGISTRY_ENTRY,
|
||||
REGISTRATIONS_COMPLETE,
|
||||
BRCM,
|
||||
CHANNELRELOAD,
|
||||
FULLYBOOTED,
|
||||
VARSET,
|
||||
DISCONNECT,
|
||||
UNKNOWN_EVENT,
|
||||
} ami_event_type;
|
||||
|
||||
typedef struct ami_event {
|
||||
ami_event_type type;
|
||||
brcm_event* brcm_event;
|
||||
registry_event* registry_event;
|
||||
registry_entry_event* registry_entry_event;
|
||||
channel_reload_event* channel_reload_event;
|
||||
varset_event* varset_event;
|
||||
} ami_event;
|
||||
|
||||
typedef struct ami_connection ami_connection;
|
||||
typedef struct ami_action ami_action;
|
||||
typedef void (*ami_event_cb) (ami_connection* con, ami_event event);
|
||||
typedef void (*ami_response_cb) (ami_connection* con, char* buf);
|
||||
/*
|
||||
* Holds data related to an AMI connection
|
||||
*/
|
||||
struct ami_connection {
|
||||
int connected; //ami_connection is connected to asterisk
|
||||
int sd;
|
||||
char message_frame[MESSAGE_FRAME_LEN];
|
||||
char left_over[AMI_BUFLEN * 2 + 1];
|
||||
ami_event_cb event_callback;
|
||||
ami_action* current_action;
|
||||
};
|
||||
|
||||
ami_connection* ami_init(ami_event_cb on_event);
|
||||
int ami_connect(ami_connection* con, const char* hostname, const char* portno);
|
||||
void ami_disconnect(ami_connection* con);
|
||||
void ami_free(ami_connection* con);
|
||||
|
||||
/*
|
||||
* Call when new data is available
|
||||
*/
|
||||
void ami_handle_data(ami_connection* con);
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
struct ami_action {
|
||||
char message[AMI_BUFLEN];
|
||||
ami_response_cb callback;
|
||||
ami_action* next_action;
|
||||
};
|
||||
|
||||
void ami_send_sip_reload(ami_connection* con, ami_response_cb on_response);
|
||||
void ami_send_login(ami_connection* con, char*username, char* password, ami_response_cb on_response);
|
||||
void ami_send_brcm_module_show(ami_connection* con, ami_response_cb on_response);
|
||||
void ami_send_brcm_ports_show(ami_connection* con, ami_response_cb on_response);
|
||||
void ami_send_sip_show_registry(ami_connection* con, ami_response_cb on_response);
|
||||
1597
ami_tool/src/ami_tool.c
Normal file
1597
ami_tool/src/ami_tool.c
Normal file
File diff suppressed because it is too large
Load diff
250
ami_tool/src/ami_tool.h
Normal file
250
ami_tool/src/ami_tool.h
Normal file
|
|
@ -0,0 +1,250 @@
|
|||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <netdb.h>
|
||||
#include <sys/socket.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
//For dynamic firewall support
|
||||
#define IPTABLES_CHAIN "zone_wan_input"
|
||||
#define IPTABLES_BIN "iptables"
|
||||
#define IPTABLES_FILE "/etc/firewall.sip"
|
||||
#ifdef USE_IPV6
|
||||
#define IP6TABLES_BIN "ip6tables"
|
||||
#define IP6TABLES_FILE "/etc/firewall6.sip"
|
||||
#endif
|
||||
#define ECHO_BIN "echo"
|
||||
#define UCI_BIN "uci"
|
||||
#define UCI_VOICE_PACKAGE "voice_client"
|
||||
|
||||
#ifndef NI_MAXHOST
|
||||
#define NI_MAXHOST 65
|
||||
#endif
|
||||
#define MAX_IP_LIST_LENGTH 20
|
||||
#define RTP_RANGE_START_DEFAULT 10000
|
||||
#define RTP_RANGE_END_DEFAULT 20000
|
||||
|
||||
#define BUFLEN 512
|
||||
|
||||
typedef struct IP
|
||||
{
|
||||
int family;
|
||||
char addr[NI_MAXHOST];
|
||||
} IP;
|
||||
|
||||
typedef enum AMI_STATE {
|
||||
DISCONNECTED, //Not connected to AMI
|
||||
CONNECTED, //Connected to AMI
|
||||
LOGGED_IN, //Logged in to AMI
|
||||
READY //Ready to handle all events
|
||||
} AMI_STATE;
|
||||
AMI_STATE state;
|
||||
|
||||
typedef enum LED_STATE
|
||||
{
|
||||
LS_OK,
|
||||
LS_NOTICE,
|
||||
LS_ALERT,
|
||||
LS_ERROR,
|
||||
LS_OFF,
|
||||
LS_UNKNOWN
|
||||
} LED_STATE;
|
||||
|
||||
#define MAX_LED_STATE 10
|
||||
typedef struct LED_STATE_MAP
|
||||
{
|
||||
LED_STATE state;
|
||||
char str[MAX_LED_STATE];
|
||||
} LED_STATE_MAP;
|
||||
|
||||
static const LED_STATE_MAP led_states[] =
|
||||
{
|
||||
{LS_OK, "ok"},
|
||||
{LS_NOTICE, "notice"},
|
||||
{LS_ALERT, "alert"},
|
||||
{LS_ERROR, "error"},
|
||||
{LS_OFF, "off"},
|
||||
{LS_UNKNOWN, "-"},
|
||||
};
|
||||
|
||||
typedef enum LED_NAME
|
||||
{
|
||||
LN_DSL,
|
||||
LN_WIFI,
|
||||
LN_WPS,
|
||||
LN_LAN,
|
||||
LN_STATUS,
|
||||
LN_DECT,
|
||||
LN_TV,
|
||||
LN_USB,
|
||||
LN_WAN,
|
||||
LN_INTERNET,
|
||||
LN_VOICE1,
|
||||
LN_VOICE2,
|
||||
LN_ECO,
|
||||
LN_ALL,
|
||||
LN_UNKNOWN
|
||||
} LED_NAME;
|
||||
|
||||
#define MAX_LED_NAME 13
|
||||
typedef struct LED_NAME_MAP
|
||||
{
|
||||
LED_NAME name;
|
||||
char str[MAX_LED_NAME];
|
||||
} LED_NAME_MAP;
|
||||
|
||||
static const LED_NAME_MAP led_names[] =
|
||||
{
|
||||
{LN_DSL, "led.dsl"},
|
||||
{LN_WIFI, "led.wifi"},
|
||||
{LN_WPS, "led.wps"},
|
||||
{LN_LAN, "led.lan"},
|
||||
{LN_STATUS, "led.status"},
|
||||
{LN_DECT, "led.dect"},
|
||||
{LN_TV, "led.tv"},
|
||||
{LN_USB, "led.usb"},
|
||||
{LN_WAN, "led.wan"},
|
||||
{LN_INTERNET, "led.internet"},
|
||||
{LN_VOICE1, "led.voice1"},
|
||||
{LN_VOICE2, "led.voice2"},
|
||||
{LN_ECO, "led.eco"},
|
||||
{LN_ALL, "All"},
|
||||
{LN_UNKNOWN, "-"}
|
||||
};
|
||||
|
||||
typedef struct LED_CURRENT_STATE_MAP
|
||||
{
|
||||
LED_NAME name;
|
||||
LED_STATE state;
|
||||
} LED_CURRENT_STATE_MAP;
|
||||
|
||||
static LED_CURRENT_STATE_MAP led_current_states[] =
|
||||
{
|
||||
{LN_VOICE1, LS_UNKNOWN},
|
||||
{LN_VOICE2, LS_UNKNOWN},
|
||||
{LN_UNKNOWN, LS_UNKNOWN}
|
||||
};
|
||||
|
||||
//These are used to map SIP peer name to a port
|
||||
//CPE may be configured to share the same SIP-account for several ports or to use individual accounts
|
||||
typedef enum BRCM_PORT
|
||||
{
|
||||
PORT_BRCM0 = 0,
|
||||
PORT_BRCM1,
|
||||
PORT_BRCM2,
|
||||
PORT_BRCM3,
|
||||
PORT_BRCM4,
|
||||
PORT_BRCM5,
|
||||
PORT_ALL,
|
||||
PORT_UNKNOWN
|
||||
} BRCM_PORT;
|
||||
|
||||
typedef struct SUBCHANNEL
|
||||
{
|
||||
char state[80];
|
||||
} SUBCHANNEL;
|
||||
|
||||
#define MAX_PORT_NAME 10
|
||||
typedef struct PORT_MAP
|
||||
{
|
||||
char name[MAX_PORT_NAME];
|
||||
BRCM_PORT port;
|
||||
int off_hook;
|
||||
SUBCHANNEL sub[2]; //TODO define for number of subchannels?
|
||||
struct ubus_object *ubus_object;
|
||||
} PORT_MAP;
|
||||
|
||||
static PORT_MAP brcm_ports[] =
|
||||
{
|
||||
{"brcm0", PORT_BRCM0, 0, { {"ONHOOK"}, {"ONHOOK"} }, NULL },
|
||||
{"brcm1", PORT_BRCM1, 0, { {"ONHOOK"}, {"ONHOOK"} }, NULL },
|
||||
{"brcm2", PORT_BRCM2, 0, { {"ONHOOK"}, {"ONHOOK"} }, NULL },
|
||||
{"brcm3", PORT_BRCM3, 0, { {"ONHOOK"}, {"ONHOOK"} }, NULL },
|
||||
{"brcm4", PORT_BRCM4, 0, { {"ONHOOK"}, {"ONHOOK"} }, NULL },
|
||||
{"brcm5", PORT_BRCM5, 0, { {"ONHOOK"}, {"ONHOOK"} }, NULL },
|
||||
//Add other ports here as needed
|
||||
{"port_all", PORT_ALL, 0, { {"ONHOOK"}, {"ONHOOK"} }, NULL },
|
||||
{"-", PORT_UNKNOWN, 0, { {"ONHOOK"}, {"ONHOOK"} }, NULL },
|
||||
};
|
||||
|
||||
typedef enum SIP_ACCOUNT_ID
|
||||
{
|
||||
SIP_ACCOUNT_0 = 0,
|
||||
SIP_ACCOUNT_1,
|
||||
SIP_ACCOUNT_2,
|
||||
SIP_ACCOUNT_3,
|
||||
SIP_ACCOUNT_4,
|
||||
SIP_ACCOUNT_5,
|
||||
SIP_ACCOUNT_6,
|
||||
SIP_ACCOUNT_7,
|
||||
SIP_ACCOUNT_UNKNOWN
|
||||
} SIP_ACCOUNT_ID;
|
||||
|
||||
#define MAX_ACCOUNT_NAME 10
|
||||
typedef struct SIP_ACCOUNT
|
||||
{
|
||||
SIP_ACCOUNT_ID id;
|
||||
char name[MAX_ACCOUNT_NAME];
|
||||
} SIP_ACCOUNT;
|
||||
|
||||
static const SIP_ACCOUNT sip_accounts[] = {
|
||||
{SIP_ACCOUNT_0, "sip0"},
|
||||
{SIP_ACCOUNT_1, "sip1"},
|
||||
{SIP_ACCOUNT_2, "sip2"},
|
||||
{SIP_ACCOUNT_3, "sip3"},
|
||||
{SIP_ACCOUNT_4, "sip4"},
|
||||
{SIP_ACCOUNT_5, "sip5"},
|
||||
{SIP_ACCOUNT_6, "sip6"},
|
||||
{SIP_ACCOUNT_7, "sip7"},
|
||||
{SIP_ACCOUNT_UNKNOWN, "-"}
|
||||
};
|
||||
|
||||
#define MAX_SIP_PEERS 10
|
||||
#define MAX_SIP_PEER_NAME 10
|
||||
#define MAX_SIP_PEER_USERNAME 128
|
||||
#define MAX_SIP_PEER_DOMAIN 128
|
||||
#define MAX_SIP_PEER_STATE 128
|
||||
typedef struct SIP_PEER
|
||||
{
|
||||
SIP_ACCOUNT account;
|
||||
int sip_registry_request_sent; //Bool indicating if we have sent a registration request
|
||||
int sip_registry_registered; //Bool indicating if we are registered or not
|
||||
time_t sip_registry_time; //The time when we received the registry event
|
||||
IP ip_list[MAX_IP_LIST_LENGTH]; //IP addresses of the sip registrar
|
||||
int ip_list_length; //Number of addresses
|
||||
|
||||
//Info from sip show registry
|
||||
int port; //The port we are connected to
|
||||
char username[MAX_SIP_PEER_USERNAME]; //Our username
|
||||
char domain[MAX_SIP_PEER_DOMAIN]; //The domain we are registered on
|
||||
int domain_port; //The domain port
|
||||
int refresh; //Refresh interval for this registration
|
||||
char state[MAX_SIP_PEER_STATE]; //Registration state e.g. Registered
|
||||
time_t registration_time; //Registration timestamp, 1401282865
|
||||
|
||||
struct ubus_object *ubus_object;
|
||||
} SIP_PEER;
|
||||
|
||||
/*
|
||||
* Struct that stores configuration for a LED
|
||||
*/
|
||||
typedef struct {
|
||||
LED_STATE state;
|
||||
LED_NAME name;
|
||||
int num_ports;
|
||||
PORT_MAP** ports; //Array of pointers to brcm ports that govern this leds state
|
||||
int num_peers;
|
||||
SIP_PEER** peers;//Array of pointers to sip peers that govern this leds state
|
||||
} Led;
|
||||
|
||||
|
||||
void init_sip_peers();
|
||||
void manage_leds();
|
||||
void manage_led(LED_NAME led, LED_STATE state);
|
||||
LED_STATE get_led_state(Led* led);
|
||||
void configure_leds();
|
||||
void free_led_config();
|
||||
|
||||
172
ami_tool/src/ucix.c
Normal file
172
ami_tool/src/ucix.c
Normal file
|
|
@ -0,0 +1,172 @@
|
|||
/*
|
||||
* 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.
|
||||
*
|
||||
* Copyright (C) 2008 John Crispin <blogic@openwrt.org>
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <uci_config.h>
|
||||
#include <uci.h>
|
||||
#include "ucix.h"
|
||||
|
||||
static struct uci_ptr ptr;
|
||||
|
||||
static inline int ucix_get_ptr(struct uci_context *ctx, const char *p, const char *s, const char *o, const char *t)
|
||||
{
|
||||
memset(&ptr, 0, sizeof(ptr));
|
||||
ptr.package = p;
|
||||
ptr.section = s;
|
||||
ptr.option = o;
|
||||
ptr.value = t;
|
||||
return uci_lookup_ptr(ctx, &ptr, NULL, true);
|
||||
}
|
||||
|
||||
struct uci_context* ucix_init(const char *config_file)
|
||||
{
|
||||
struct uci_context *ctx = uci_alloc_context();
|
||||
uci_add_delta_path(ctx, "/var/state");
|
||||
if(uci_load(ctx, config_file, NULL) != UCI_OK)
|
||||
{
|
||||
printf("%s/%s is missing or corrupt\n", ctx->savedir, config_file);
|
||||
return NULL;
|
||||
}
|
||||
return ctx;
|
||||
}
|
||||
|
||||
struct uci_context* ucix_init_path(const char *path, const char *config_file)
|
||||
{
|
||||
struct uci_context *ctx = uci_alloc_context();
|
||||
if(path)
|
||||
uci_set_confdir(ctx, path);
|
||||
if(uci_load(ctx, config_file, NULL) != UCI_OK)
|
||||
{
|
||||
printf("%s/%s is missing or corrupt\n", ctx->savedir, config_file);
|
||||
return NULL;
|
||||
}
|
||||
return ctx;
|
||||
}
|
||||
|
||||
void ucix_cleanup(struct uci_context *ctx)
|
||||
{
|
||||
uci_free_context(ctx);
|
||||
}
|
||||
|
||||
void ucix_save(struct uci_context *ctx)
|
||||
{
|
||||
uci_set_savedir(ctx, "/tmp/.uci/");
|
||||
uci_save(ctx, NULL);
|
||||
}
|
||||
|
||||
void ucix_save_state(struct uci_context *ctx)
|
||||
{
|
||||
uci_set_savedir(ctx, "/var/state/");
|
||||
uci_save(ctx, NULL);
|
||||
}
|
||||
|
||||
const char* ucix_get_option(struct uci_context *ctx, const char *p, const char *s, const char *o)
|
||||
{
|
||||
struct uci_element *e = NULL;
|
||||
const char *value = NULL;
|
||||
if(ucix_get_ptr(ctx, p, s, o, NULL))
|
||||
return NULL;
|
||||
if (!(ptr.flags & UCI_LOOKUP_COMPLETE))
|
||||
return NULL;
|
||||
e = ptr.last;
|
||||
switch (e->type)
|
||||
{
|
||||
case UCI_TYPE_SECTION:
|
||||
value = uci_to_section(e)->type;
|
||||
break;
|
||||
case UCI_TYPE_OPTION:
|
||||
switch(ptr.o->type) {
|
||||
case UCI_TYPE_STRING:
|
||||
value = ptr.o->v.string;
|
||||
break;
|
||||
default:
|
||||
value = NULL;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
int ucix_get_option_int(struct uci_context *ctx, const char *p, const char *s, const char *o, int def)
|
||||
{
|
||||
const char *tmp = ucix_get_option(ctx, p, s, o);
|
||||
int ret = def;
|
||||
|
||||
if (tmp)
|
||||
ret = atoi(tmp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ucix_add_section(struct uci_context *ctx, const char *p, const char *s, const char *t)
|
||||
{
|
||||
if(ucix_get_ptr(ctx, p, s, NULL, t))
|
||||
return;
|
||||
uci_set(ctx, &ptr);
|
||||
}
|
||||
|
||||
void ucix_add_option(struct uci_context *ctx, const char *p, const char *s, const char *o, const char *t)
|
||||
{
|
||||
if(ucix_get_ptr(ctx, p, s, o, (t)?(t):("")))
|
||||
return;
|
||||
uci_set(ctx, &ptr);
|
||||
}
|
||||
|
||||
void ucix_add_option_int(struct uci_context *ctx, const char *p, const char *s, const char *o, int t)
|
||||
{
|
||||
char tmp[64];
|
||||
snprintf(tmp, 64, "%d", t);
|
||||
ucix_add_option(ctx, p, s, o, tmp);
|
||||
}
|
||||
|
||||
void ucix_del(struct uci_context *ctx, const char *p, const char *s, const char *o)
|
||||
{
|
||||
if(!ucix_get_ptr(ctx, p, s, o, NULL))
|
||||
uci_delete(ctx, &ptr);
|
||||
}
|
||||
|
||||
void ucix_revert(struct uci_context *ctx, const char *p, const char *s, const char *o)
|
||||
{
|
||||
if(!ucix_get_ptr(ctx, p, s, o, NULL))
|
||||
uci_revert(ctx, &ptr);
|
||||
}
|
||||
|
||||
void ucix_for_each_section_type(struct uci_context *ctx,
|
||||
const char *p, const char *t,
|
||||
void (*cb)(const char*, void*), void *priv)
|
||||
{
|
||||
struct uci_element *e;
|
||||
if(ucix_get_ptr(ctx, p, NULL, NULL, NULL))
|
||||
return;
|
||||
uci_foreach_element(&ptr.p->sections, e)
|
||||
if (!strcmp(t, uci_to_section(e)->type))
|
||||
cb(e->name, priv);
|
||||
}
|
||||
|
||||
int ucix_commit(struct uci_context *ctx, const char *p)
|
||||
{
|
||||
if(ucix_get_ptr(ctx, p, NULL, NULL, NULL))
|
||||
return 1;
|
||||
return uci_commit(ctx, &ptr.p, false);
|
||||
}
|
||||
|
||||
54
ami_tool/src/ucix.h
Normal file
54
ami_tool/src/ucix.h
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* 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.
|
||||
*
|
||||
* Copyright (C) 2008 John Crispin <blogic@openwrt.org>
|
||||
*/
|
||||
|
||||
#ifndef _UCI_H__
|
||||
#define _UCI_H__
|
||||
|
||||
#include "list.h"
|
||||
|
||||
struct ucilist {
|
||||
struct list_head list;
|
||||
char *val;
|
||||
};
|
||||
|
||||
struct uci_context* ucix_init(const char *config_file);
|
||||
struct uci_context* ucix_init_path(const char *path, const char *config_file);
|
||||
void ucix_cleanup(struct uci_context *ctx);
|
||||
void ucix_save(struct uci_context *ctx);
|
||||
void ucix_save_state(struct uci_context *ctx);
|
||||
const char* ucix_get_option(struct uci_context *ctx,
|
||||
const char *p, const char *s, const char *o);
|
||||
int ucix_get_option_list(struct uci_context *ctx, const char *p,
|
||||
const char *s, const char *o, struct list_head *l);
|
||||
int ucix_get_option_int(struct uci_context *ctx,
|
||||
const char *p, const char *s, const char *o, int def);
|
||||
void ucix_add_section(struct uci_context *ctx,
|
||||
const char *p, const char *s, const char *t);
|
||||
void ucix_add_option(struct uci_context *ctx,
|
||||
const char *p, const char *s, const char *o, const char *t);
|
||||
void ucix_add_option_int(struct uci_context *ctx,
|
||||
const char *p, const char *s, const char *o, int t);
|
||||
int ucix_commit(struct uci_context *ctx, const char *p);
|
||||
void ucix_revert(struct uci_context *ctx,
|
||||
const char *p, const char *s, const char *o);
|
||||
void ucix_del(struct uci_context *ctx, const char *p,
|
||||
const char *s, const char *o);
|
||||
void ucix_for_each_section_type(struct uci_context *ctx,
|
||||
const char *p, const char *t,
|
||||
void (*cb)(const char*, void*), void *priv);
|
||||
#endif
|
||||
7
anyfi/Config.in
Normal file
7
anyfi/Config.in
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
config ANYFI_CONTROLLER
|
||||
string "Controller IP or FQDN"
|
||||
depends PACKAGE_anyfi
|
||||
help
|
||||
The default IP address or fully qualified domain name (FQDN)
|
||||
of the Controller that should manage the Anyfi.net software.
|
||||
|
||||
61
anyfi/Makefile
Normal file
61
anyfi/Makefile
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
include $(TOPDIR)/rules.mk
|
||||
|
||||
ANYFI_TARGET := $(ARCH)-linux-$(subst C,c,$(LIBC))-$(LIBCV)
|
||||
|
||||
PKG_NAME := anyfi
|
||||
PKG_VERSION := 1.3.9
|
||||
PKG_RELEASE := 1
|
||||
|
||||
PKG_SOURCE := anyfimac-$(PKG_VERSION)-$(ANYFI_TARGET).tar.bz2
|
||||
PKG_SOURCE_URL := http://anyfi.net/download
|
||||
PKG_BUILD_DIR := $(BUILD_DIR)/anyfimac-$(PKG_VERSION)-$(ANYFI_TARGET)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/$(PKG_NAME)
|
||||
SECTION := net
|
||||
CATEGORY := Network
|
||||
TITLE := Anyfi.net - Free SDWN Data Plane for IEEE 802.11
|
||||
URL := http://anyfi.net
|
||||
DEPENDS := +kmod-tun +librt +wl-anyfi
|
||||
MAINTAINER := Anyfi Networks <eng@anyfinetworks.com>
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/description
|
||||
Anyfi.net is a free Software-Defined Wirless Networking (SDWN)
|
||||
forwarding data plane implementation for IEEE 802.11.
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/config
|
||||
source "$(SOURCE)/Config.in"
|
||||
endef
|
||||
|
||||
define Build/Configure
|
||||
echo "config anyfi controller" > $(PKG_BUILD_DIR)/anyfi.conf
|
||||
echo " option 'hostname' $(CONFIG_ANYFI_CONTROLLER)" >> \
|
||||
$(PKG_BUILD_DIR)/anyfi.conf
|
||||
echo "config anyfi optimizer" >> $(PKG_BUILD_DIR)/anyfi.conf
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
@echo "Nothing to do - Anyfi.net software comes pre-built."
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/conffiles
|
||||
/etc/config/anyfi
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/install
|
||||
$(CP) ./files/* $(1)/
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_CONF) $(PKG_BUILD_DIR)/anyfi.conf $(1)/etc/config/anyfi
|
||||
$(INSTALL_DIR) $(1)/sbin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/anyfimac $(1)/sbin
|
||||
$(LN) anyfimac $(1)/sbin/anyfid
|
||||
$(LN) anyfimac $(1)/sbin/myfid
|
||||
$(INSTALL_DIR) $(1)/bin
|
||||
$(LN) ../sbin/anyfimac $(1)/bin/anyfidctl
|
||||
$(LN) ../sbin/anyfimac $(1)/bin/myfidctl
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,$(PKG_NAME)))
|
||||
558
anyfi/files/lib/network/anyfi.sh
Normal file
558
anyfi/files/lib/network/anyfi.sh
Normal file
|
|
@ -0,0 +1,558 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Copyright (C) 2013-2014 Anyfi Networks AB.
|
||||
#
|
||||
# Overview of the Integration
|
||||
# ===========================
|
||||
#
|
||||
# Anyfi.net software consists of two user space daemons; the radio daemon
|
||||
# anyfid and the tunnel termination daemon myfid. They communicate with each
|
||||
# other and with a Controller [1] over UDP/IP.
|
||||
#
|
||||
# The radio daemon anyfid provides guests with access to remote Wi-Fi networks.
|
||||
# It needs a Wi-Fi monitor interface to detect when guest devices come within
|
||||
# range and a pool of virtual access points to serve them. The integration is
|
||||
# responsible for creating the monitor interface and the pool of virtual access
|
||||
# points; anyfid handles the rest.
|
||||
#
|
||||
# The tunnel termination daemon myfid provides remote access to the local Wi-Fi
|
||||
# network. It is up to the integration to configure myfid to authenticate remote
|
||||
# devices in the same way that devices are authenticated when connecting
|
||||
# locally.
|
||||
#
|
||||
# Myfid is also responsible for telling the controller the MAC address of
|
||||
# devices that connect locally, so that they can later be offered seamless
|
||||
# remote access whenever they come close to another access point running anyfid.
|
||||
# However, when the user changes the WPA passphrase all such associations
|
||||
# between previously connected devices and the local Wi-Fi network should be
|
||||
# removed. The integration does so by passing myfid the --reset flag.
|
||||
#
|
||||
# Below is the integration logic in pseudo code. If you need to integrate
|
||||
# Anyfi.net software in your own firmware build environment you can find step
|
||||
# by step instructions at http://anyfi.net/integration.
|
||||
#
|
||||
# 1. A Community Edition of the Controller is available for download at
|
||||
# http://www.anyfinetworks.com/download. You can also use the public
|
||||
# demonstration controller at "demo.anyfi.net".
|
||||
#
|
||||
#
|
||||
# Integration Logic in Pseudo Code
|
||||
# ================================
|
||||
#
|
||||
# After enabling a Wi-Fi device:
|
||||
# IF a controller is configured AND Anyfi.net is not disabled
|
||||
# ALLOCATE monitor interface and virtual access point pool for anyfid
|
||||
# START anyfid
|
||||
#
|
||||
# FOREACH Wi-Fi interface of this device
|
||||
# IF a controller is configured AND Anyfi.net is not disabled
|
||||
# GENERATE a config file for myfid
|
||||
#
|
||||
# IF the WPA passphrase has changed
|
||||
# ADD the --reset flag to myfid arguments
|
||||
#
|
||||
# START myfid on the Wi-Fi interface
|
||||
#
|
||||
# After disabling a Wi-Fi device:
|
||||
# STOP anyfid
|
||||
#
|
||||
# FOREACH Wi-Fi interface of this device
|
||||
# STOP myfid on the Wi-Fi interface
|
||||
#
|
||||
# NOTE 1: The integration provides remote access to all Wi-Fi interfaces on the
|
||||
# system that have anyfi_disabled set to 0. Each interface will have
|
||||
# its own myfid daemon. There should however only be one anyfid daemon
|
||||
# per radio.
|
||||
#
|
||||
# NOTE 2: On concurrent dual band routers each radio should have its own anyfid
|
||||
# daemon.
|
||||
#
|
||||
#
|
||||
# Anyfi.net UCI data model
|
||||
# ========================
|
||||
#
|
||||
# Anyfi.net global parameters:
|
||||
#
|
||||
# Name Type Default Description
|
||||
# controller
|
||||
# .hostname IP or FQDN demo.anyfi.net Controller IP or FQDN
|
||||
# .key path - Controller public key PEM file
|
||||
# optimizer
|
||||
# .key path - Optimizer public key PEM file
|
||||
#
|
||||
# Wi-Fi device parameters:
|
||||
#
|
||||
# Name Type Default Description
|
||||
# anyfi_disabled boolean 0 Enable/disable guest access on this radio
|
||||
# anyfi_iface port - Bind anyfid to a WAN interface IP address
|
||||
# anyfi_port number - Bind anyfid to a SDWN UDP port
|
||||
# anyfi_floor percent 5 Min backhaul and spectrum allocation
|
||||
# anyfi_ceiling percent 75 Max backhaul and spectrum allocation
|
||||
# anyfi_uplink integer - WAN uplink capacity in bits per second
|
||||
# anyfi_downlink integer - WAN downlink capacity in bits per second
|
||||
# anyfi_bssids integer - Max number of virtual interfaces to use
|
||||
# anyfi_clients integer - Max number of concurrent guest users
|
||||
#
|
||||
# Wi-Fi interface parameters:
|
||||
#
|
||||
# Name Type Default Description
|
||||
# anyfi_disabled boolean 0 Enable remote access on this network
|
||||
# anyfi_iface string - Bind myfid to a WAN interface IP
|
||||
# address
|
||||
# anyfi_port port - Bind myfid to a SDWN UDP port
|
||||
# anyfi_autz_server IP - RADIUS authorization server IP
|
||||
# anyfi_autz_port port 1812 RADIUS authorization server UDP port
|
||||
# anyfi_autz_secret string - RADIUS authorization server shared
|
||||
# secret
|
||||
# anyfi_acct_server IP - RADIUS extra accounting server IP
|
||||
# anyfi_acct_port port 1813 RADIUS extra accounting server UDP port
|
||||
# anyfi_acct_secret string - RADIUS extra accounting server shared
|
||||
# secret
|
||||
|
||||
append ENABLE_HOOKS anyfi_enable
|
||||
append DISABLE_HOOKS anyfi_disable
|
||||
|
||||
# Daemon run dir for temporary files.
|
||||
RUNDIR=/var/run
|
||||
|
||||
# Config file dir for persistent configuration files.
|
||||
CONFDIR=/etc
|
||||
|
||||
##### Wi-Fi device handling ##################################################
|
||||
|
||||
# Get the channel for Wi-Fi device.
|
||||
# anyfi_dev_get_channel <device>
|
||||
anyfi_dev_get_channel() {
|
||||
local device="$1"
|
||||
local hwmode channel
|
||||
|
||||
config_get hwmode "$device" hwmode
|
||||
config_get channel "$device" channel
|
||||
|
||||
if [ "$channel" = auto -o "$channel" = 0 ]; then
|
||||
case "$hwmode" in
|
||||
auto)
|
||||
channel=auto
|
||||
;;
|
||||
|
||||
*b*|*g*)
|
||||
channel=auto2
|
||||
;;
|
||||
|
||||
*a*)
|
||||
channel=auto5
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
echo "$channel"
|
||||
}
|
||||
|
||||
# Get the WLAN interface list for a WLAN device.
|
||||
# anyfi_get_vifs <device>
|
||||
anyfi_get_vifs() {
|
||||
local device=$1
|
||||
local vifs=""
|
||||
local cfg
|
||||
|
||||
for cfg in $CONFIG_SECTIONS; do
|
||||
local type dev
|
||||
config_get type "$cfg" TYPE
|
||||
config_get dev "$cfg" device
|
||||
|
||||
if [ "$type" = wifi-iface ] && [ "$dev" = "$device" ]; then
|
||||
append vifs "$cfg"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "$vifs"
|
||||
}
|
||||
|
||||
# Start the Anyfi.net radio head daemon anyfid on a device.
|
||||
# anyfi_dev_start <device> <type> <controller> <controller_key>
|
||||
anyfi_dev_start()
|
||||
{
|
||||
local device="$1"
|
||||
local type="$2"
|
||||
local controller="$3"
|
||||
local controller_key="$4"
|
||||
local nvifs bssids monitor iflist
|
||||
|
||||
# Determine how many virtual interfaces we should use
|
||||
config_get bssids "$device" anyfi_bssids
|
||||
nvifs=$(anyfi_get_vifs "$device" | wc -w)
|
||||
|
||||
if [ -n "$bssids" ]; then
|
||||
# Limit the number of virtual interfaces to 32
|
||||
[ "$bssids" -lt 32 ] || bssids=32
|
||||
elif [ $nvifs -lt 4 ]; then
|
||||
# Don't use more that 8 interfaces in total if possible...
|
||||
bssids=$((8 - $nvifs))
|
||||
else
|
||||
# ...but try to allocate at least 4 interfaces for anyfid.
|
||||
bssids=4
|
||||
fi
|
||||
|
||||
# ALLOCATE monitor and pool of virtual access points
|
||||
if monitor=$(anyfi_${type}_alloc_monitor "$device") && \
|
||||
iflist=$(anyfi_${type}_alloc_iflist "$device" $bssids)
|
||||
then
|
||||
local args=""
|
||||
local wanif port floor ceiling uplink downlink clients
|
||||
|
||||
config_get wanif "$device" anyfi_iface
|
||||
config_get port "$device" anyfi_port
|
||||
config_get floor "$device" anyfi_floor
|
||||
config_get ceiling "$device" anyfi_ceiling
|
||||
config_get uplink "$device" anyfi_uplink
|
||||
config_get downlink "$device" anyfi_downlink
|
||||
config_get clients "$device" anyfi_clients
|
||||
|
||||
# If there are no interfaces on this device then
|
||||
# anyfid controls channel
|
||||
if [ "$nvifs" -eq 0 ]; then
|
||||
args="$args --channel=$(anyfi_dev_get_channel $device)"
|
||||
fi
|
||||
|
||||
[ -n "$wanif" ] && args="$args --bind-if=$wanif"
|
||||
[ -n "$port" ] && args="$args --bind-port=$port"
|
||||
[ -n "$floor" ] && args="$args --floor=$floor"
|
||||
[ -n "$ceiling" ] && args="$args --ceiling=$ceiling"
|
||||
[ -n "$uplink" ] && args="$args --uplink=$uplink"
|
||||
[ -n "$downlink" ] && args="$args --downlink=$downlink"
|
||||
[ -n "$clients" ] && args="$args --max-clients=$clients"
|
||||
[ -n "$controller_key" ] && \
|
||||
args="$args --controller-key=$controller_key"
|
||||
|
||||
# START anyfid
|
||||
echo "$device: starting anyfid"
|
||||
/sbin/anyfid --accept-license -C "$controller" -B \
|
||||
-P $RUNDIR/anyfid_$device.pid $args \
|
||||
$monitor $iflist
|
||||
else
|
||||
echo "$device: failed to allocate anyfid interfaces" 1>&2
|
||||
fi
|
||||
}
|
||||
|
||||
##### Wi-Fi interface handling ###############################################
|
||||
|
||||
# Get the printable name of an interface.
|
||||
anyfi_vif_get_name() {
|
||||
local ifname
|
||||
config_get ifname "$1" ifname
|
||||
echo "${ifname:-$1}"
|
||||
}
|
||||
|
||||
# Generate the config file for myfid from UCI variables.
|
||||
# anyfi_vif_gen_config <vif>
|
||||
anyfi_vif_gen_config() {
|
||||
local vif="$1"
|
||||
local name="$(anyfi_vif_get_name $1)"
|
||||
local device net ssid enc key isolate ifname
|
||||
|
||||
config_get device "$vif" device
|
||||
config_get net "$vif" network
|
||||
config_get ssid "$vif" ssid
|
||||
config_get enc "$vif" encryption
|
||||
config_get key "$vif" key
|
||||
config_get isolate "$vif" isolate
|
||||
config_get ifname "$vif" ifname
|
||||
|
||||
# Check basic settings before proceeding
|
||||
[ -n "$net" ] || [ -n "$ssid" ] || return 1
|
||||
|
||||
local auth_proto auth_mode auth_cache group_rekey
|
||||
local ciphers wpa_ciphers rsn_ciphers passphrase
|
||||
local auth_server auth_port auth_secret
|
||||
local autz_server autz_port autz_secret
|
||||
local acct_server acct_port acct_secret
|
||||
local acct2_server acct2_port acct2_secret
|
||||
local radius_nasid
|
||||
|
||||
# Resolve explicit cipher overrides (tkip, ccmp or tkip+ccmp)
|
||||
case "$enc" in
|
||||
*+tkip+ccmp|*+tkip+aes)
|
||||
ciphers=tkip+ccmp
|
||||
;;
|
||||
|
||||
*+ccmp|*+aes)
|
||||
ciphers=ccmp
|
||||
;;
|
||||
|
||||
*+tkip)
|
||||
ciphers=tkip
|
||||
;;
|
||||
esac
|
||||
|
||||
# Resolve authentication protocol (WPA or WPA2)
|
||||
case "$enc" in
|
||||
psk-mixed*|wpa-mixed*|mixed-psk*|mixed-wpa*)
|
||||
auth_proto=wpa+rsn
|
||||
wpa_ciphers=$ciphers
|
||||
rsn_ciphers=$ciphers
|
||||
;;
|
||||
|
||||
psk2*|wpa2*)
|
||||
auth_proto=rsn
|
||||
rsn_ciphers=$ciphers
|
||||
;;
|
||||
|
||||
psk*|wpa*)
|
||||
auth_proto=wpa
|
||||
wpa_ciphers=$ciphers
|
||||
;;
|
||||
|
||||
none)
|
||||
echo "$name: no remote access for security reasons (open network)" 1>&2
|
||||
return 1
|
||||
;;
|
||||
|
||||
wep*)
|
||||
echo "$name: no remote access for security reasons (wep is insecure)" 1>&2
|
||||
return 1
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "$name: unrecognized encryption type $enc" 1>&2
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# Resolve authenticator mode (PSK or 802.1X)
|
||||
case "$enc" in
|
||||
psk*)
|
||||
auth_mode=psk
|
||||
passphrase=$key
|
||||
[ -n "$passphrase" ] || return 1
|
||||
;;
|
||||
|
||||
wpa*)
|
||||
auth_mode=eap
|
||||
|
||||
config_get auth_server "$vif" radius_server
|
||||
config_get auth_port "$vif" radius_port
|
||||
config_get auth_secret "$vif" radius_secret
|
||||
|
||||
config_get acct_server "$vif" acct_server
|
||||
config_get acct_port "$vif" acct_port
|
||||
config_get acct_secret "$vif" acct_secret
|
||||
|
||||
config_get auth_cache "$vif" auth_cache
|
||||
config_get group_rekey "$vif" wpa_group_rekey
|
||||
|
||||
[ -n "$auth_server" ] || return 1
|
||||
[ -n "$auth_secret" ] || auth_secret="$key"
|
||||
[ -n "$acct_server" -a -z "$acct_secret" ] && acct_secret="$key"
|
||||
;;
|
||||
|
||||
none)
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "$name: no remote access ('encryption' not configured)" 1>&2
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# Optional RADIUS authorization and accounting for Anyfi.net
|
||||
config_get autz_server "$vif" anyfi_autz_server
|
||||
config_get autz_port "$vif" anyfi_autz_port
|
||||
config_get autz_secret "$vif" anyfi_autz_secret
|
||||
|
||||
config_get acct2_server "$vif" anyfi_acct_server
|
||||
config_get acct2_port "$vif" anyfi_acct_port
|
||||
config_get acct2_secret "$vif" anyfi_acct_secret
|
||||
|
||||
config_get radius_nasid "$vif" radius_nasid
|
||||
|
||||
# Generate common config file options
|
||||
cat <<EOF
|
||||
ssid = '$ssid'
|
||||
bridge = br-$net
|
||||
auth_proto = $auth_proto
|
||||
EOF
|
||||
|
||||
# Generate dependent config file options
|
||||
[ "$isolate" = 1 ] && echo "isolation = 1"
|
||||
[ -n "$ifname" ] && echo "local_ap = $ifname"
|
||||
[ -n "$auth_mode" ] && echo "auth_mode = $auth_mode"
|
||||
[ -n "$auth_cache" ] && echo "auth_cache = $auth_cache"
|
||||
[ -n "$rsn_ciphers" ] && echo "rsn_ciphers = $rsn_ciphers"
|
||||
[ -n "$wpa_ciphers" ] && echo "wpa_ciphers = $wpa_ciphers"
|
||||
[ -n "$group_rekey" ] && echo "group_rekey = $group_rekey"
|
||||
[ -n "$passphrase" ] && echo "passphrase = '$passphrase'"
|
||||
[ -n "$radius_nasid" ] && echo "radius_nas_id = $radius_nas_id"
|
||||
if [ -n "$auth_server" ] && [ -n "$auth_secret" ]; then
|
||||
echo "radius_auth_server = $auth_server"
|
||||
echo "radius_auth_port = ${auth_port:-1812}"
|
||||
echo "radius_auth_secret = $auth_secret"
|
||||
fi
|
||||
if [ -n "$acct_server" ] && [ -n "$acct_secret" ]; then
|
||||
echo "radius_acct_server = $acct_server"
|
||||
echo "radius_acct_port = ${acct_port:-1813}"
|
||||
echo "radius_acct_secret = $acct_secret"
|
||||
fi
|
||||
if [ -n "$autz_server" ] && [ -n "$autz_secret" ]; then
|
||||
echo "radius_autz_server = $autz_server"
|
||||
echo "radius_autz_port = ${autz_port:-1812}"
|
||||
echo "radius_autz_secret = $autz_secret"
|
||||
fi
|
||||
if [ -n "$acct2_server" ] && [ -n "$acct2_secret" ]; then
|
||||
echo "radius_acct2_server = $acct2_server"
|
||||
echo "radius_acct2_port = ${acct2_port:-1813}"
|
||||
echo "radius_acct2_secret = $acct2_secret"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
# Get the current value from a myfid configuration file.
|
||||
# anyfi_vif_get_config <file> <config>
|
||||
anyfi_vif_get_config() {
|
||||
local file="$1"
|
||||
local key="$2"
|
||||
|
||||
[ -e "$file" ] || return 1
|
||||
|
||||
# Assume the format is exactly "key = value",
|
||||
# where value may or may not be in ''
|
||||
grep "$key = " $file | cut -d '=' -f2- | cut -b2- | \
|
||||
sed -e "/^'.*'$/s/^'\\(.*\\)'$/\\1/"
|
||||
}
|
||||
|
||||
# Start the Anyfi.net tunnel-termination daemon myfid on an interface.
|
||||
# anyfi_vif_start <vif> <controller> <controller_key> <optimizer_key>
|
||||
anyfi_vif_start()
|
||||
{
|
||||
local vif="$1"
|
||||
local controller="$2"
|
||||
local controller_key="$3"
|
||||
local optimizer_key="$4"
|
||||
|
||||
local name="$(anyfi_vif_get_name $vif)"
|
||||
local pid_file="$RUNDIR/myfid_$name.pid"
|
||||
local conf_file="$CONFDIR/myfid_$name.conf"
|
||||
local new_conf_file="$RUNDIR/myfid_$name.conf"
|
||||
|
||||
# GENERATE a config file for myfid
|
||||
if (anyfi_vif_gen_config $vif) > $new_conf_file; then
|
||||
local controller_key optimizer_key
|
||||
local key old_key wanif port
|
||||
local args=""
|
||||
|
||||
config_get key "$vif" key
|
||||
config_get wanif "$vif" anyfi_iface
|
||||
config_get port "$vif" anyfi_port
|
||||
|
||||
# ADD optional arguments
|
||||
[ -n "$wanif" ] && args="$args --bind-if=$wanif"
|
||||
[ -n "$port" ] && args="$args --bind-port=$port"
|
||||
[ -n "$controller_key" ] && \
|
||||
args="$args --controller-key=$controller_key"
|
||||
[ -n "$optimizer_key" ] && \
|
||||
args="$args --optimizer-key=$optimizer_key"
|
||||
|
||||
# ADD the --reset flag to myfid arguments if the passphrase
|
||||
# has changed or myfid is started for the first time
|
||||
old_key="$(anyfi_vif_get_config $conf_file passphrase)"
|
||||
[ "$key" == "$old_key" ] || args="$args --reset"
|
||||
|
||||
# Update the myfid config file in flash only if needed
|
||||
if ! cmp -s $new_conf_file $conf_file; then
|
||||
mv $new_conf_file $conf_file
|
||||
else
|
||||
rm -f $new_conf_file
|
||||
fi
|
||||
|
||||
# START myfid
|
||||
echo "$name: starting myfid"
|
||||
/sbin/myfid --accept-license -C "$controller" -B -P $pid_file \
|
||||
$args $conf_file
|
||||
fi
|
||||
}
|
||||
|
||||
# Stop an Anyfi.net daemon gracefully
|
||||
# anyfi_stop_daemon <pidfile>
|
||||
anyfi_stop_daemon() {
|
||||
local pidfile="$1"
|
||||
|
||||
kill -TERM $(cat $pidfile)
|
||||
for t in $(seq 0 5); do
|
||||
[ -e $pidfile ] || return 0
|
||||
sleep 1
|
||||
done
|
||||
|
||||
echo "Timeout waiting for daemon assocated with $pidfile to exit" 1>&2
|
||||
kill -KILL $(cat $pidfile)
|
||||
rm -f $pidfile
|
||||
return 1
|
||||
}
|
||||
|
||||
# Enable Anyfi.net for a Wi-Fi device.
|
||||
# Run from ENABLE_HOOKS
|
||||
anyfi_enable()
|
||||
{
|
||||
local device="$1"
|
||||
local controller
|
||||
local type vif vifs
|
||||
|
||||
# A controller IP or FQDN is required
|
||||
controller="$(uci get anyfi.controller.hostname 2>/dev/null)"
|
||||
[ -n "$controller" ] || return 0
|
||||
|
||||
# Optional controller and optimizer public keys
|
||||
controller_key="$(uci get anyfi.controller.key 2>/dev/null)"
|
||||
optimizer_key="$(uci get anyfi.optimizer.key 2>/dev/null)"
|
||||
|
||||
# Reload the wireless config to get the assigned ifnames right
|
||||
config_load wireless
|
||||
config_get type "$device" type
|
||||
vifs=$(anyfi_get_vifs "$device")
|
||||
|
||||
# START anyfid on this device
|
||||
if [ "$(config_get $device anyfi_disabled)" != 1 ] && \
|
||||
/sbin/anyfi-probe "$type"
|
||||
then
|
||||
anyfi_dev_start $device $type "$controller" "$controller_key"
|
||||
fi
|
||||
|
||||
# FOREACH Wi-Fi interface of this device
|
||||
for vif in $vifs; do
|
||||
if [ "$(config_get $vif disabled)" != 1 ] && \
|
||||
[ "$(config_get $vif anyfi_disabled)" != 1 ]
|
||||
then
|
||||
anyfi_vif_start $vif "$controller" \
|
||||
"$controller_key" "$optimizer_key"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# Disable Anyfi.net for a Wi-Fi device.
|
||||
# Run from DISABLE_HOOKS
|
||||
anyfi_disable()
|
||||
{
|
||||
local device="$1"
|
||||
local type vif vifs
|
||||
|
||||
# Reload the wireless config to get the assigned ifnames right
|
||||
config_load wireless
|
||||
config_get type "$device" type
|
||||
vifs=$(anyfi_get_vifs "$device")
|
||||
|
||||
# STOP anyfid on this device (if anyfid is running)
|
||||
if [ -e $RUNDIR/anyfid_$device.pid ]; then
|
||||
echo "$device: stopping anyfid"
|
||||
anyfi_stop_daemon $RUNDIR/anyfid_$device.pid
|
||||
anyfi_${type}_release_iflist $device
|
||||
anyfi_${type}_release_monitor $device
|
||||
fi
|
||||
|
||||
# FOREACH Wi-Fi interface of this device (with myfid running)
|
||||
for vif in $vifs; do
|
||||
local name="$(anyfi_vif_get_name $vif)"
|
||||
local pidfile="$RUNDIR/myfid_$name.pid"
|
||||
|
||||
if [ -e $pidfile ]; then
|
||||
echo "$name: stopping myfid"
|
||||
anyfi_stop_daemon $pidfile
|
||||
fi
|
||||
done
|
||||
}
|
||||
86
anyfi/files/lib/network/anyfi_broadcom.sh
Normal file
86
anyfi/files/lib/network/anyfi_broadcom.sh
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Copyright (C) 2013-2014 Anyfi Networks AB.
|
||||
# Anyfi.net setup functions for Broadcom wl driver.
|
||||
|
||||
# Get monitor name interface based for a device.
|
||||
# anyfi_dev_monitor_name <device>
|
||||
anyfi_broadcom_name_monitor() {
|
||||
local device="$1"
|
||||
|
||||
# Map wlX => radiotapX
|
||||
echo "$device" | sed 's/^.*\([0-9]\)$/radiotap\1/'
|
||||
}
|
||||
|
||||
# Get BSS index of the last wl interface that is used (=up)
|
||||
# wl0.2 => 2
|
||||
# wl0 => (empty)
|
||||
anyfi_broadcom_get_wlindex() {
|
||||
ifconfig | grep -o "^$1\..." | cut -d'.' -f2 | sort -n | tail -n 1
|
||||
}
|
||||
|
||||
# Allocate virtual Wi-Fi interfaces for anyfid.
|
||||
# anyfi_broadcom_alloc_iflist <device> <bssids>
|
||||
anyfi_broadcom_alloc_iflist() {
|
||||
local device="$1"
|
||||
local bssids="$2"
|
||||
local count=0
|
||||
local wlindex num
|
||||
|
||||
# Enable MBSS mode if not already enabled
|
||||
if [ "$(wlctl -i $device mbss)" = 0 ]; then
|
||||
wlctl -i $device down
|
||||
wlctl -i $device mbss 1
|
||||
wlctl -i $device up
|
||||
fi
|
||||
|
||||
wlindex=$(anyfi_broadcom_get_wlindex $device)
|
||||
|
||||
# Create WLAN interfaces and let the driver assign the BSSIDs
|
||||
for num in $(seq $bssids); do
|
||||
local idx=$(($wlindex + $num))
|
||||
local wlif=$device.$idx
|
||||
|
||||
# Do the 'wlctl' dance to make the driver assign proper BSSIDs
|
||||
wlctl -i $device bss -C $idx up > /dev/null || break
|
||||
wlctl -i $device ssid -C $idx "dummy" > /dev/null
|
||||
wlctl -i $device bss -C $idx up > /dev/null
|
||||
wlctl -i $device bss -C $idx down > /dev/null
|
||||
wlctl -i $device ssid -C $idx "" > /dev/null
|
||||
|
||||
local bssid=$(wlctl -i $wlif cur_etheraddr | cut -d' ' -f2)
|
||||
ifconfig $wlif hw ether $bssid > /dev/null
|
||||
count=$(($count + 1))
|
||||
done
|
||||
|
||||
[ "$count" -gt 0 ] && echo $device.$(($wlindex + 1))/$count
|
||||
}
|
||||
|
||||
# Release virtual Wi-Fi interfaces allocated for anyfid.
|
||||
# anyfi_broadcom_release_iflist <device>
|
||||
anyfi_broadcom_release_iflist() {
|
||||
true
|
||||
}
|
||||
|
||||
# Allocate a monitor interface for anyfid.
|
||||
# anyfi_broadcom_alloc_monitor <device>
|
||||
anyfi_broadcom_alloc_monitor() {
|
||||
local device="$1"
|
||||
local monitor=$(anyfi_broadcom_name_monitor $device)
|
||||
|
||||
wlctl -i $device monitor 0 || return 1
|
||||
wlctl -i $device monitor 3 || return 1
|
||||
ifconfig $monitor down || return 1
|
||||
ifconfig $monitor up || return 1
|
||||
echo $monitor
|
||||
}
|
||||
|
||||
# Release the monitor interface for anyfid.
|
||||
# anyfi_broadcom_release_monitor <device>
|
||||
anyfi_broadcom_release_monitor() {
|
||||
local device="$1"
|
||||
local monitor=$(anyfi_broadcom_name_monitor $device)
|
||||
|
||||
ifconfig $monitor down 2> /dev/null
|
||||
wlctl -i $device monitor 0 2> /dev/null
|
||||
}
|
||||
58
anyfi/files/sbin/anyfi-probe
Executable file
58
anyfi/files/sbin/anyfi-probe
Executable file
|
|
@ -0,0 +1,58 @@
|
|||
#!/bin/sh
|
||||
|
||||
if [ $# -lt 1 ]; then
|
||||
echo "Check if a WLAN driver type is supported by Anyfi.net radio software."
|
||||
echo "Usage: $0 {mac80211|...}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
number() {
|
||||
echo $2 | sed -e 's/[^0-9]/ /g' | cut -d' ' -f $1
|
||||
}
|
||||
|
||||
major() {
|
||||
number 1 $1
|
||||
}
|
||||
|
||||
minor() {
|
||||
number 2 $1
|
||||
}
|
||||
|
||||
case $1 in
|
||||
mac80211)
|
||||
COMPAT_VER=$(opkg list-installed kmod-mac80211 | cut -d'+' -f2)
|
||||
KERNEL_VER=$(uname -r)
|
||||
|
||||
# Future kernels > 3.x are OK
|
||||
[ "$(major $KERNEL_VER)" -gt 3 ] && return 0
|
||||
|
||||
# The required commit 86c228a7627f3f2776893da47592234140fbfba8
|
||||
# for mac80211 support was introduced in kernel 3.12.
|
||||
[ "$(major $KERNEL_VER)" -eq 3 ] && \
|
||||
[ "$(minor $KERNEL_VER)" -ge 12 ] && return 0
|
||||
|
||||
[ "$(major $COMPAT_VER)" -gt 2013 ] && return 0
|
||||
[ "$(major $COMPAT_VER)" -eq 2013 ] && \
|
||||
[ "$(minor $COMPAT_VER)" -ge 11 ] && return 0
|
||||
|
||||
cat <<EOF
|
||||
Support for mac80211 requires Linux kernel >= 3.12 or
|
||||
compat-wireless >= 2013-11-05. Please update your system.
|
||||
EOF
|
||||
;;
|
||||
|
||||
broadcom)
|
||||
return 0
|
||||
;;
|
||||
|
||||
*)
|
||||
cat<<EOF
|
||||
WLAN driver \"$1\" is not supported by the Anyfi.net radio software.
|
||||
Improved drivers with Anyfi.net support are available for Broadcom,
|
||||
Qualcomm Atheros, Ralink and Realtek chipsets. Please contact
|
||||
support@anyfi.net for updated drivers, reference integrations and
|
||||
commercial integration services.
|
||||
EOF
|
||||
;;
|
||||
esac
|
||||
exit 1
|
||||
803
asterisk-1.8.x-mod/Makefile
Normal file
803
asterisk-1.8.x-mod/Makefile
Normal file
|
|
@ -0,0 +1,803 @@
|
|||
#
|
||||
# Copyright (C) 2008-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:=asterisk18-mod
|
||||
PKG_VERSION:=1.8.10.1
|
||||
|
||||
PKG_SOURCE_VERSION:=e6a06b24a4e3d5ff786a4ad55a7c90de1defb49e
|
||||
PKG_SOURCE_PROTO:=git
|
||||
ifeq ($(CONFIG_PACKAGE_bcmkernel),y)
|
||||
PKG_SOURCE_URL:=git@ihgsp.inteno.se:asterisk-aa
|
||||
else
|
||||
PKG_SOURCE_URL:=http://ihgsp.inteno.se/git/asterisk-aa
|
||||
endif
|
||||
|
||||
PKG_RELEASE:=$(PKG_SOURCE_VERSION)
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_RELEASE).tar.gz
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
include $(INCLUDE_DIR)/ltqtapi.mk
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/asterisk18-mod/Default
|
||||
SUBMENU:=Telephony
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
URL:=http://www.asterisk.org/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod/Default/description
|
||||
Asterisk is a complete PBX in software. It provides all of the features
|
||||
you would expect from a PBX and more. Asterisk does voice over IP in three
|
||||
protocols, and can interoperate with almost all standards-based telephony
|
||||
equipment using relatively inexpensive hardware.
|
||||
endef
|
||||
|
||||
|
||||
define Package/asterisk18-mod
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=Complete open source PBX, v1.8x
|
||||
MENU:=1
|
||||
DEPENDS:= +natalie-dect-h +PACKAGE_bcmkernel:bcmkernel +PACKAGE_bcmopen:bcmopen +libopenssl +libncurses +libpopt +libpthread +uci +ubus +zlib @!TARGET_avr32
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod/description
|
||||
$(call Package/asterisk18-mod/Default/description)
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-sounds
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=Sound files
|
||||
DEPENDS:= asterisk18-mod
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-sounds/description
|
||||
$(call Package/asterisk18-mod/Default/description)
|
||||
This package contains sound files for Asterisk.
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-voicemail
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=Voicemail support
|
||||
DEPENDS:= asterisk18-mod
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-voicemail/description
|
||||
$(call Package/asterisk18-mod/Default/description)
|
||||
This package contains voicemail related modules for Asterisk.
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-app-transfer
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=Call transfer support
|
||||
DEPENDS:= asterisk18-mod
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-app-transfer/description
|
||||
$(call Package/asterisk18-mod/Default/description)
|
||||
This package contains the call transfer support module for Asterisk.
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-app-softhangup
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=SoftHangup application
|
||||
DEPENDS:= asterisk18-mod
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-app-softhangup/description
|
||||
$(call Package/asterisk18-mod/Default/description)
|
||||
This package contains the SoftHangup support module for Asterisk.
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-app-meetme
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=conferencing support
|
||||
DEPENDS:= asterisk18-mod +dahdi-tools-libtonezone +dahdi
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-app-meetme/description
|
||||
$(call Package/asterisk18-mod/Default/description)
|
||||
This package provides the MeetMe application driver Conferencing support to
|
||||
Asterisk.
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-iax2
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=IAX support
|
||||
DEPENDS:= asterisk18-mod +asterisk18-res-crypto
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-iax2/description
|
||||
$(call Package/asterisk18-mod/Default/description)
|
||||
This package provides IAX support to
|
||||
Asterisk.
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-cdr
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=CDR support
|
||||
DEPENDS:= asterisk18-mod
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-cdr/description
|
||||
$(call Package/asterisk18-mod/Default/description)
|
||||
This package provides Call Detail Record support to
|
||||
Asterisk.
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-res-musiconhold
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=MOH support
|
||||
DEPENDS:= asterisk18-mod
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-res-musiconhold/description
|
||||
$(call Package/asterisk18-mod/Default/description)
|
||||
This package provides Music On Hold support to
|
||||
Asterisk.
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-res-voice
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=Voice client/pbx support
|
||||
DEPENDS:= asterisk18-mod
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-res-voice/description
|
||||
$(call Package/asterisk18-mod/Default/description)
|
||||
This package provides Voice Client/pbx support to
|
||||
Asterisk.
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-res-srtp
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=SRTP support
|
||||
DEPENDS:= asterisk18-mod libsrtp +asterisk18-mod-res-crypto
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-res-srtp/description
|
||||
$(call Package/asterisk18-mod/Default/description)
|
||||
This package provides SRTP support to
|
||||
Asterisk.
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-res-stun
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=STUN support
|
||||
DEPENDS:= asterisk18-mod
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-app-queue
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=Queue support
|
||||
DEPENDS:= asterisk18-mod
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-gtalk
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=GTalk support
|
||||
DEPENDS:= asterisk18-mod +libiksemel
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-gtalk/description
|
||||
$(call Package/asterisk18-mod/Default/description)
|
||||
This package provides the channel chan_gtalk and res_jabber for GTalk
|
||||
support to Asterisk.
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-mobile
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=Mobile channel support
|
||||
DEPENDS:= asterisk18-mod +bluez-libs
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-mobile/description
|
||||
$(call Package/asterisk18-mod/Default/description)
|
||||
This package provides the channel chan_mobile support to Asterisk.
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-res-timing-timerfd
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:= Timerfd Timing Interface
|
||||
DEPENDS:= asterisk18-mod
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-res-timing-pthread
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:= pthread Timing Interface
|
||||
DEPENDS:= asterisk18-mod
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-res-fax
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=Generic FAX Resource for FAX technology resource modules
|
||||
DEPENDS:= asterisk18-mod +asterisk18-mod-res-timing-pthread
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-res-fax-spandsp
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=Spandsp T.38 and G.711 FAX Resource
|
||||
DEPENDS:= asterisk18-mod +asterisk18-mod-res-fax +libspandsp
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-mgcp
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=MGCP channel support
|
||||
DEPENDS:= asterisk18-mod
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-mgcp/description
|
||||
$(call Package/asterisk18-mod/Default/description)
|
||||
This package provides the channel chan_mgcp support to Asterisk.
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-skinny
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=Skinny channel support
|
||||
DEPENDS:= asterisk18-mod
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-skinny/description
|
||||
$(call Package/asterisk18-mod/Default/description)
|
||||
This package provides the channel chan_skinny support to Asterisk.
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-brcm
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=Broadcom channel support
|
||||
DEPENDS:= asterisk18-mod
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-brcm/description
|
||||
$(call Package/asterisk18-mod/Default/description)
|
||||
This package provides the channel chan_brcm support to Asterisk.
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-curl
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=CURL support
|
||||
DEPENDS:= asterisk18-mod +libcurl
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-curl/description
|
||||
$(call Package/asterisk18-mod/Default/description)
|
||||
This package provides CURL
|
||||
support to Asterisk.
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-mysql
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=MySQL support
|
||||
DEPENDS:= asterisk18-mod +PACKAGE_asterisk18-mysql:libmysqlclient
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-mysql/description
|
||||
$(call Package/asterisk18-mod/Default/description)
|
||||
This package provides MySQL
|
||||
support to Asterisk.
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-lantiq
|
||||
$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=Lantiq TAPI support
|
||||
DEPENDS:= asterisk18-mod $(LTQ_TAPI_DEPENDS)
|
||||
URL:=http://git.nanl.de/?p=asterisk_channel_lantiq.git
|
||||
MAINTAINER:=Mirko Vogt <mirko@openwrt.org>
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-lantiq/description
|
||||
$(call Package/asterisk18-mod/Default/description)
|
||||
This package provides the channel chan_lantiq support to Asterisk.
|
||||
endef
|
||||
|
||||
CONFIGURE_ARGS+= \
|
||||
--without-inotify
|
||||
|
||||
ifneq ($(SDK)$(CONFIG_PACKAGE_asterisk18-mod-app-meetme),)
|
||||
CONFIGURE_ARGS+= \
|
||||
--with-dahdi="$(STAGING_DIR)/usr"
|
||||
else
|
||||
CONFIGURE_ARGS+= \
|
||||
--without-dahdi
|
||||
endif
|
||||
|
||||
ifneq ($(SDK)$(CONFIG_PACKAGE_asterisk18-mod-chan-gtalk),)
|
||||
CONFIGURE_ARGS+= \
|
||||
--with-gnutls="$(STAGING_DIR)/usr" \
|
||||
--with-iksemel="$(STAGING_DIR)/usr"
|
||||
SITE_VARS+= \
|
||||
ac_cv_lib_iksemel_iks_start_sasl=yes \
|
||||
ac_cv_lib_gnutls_gnutls_bye=yes
|
||||
else
|
||||
CONFIGURE_ARGS+= \
|
||||
--without-gnutls \
|
||||
--without-iksemel
|
||||
endif
|
||||
|
||||
ifneq ($(SDK)$(CONFIG_PACKAGE_asterisk18-mod-curl),)
|
||||
CONFIGURE_ARGS+= \
|
||||
--with-curl="$(STAGING_DIR)/usr"
|
||||
else
|
||||
CONFIGURE_ARGS+= \
|
||||
--without-curl
|
||||
endif
|
||||
|
||||
ifneq ($(SDK)$(CONFIG_PACKAGE_asterisk18-mod-mysql),)
|
||||
CONFIGURE_ARGS+= \
|
||||
--with-mysqlclient="$(STAGING_DIR)/usr/bin"
|
||||
else
|
||||
CONFIGURE_ARGS+= \
|
||||
--without-mysqlclient
|
||||
endif
|
||||
|
||||
ifneq ($(SDK)$(CONFIG_PACKAGE_asterisk18-mod-res-fax-spandsp),)
|
||||
CONFIGURE_ARGS+= \
|
||||
--with-spandsp="$(STAGING_DIR)/usr"
|
||||
else
|
||||
CONFIGURE_ARGS+= \
|
||||
--without-spandsp
|
||||
endif
|
||||
|
||||
ifneq ($(SDK)$(CONFIG_PACKAGE_asterisk18-mod-chan-mobile),)
|
||||
CONFIGURE_ARGS+= \
|
||||
--with-bluetooth="$(STAGING_DIR)/usr"
|
||||
else
|
||||
CONFIGURE_ARGS+= \
|
||||
--without-bluetooth
|
||||
endif
|
||||
|
||||
ifneq ($(SDK)$(CONFIG_PACKAGE_asterisk18-mod-res-srtp),)
|
||||
CONFIGURE_ARGS+= \
|
||||
--with-srtp="$(STAGING_DIR)/usr"
|
||||
else
|
||||
CONFIGURE_ARGS+= \
|
||||
--without-srtp
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_TARGET_IBOARDID),"D301")
|
||||
EXTRA_CFLAGS += -DNTR_SUPPORT
|
||||
endif
|
||||
|
||||
CONFIGURE_ARGS+= \
|
||||
--without-curses \
|
||||
--with-gsm=internal \
|
||||
--without-cap \
|
||||
--without-gtk \
|
||||
--without-gtk2 \
|
||||
--without-isdnnet \
|
||||
--without-kde \
|
||||
--without-misdn \
|
||||
--without-nbs \
|
||||
--with-ncurses="$(STAGING_DIR)/usr" \
|
||||
--without-netsnmp \
|
||||
--without-newt \
|
||||
--without-odbc \
|
||||
--without-ogg \
|
||||
--without-osptk \
|
||||
--with-popt="$(STAGING_DIR)/usr" \
|
||||
--without-pri \
|
||||
--without-qt \
|
||||
--without-radius \
|
||||
--without-sdl \
|
||||
--without-suppserv \
|
||||
--without-tds \
|
||||
--without-termcap \
|
||||
--without-tinfo \
|
||||
--without-vorbis \
|
||||
--without-vpb \
|
||||
--with-z="$(STAGING_DIR)/usr" \
|
||||
--with-sounds-cache="$(DL_DIR)" \
|
||||
--disable-xmldoc
|
||||
|
||||
EXTRA_CFLAGS+= $(TARGET_CPPFLAGS)
|
||||
EXTRA_LDFLAGS+= $(TARGET_LDFLAGS)
|
||||
|
||||
|
||||
|
||||
define Build/Prepare
|
||||
$(call Build/Prepare/Default)
|
||||
ifneq ($(CONFIG_TARGET_lantiq),)
|
||||
$(CP) ./src-lantiq/* $(PKG_BUILD_DIR)/
|
||||
endif
|
||||
endef
|
||||
|
||||
define Build/Configure
|
||||
-rm $(PKG_BUILD_DIR)/menuselect.makeopts
|
||||
$(call Build/Configure/Default,,$(SITE_VARS))
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
$(MAKE) -C "$(PKG_BUILD_DIR)" \
|
||||
include/asterisk/version.h \
|
||||
include/asterisk/buildopts.h defaults.h \
|
||||
makeopts.embed_rules
|
||||
ASTCFLAGS="$(EXTRA_CFLAGS) -DLOW_MEMORY" \
|
||||
ASTLDFLAGS="$(EXTRA_LDFLAGS)" \
|
||||
$(MAKE) -C "$(PKG_BUILD_DIR)" \
|
||||
ASTVARLIBDIR="/usr/lib/asterisk" \
|
||||
ASTDATADIR="/usr/lib/asterisk" \
|
||||
ASTKEYDIR="/usr/lib/asterisk" \
|
||||
ASTDBDIR="/usr/lib/asterisk" \
|
||||
NOISY_BUILD="1" \
|
||||
DEBUG="" \
|
||||
OPTIMIZE="" \
|
||||
DESTDIR="$(PKG_INSTALL_DIR)" \
|
||||
all install samples
|
||||
endef
|
||||
|
||||
define Build/InstallDev
|
||||
$(INSTALL_DIR) $(1)/usr/include/asterisk-1.8/include/asterisk/
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/include/asterisk/*.h $(1)/usr/include/asterisk-1.8/include/asterisk/
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/include/asterisk.h $(1)/usr/include/asterisk-1.8/include/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod/conffiles
|
||||
/etc/asterisk/asterisk.conf
|
||||
/etc/asterisk/modules.conf
|
||||
/etc/asterisk/extensions.conf
|
||||
/etc/asterisk/sip.conf
|
||||
/etc/asterisk/sip_notify.conf
|
||||
/etc/asterisk/features.conf
|
||||
/etc/asterisk/indications.conf
|
||||
/etc/asterisk/logger.conf
|
||||
/etc/asterisk/manager.conf
|
||||
/etc/asterisk/rtp.conf
|
||||
/etc/default/asterisk
|
||||
/etc/init.d/asterisk
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod/install
|
||||
$(INSTALL_DIR) $(1)/etc/asterisk/ssl
|
||||
for f in asterisk extensions features \
|
||||
indications logger manager modules \
|
||||
sip sip_notify rtp; do \
|
||||
$(CP) $(PKG_INSTALL_DIR)/etc/asterisk/$$$$f.conf $(1)/etc/asterisk/ ; \
|
||||
done
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
for f in app_dial app_echo app_playback app_macro \
|
||||
chan_sip res_rtp_asterisk res_rtp_multicast \
|
||||
codec_ulaw codec_gsm \
|
||||
format_gsm format_pcm format_wav format_wav_gsm \
|
||||
pbx_config \
|
||||
func_strings func_timeout func_callerid func_logic; do \
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/$$$$f.so $(1)/usr/lib/asterisk/modules/ ; \
|
||||
done
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/asterisk $(1)/usr/sbin/
|
||||
$(INSTALL_DIR) $(1)/etc/default
|
||||
$(INSTALL_DATA) ./files/asterisk.default $(1)/etc/default/asterisk
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/asterisk.init $(1)/etc/init.d/asterisk
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-sounds/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/sounds/
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/asterisk/sounds/en/* $(1)/usr/lib/asterisk/sounds/
|
||||
rm -f $(1)/usr/lib/asterisk/sounds/vm-*
|
||||
rm -f $(1)/usr/lib/asterisk/sounds/conf-*
|
||||
endef
|
||||
|
||||
|
||||
define Package/asterisk18-mod-voicemail/conffiles
|
||||
/etc/asterisk/voicemail.conf
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-voicemail/install
|
||||
$(INSTALL_DIR) $(1)/etc/asterisk
|
||||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/etc/asterisk/voicemail.conf $(1)/etc/asterisk/
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/*voicemail.so $(1)/usr/lib/asterisk/modules/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/res_adsi.so $(1)/usr/lib/asterisk/modules/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/res_smdi.so $(1)/usr/lib/asterisk/modules/
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/sounds/
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/asterisk/sounds/en/vm-*.gsm $(1)/usr/lib/asterisk/sounds/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-app-meetme/conffiles
|
||||
/etc/asterisk/meetme.conf
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-app-meetme/install
|
||||
$(INSTALL_DIR) $(1)/etc/asterisk
|
||||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/etc/asterisk/meetme.conf $(1)/etc/asterisk/
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/app_meetme.so $(1)/usr/lib/asterisk/modules/
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/sounds/
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/lib/asterisk/sounds/en/conf-*.gsm $(1)/usr/lib/asterisk/sounds/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-iax2/conffiles
|
||||
/etc/asterisk/iax.conf
|
||||
/etc/asterisk/iaxprov.conf
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-cdr/conffiles
|
||||
/etc/asterisk/cdr.conf
|
||||
/etc/asterisk/cdr_custom.conf
|
||||
/etc/asterisk/cdr_manager.conf
|
||||
/etc/asterisk/cdr_odbc.conf
|
||||
/etc/asterisk/cdr_pgsql.conf
|
||||
/etc/asterisk/cdr_tds.conf
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-res-musiconhold/conffiles
|
||||
/etc/asterisk/musiconhold.conf
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-iax2/install
|
||||
$(INSTALL_DIR) $(1)/etc/asterisk
|
||||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/etc/asterisk/iax.conf $(1)/etc/asterisk/
|
||||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/etc/asterisk/iaxprov.conf $(1)/etc/asterisk/
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/chan_iax2.so $(1)/usr/lib/asterisk/modules/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-cdr/install
|
||||
$(INSTALL_DIR) $(1)/etc/asterisk
|
||||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/etc/asterisk/cdr*.conf $(1)/etc/asterisk/
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/*cdr*.so $(1)/usr/lib/asterisk/modules/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-res-musiconhold/install
|
||||
$(INSTALL_DIR) $(1)/etc/asterisk
|
||||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/etc/asterisk/musiconhold.conf $(1)/etc/asterisk/
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/res_musiconhold.so $(1)/usr/lib/asterisk/modules/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-res-voice/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/res_voice.so $(1)/usr/lib/asterisk/modules/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-gtalk/conffiles
|
||||
/etc/asterisk/gtalk.conf
|
||||
/etc/asterisk/jabber.conf
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-gtalk/install
|
||||
$(INSTALL_DIR) $(1)/etc/asterisk
|
||||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/etc/asterisk/gtalk.conf $(1)/etc/asterisk/
|
||||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/etc/asterisk/jabber.conf $(1)/etc/asterisk/
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/chan_gtalk.so $(1)/usr/lib/asterisk/modules/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/res_jabber.so $(1)/usr/lib/asterisk/modules/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-mobile/conffiles
|
||||
/etc/asterisk/chan_mobile.conf
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-mobile/install
|
||||
$(INSTALL_DIR) $(1)/etc/asterisk
|
||||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/etc/asterisk/chan_mobile.conf $(1)/etc/asterisk/
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/chan_mobile.so $(1)/usr/lib/asterisk/modules/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-res-timing-timerfd/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/res_timing_timerfd.so $(1)/usr/lib/asterisk/modules/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-res-timing-pthread/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/res_timing_pthread.so $(1)/usr/lib/asterisk/modules/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-res-fax/conffiles
|
||||
/etc/asterisk/res_fax.conf
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-res-fax/install
|
||||
$(INSTALL_DIR) $(1)/etc/asterisk
|
||||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/etc/asterisk/res_fax.conf $(1)/etc/asterisk/
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/res_fax.so $(1)/usr/lib/asterisk/modules/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-res-fax-spandsp/install
|
||||
$(INSTALL_DIR) $(1)/etc/asterisk
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/res_fax_spandsp.so $(1)/usr/lib/asterisk/modules/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-mgcp/conffiles
|
||||
/etc/asterisk/mgcp.conf
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-mgcp/install
|
||||
$(INSTALL_DIR) $(1)/etc/asterisk
|
||||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/etc/asterisk/mgcp.conf $(1)/etc/asterisk/
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/chan_mgcp.so $(1)/usr/lib/asterisk/modules/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-skinny/conffiles
|
||||
/etc/asterisk/skinny.conf
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-skinny/install
|
||||
$(INSTALL_DIR) $(1)/etc/asterisk
|
||||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/etc/asterisk/skinny.conf $(1)/etc/asterisk/
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/chan_skinny.so $(1)/usr/lib/asterisk/modules/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-brcm/conffiles
|
||||
/etc/asterisk/brcm.conf
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-brcm/install
|
||||
$(INSTALL_DIR) $(1)/etc/asterisk
|
||||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/etc/asterisk/brcm.conf $(1)/etc/asterisk/
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/chan_brcm.so $(1)/usr/lib/asterisk/modules/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-curl/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/func_curl.so $(1)/usr/lib/asterisk/modules/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/res_curl.so $(1)/usr/lib/asterisk/modules/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-app-transfer/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/app_transfer.so $(1)/usr/lib/asterisk/modules/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-app-softhangup/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/app_softhangup.so $(1)/usr/lib/asterisk/modules/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-mysql/conffiles
|
||||
/etc/asterisk/app_mysql.conf
|
||||
/etc/asterisk/res_config_mysql.conf
|
||||
/etc/asterisk/cdr_mysql.conf
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-mysql/install
|
||||
$(INSTALL_DIR) $(1)/etc/asterisk
|
||||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/etc/asterisk/app_mysql.conf $(1)/etc/asterisk/
|
||||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/etc/asterisk/res_config_mysql.conf $(1)/etc/asterisk/
|
||||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/etc/asterisk/cdr_mysql.conf $(1)/etc/asterisk/
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/app_mysql.so $(1)/usr/lib/asterisk/modules/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/cdr_mysql.so $(1)/usr/lib/asterisk/modules/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/res_config_mysql.so $(1)/usr/lib/asterisk/modules/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-lantiq/conffiles
|
||||
/etc/asterisk/lantiq.conf
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-chan-lantiq/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_DIR) $(1)/etc/asterisk
|
||||
$(INSTALL_DATA) $(PKG_INSTALL_DIR)/etc/asterisk/lantiq.conf $(1)/etc/asterisk/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/chan_lantiq.so $(1)/usr/lib/asterisk/modules/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-res-srtp/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/res_srtp.so $(1)/usr/lib/asterisk/modules/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-res-stun/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/res_stun_monitor.so $(1)/usr/lib/asterisk/modules/
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-app-queue/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/app_queue.so $(1)/usr/lib/asterisk/modules/
|
||||
endef
|
||||
|
||||
define Buildasterisk18-modModuleTemplate
|
||||
|
||||
define Package/asterisk18-mod-$(subst _,-,$(1))
|
||||
$$(call Package/asterisk18-mod/Default)
|
||||
TITLE:=$(2) support
|
||||
DEPENDS:= asterisk18-mod $(4)
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-$(subst _,-,$(1))/description
|
||||
$$(call Package/asterisk18-mod/Default/description)
|
||||
This package provides support $(3) in Asterisk.
|
||||
endef
|
||||
|
||||
define Package/asterisk18-mod-$(subst _,-,$(1))/install
|
||||
$(INSTALL_DIR) $$(1)/usr/lib/asterisk/modules
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/asterisk/modules/$(1).so $$(1)/usr/lib/asterisk/modules/
|
||||
endef
|
||||
|
||||
$$(eval $$(call BuildPackage,asterisk18-mod-$(subst _,-,$(1))))
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,asterisk18-mod))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-voicemail))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-sounds))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-app-meetme))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-app-transfer))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-app-softhangup))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-chan-iax2))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-cdr))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-res-musiconhold))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-res-voice))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-chan-gtalk))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-chan-mobile))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-res-fax))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-res-fax-spandsp))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-res-timing-timerfd))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-res-timing-pthread))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-chan-mgcp))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-chan-skinny))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-chan-brcm))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-curl))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-mysql))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-chan-lantiq))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-res-srtp))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-res-stun))
|
||||
$(eval $(call BuildPackage,asterisk18-mod-app-queue))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_authenticate,Authenticate,support for executing arbitrary authenticate commands))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_chanisavail,Channel availability check,support for checking if a channel is available))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_chanspy,Channel listen in,support for listening in on any channel))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_directed_pickup,Directed call pickup,support for directed call pickup))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_exec,Exec application,support for application execution))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_minivm,Minimal voicemail system,a voicemail system in small building blocks working together based on the Comedian Mail voicemail system))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_readexten,Extension to variable,a trivial application to read an extension into a variable))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_read,Variable read,a trivial application to read a variable))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_sayunixtime,Say Unix time,an application to say Unix time))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_sms,SMS,SMS support (ETSI ES 201 912 protocol 1)))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_stack,Stack applications, stack applications Gosub Return etc., +asterisk18-res-agi))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_system,System exec,support for executing system commands))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_talkdetect,File playback with audio detect,for file playback with audio detect))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_waituntil,Sleep,support sleeping until the given epoch))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_while,While loop,a while loop implementation))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,chan_agent,Agents proxy channel, an implementation of agents proxy channel))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,chan_local,Local proxy channel, an implementation of local proxy channel))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,codec_alaw,Signed linear to alaw translation,translation between signed linear and alaw codecs))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,codec_ulaw,Signed linear to ulaw translation,translation between signed linear and ulaw codecs))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,codec_a_mu,Alaw to ulaw translation,translation between alaw and ulaw codecs))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,codec_g722,G.722,a high bit rate 48/56/64Kbps ITU standard codec))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,codec_g726,Signed linear to G.726 translation,translation between signed linear and ITU G.726-32kbps codecs))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,codec_ilbc,iLBC,internet Low Bitrate Codec))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,codec_gsm,GSM,GSM codec))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,format_g726,G.726,support for headerless G.726 16/24/32/40kbps data format))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,format_g729,G.729,support for raw headerless G729 data))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,format_sln,Raw slinear format,support for raw slinear format))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,format_sln16,Raw slinear 16 format,support for Raw slinear 16 format))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,func_db,Database interaction,functions for interaction with the database))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,func_devstate,Blinky lights control,functions for manually controlled blinky lights))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,func_vmcount,vmcount dialplan,a vmcount dialplan function))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,func_extstate,Hinted extension state,retrieving the state of a hinted extension for dialplan control))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,func_global,Global variable,global variable dialplan functions))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,func_shell,Shell,support for shell execution))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,pbx_ael,Asterisk Extension Logic,support for symbolic Asterisk Extension Logic))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,res_ael_share,Shareable AEL code,support for shareable AEL code mainly between internal and external modules))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,pbx_spool,Call Spool,outgoing call spool support))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,res_agi,Asterisk Gateway Interface,support for the Asterisk Gateway Interface extension))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,res_crypto,Provide Crypto,Cryptographic Signature capability))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_alarmreceiver,Alarm receiver,Central Station Alarm receiver for Ademco Contact ID))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_setcallerid,Set callerid,support for setting callerid))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_verbose,Verbose logging,Verbose logging application))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,func_channel,Channel info,Channel info dialplan function))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,func_blacklist,Blacklist on callerid,looking up the callerid number and see if it is blacklisted))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_originate,Originate a call,originating an outbound call and connecting it to a specified extension or application))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,func_uri,URI encoding and decoding,Encodes and decodes URI-safe strings))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_disa,Direct Inward System Access,Direct Inward System Access))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_senddtmf,Send DTMF digits,Sends arbitrary DTMF digits))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,func_cut,CUT function,CUT function))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,res_clioriginate,Calls via CLI,Originate calls via the CLI))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_mixmonitor,Record a call and mix the audio,record a call and mix the audio during the recording))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_playtones,Playtones application,play a tone list))
|
||||
$(eval $(call Buildasterisk18-modModuleTemplate,app_record,Record sound file,to record a sound file))
|
||||
4
asterisk-1.8.x-mod/files/asterisk.default
Normal file
4
asterisk-1.8.x-mod/files/asterisk.default
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
## startup options for /etc/init.d/asterisk
|
||||
|
||||
ENABLE_ASTERISK="yes"
|
||||
OPTIONS=""
|
||||
51
asterisk-1.8.x-mod/files/asterisk.init
Normal file
51
asterisk-1.8.x-mod/files/asterisk.init
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2008 OpenWrt.org
|
||||
START=98
|
||||
STOP=10
|
||||
|
||||
DEST=
|
||||
DEFAULT=$DEST/etc/default/asterisk
|
||||
OPTIONS=""
|
||||
|
||||
asterisk_boot() {
|
||||
[ -f $DEFAULT ] && . $DEFAULT
|
||||
[ -d $DEST/var/run/asterisk ] || mkdir -p $DEST/var/run/asterisk
|
||||
[ -d $DEST/var/log/asterisk ] || mkdir -p $DEST/var/log/asterisk
|
||||
[ -d $DEST/var/spool/asterisk ] || mkdir -p $DEST/var/spool/asterisk
|
||||
[ -d /var/spool/asterisk ] || mkdir -p /var/spool/asterisk
|
||||
|
||||
# does the board have a fxs relay?
|
||||
local fxsRelayGpio=$(uci get -q /lib/db/config/hw.board.fxsRelayGpio)
|
||||
if [ "$fxsRelayGpio" != "" ]; then
|
||||
/sbin/brcm_fw_tool set -x $fxsRelayGpio -p 1
|
||||
fi
|
||||
|
||||
echo 'starting asterisk'
|
||||
$DEST/usr/sbin/asterisk $OPTIONS
|
||||
}
|
||||
|
||||
asterisk_restart() {
|
||||
asterisk -rx "core reload"
|
||||
asterisk -rx "dialplan reload"
|
||||
asterisk -rx "brcm reload"
|
||||
echo "asterisk reloaded"
|
||||
}
|
||||
|
||||
boot()
|
||||
{
|
||||
asterisk_boot
|
||||
}
|
||||
|
||||
start() {
|
||||
asterisk_boot
|
||||
restart
|
||||
}
|
||||
|
||||
stop() {
|
||||
[ -f $DEST/var/run/asterisk/asterisk.pid ]
|
||||
echo 'stopping asterisk'
|
||||
}
|
||||
|
||||
restart() {
|
||||
asterisk_restart
|
||||
}
|
||||
50
bcmhotproxy/Makefile
Normal file
50
bcmhotproxy/Makefile
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
#
|
||||
# Copyright (C) 2006-2009 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:=bcmhotproxy
|
||||
PKG_RELEASE:=13
|
||||
|
||||
PKG_BUILD_DIR := $(KERNEL_BUILD_DIR)/$(PKG_NAME)
|
||||
STAMP_PREPARED := $(STAMP_PREPARED)_$(call confvar,CONFIG_MTD_REDBOOT_PARTS)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/bcmhotproxy
|
||||
SECTION:=utils
|
||||
CATEGORY:=Base system
|
||||
TITLE:=Daemon That feeds broadcom driver calls to hotplug2
|
||||
endef
|
||||
|
||||
define Package/bcmhotproxy/description
|
||||
This package contains a Daemon that will listen to link events from broadcoms adsl driver and etherent driver and proxy them to hotplug
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
mkdir -p $(PKG_BUILD_DIR)
|
||||
$(CP) ./src/* $(PKG_BUILD_DIR)/
|
||||
$(CP) ./files/* $(PKG_BUILD_DIR)/
|
||||
endef
|
||||
|
||||
target=$(firstword $(subst -, ,$(BOARD)))
|
||||
|
||||
MAKE_FLAGS += TARGET="$(target)"
|
||||
TARGET_CFLAGS += -Dtarget_$(target)=1 -Wall
|
||||
|
||||
|
||||
define Package/bcmhotproxy/install
|
||||
$(INSTALL_DIR) $(1)/sbin
|
||||
$(INSTALL_DIR) $(1)/etc/
|
||||
$(INSTALL_DIR) $(1)/etc/init.d/
|
||||
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/etc/init.d/* $(1)/etc/init.d/
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bcmhotproxy $(1)/sbin/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,bcmhotproxy))
|
||||
11
bcmhotproxy/files/etc/init.d/bcmhotproxy
Executable file
11
bcmhotproxy/files/etc/init.d/bcmhotproxy
Executable file
|
|
@ -0,0 +1,11 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
#
|
||||
# Copyright (C) 2009 OpenWrt.org
|
||||
#
|
||||
|
||||
START=15
|
||||
|
||||
start() {
|
||||
/sbin/bcmhotproxy
|
||||
}
|
||||
|
||||
8
bcmhotproxy/src/Makefile
Normal file
8
bcmhotproxy/src/Makefile
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
CC = gcc
|
||||
CFLAGS += -Wall
|
||||
|
||||
obj = bcmhotproxy.o brcmdaemon.o
|
||||
|
||||
bcmhotproxy: $(obj) $(obj.$(TARGET))
|
||||
clean:
|
||||
rm -f *.o
|
||||
139
bcmhotproxy/src/bcmhotproxy.c
Normal file
139
bcmhotproxy/src/bcmhotproxy.c
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
/*
|
||||
* bcmhotproxy -- a proxy to send messages from broadcom drivers to userspace
|
||||
*
|
||||
* Copyright (C) 2012-2013 Inteno Broadband Technology AB. All rights reserved.
|
||||
*
|
||||
* Author: Strhuan Blomquist
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* 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., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA
|
||||
*/
|
||||
#include "bcmhotproxy.h"
|
||||
|
||||
int netlink_init() {
|
||||
int sock_fd;
|
||||
sock_fd=socket(PF_NETLINK, SOCK_RAW, NETLINK_BRCM_MONITOR);
|
||||
if(sock_fd<0)
|
||||
return -1;
|
||||
return sock_fd;
|
||||
}
|
||||
int hotplug_call(struct hotplug_arg arg)
|
||||
{
|
||||
char str[512];
|
||||
int ret;
|
||||
memset(str, '\0', sizeof(512));
|
||||
syslog(LOG_INFO, "ACTION=%s INTERFACE=%s /sbin/hotplug-call %s", arg.action,arg.inteface,arg.subsystem);
|
||||
sprintf(str, "ACTION=%s INTERFACE=%s /sbin/hotplug-call %s",arg.action,arg.inteface,arg.subsystem);
|
||||
ret=system(str);
|
||||
return ret;
|
||||
}
|
||||
hotplug_arg createargumetstruct(char *hotplugmsg)
|
||||
{
|
||||
hotplug_arg arg;
|
||||
char argumets[3][20];
|
||||
char * pch;
|
||||
int x=0;
|
||||
pch = strtok (hotplugmsg," ");
|
||||
while (pch != NULL){
|
||||
strcpy(argumets[x],pch);
|
||||
pch = strtok (NULL, " ");
|
||||
x++;
|
||||
}
|
||||
strncpy(arg.action,argumets[0],sizeof(arg.action));
|
||||
strncpy(arg.inteface,argumets[1],sizeof(arg.action));
|
||||
strncpy(arg.subsystem,argumets[2],sizeof(arg.action));
|
||||
|
||||
return arg;
|
||||
|
||||
}
|
||||
|
||||
int netlink_bind(int sock_fd) {
|
||||
|
||||
struct sockaddr_nl src_addr;
|
||||
memset(&src_addr, 0, sizeof(src_addr));
|
||||
src_addr.nl_family = AF_NETLINK;
|
||||
src_addr.nl_pid = getpid(); /* self pid */
|
||||
src_addr.nl_groups = 1; //multicast Group
|
||||
|
||||
bind(sock_fd, (struct sockaddr*)&src_addr,sizeof(src_addr));
|
||||
|
||||
if (bind(sock_fd, (struct sockaddr*)&src_addr,sizeof(src_addr))) {
|
||||
close(sock_fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return sock_fd;
|
||||
}
|
||||
|
||||
int dispatcher() {
|
||||
struct sockaddr_nl dest_addr;
|
||||
struct nlmsghdr *nlh = NULL;
|
||||
struct iovec iov;
|
||||
struct msghdr msg;
|
||||
hotplug_arg arg;
|
||||
int sock_fd;
|
||||
/* Initlize the netlink socket */
|
||||
sock_fd=netlink_init();
|
||||
if (sock_fd == -1) {
|
||||
fprintf(stderr, "Unable to Intitlize netlink socket.\n");
|
||||
exit(1);
|
||||
}
|
||||
/* Bind the netlink socket */
|
||||
sock_fd=netlink_bind(sock_fd);
|
||||
if (sock_fd == -1) {
|
||||
fprintf(stderr, "Unable to Listen to netlink socket.\n");
|
||||
exit(1);
|
||||
}
|
||||
/* destination address to listen to */
|
||||
nlh = (struct nlmsghdr *)malloc(NLMSG_SPACE(MAX_PAYLOAD));
|
||||
memset(nlh, 0, NLMSG_SPACE(MAX_PAYLOAD));
|
||||
nlh->nlmsg_len = NLMSG_SPACE(MAX_PAYLOAD);
|
||||
nlh->nlmsg_pid = getpid();
|
||||
nlh->nlmsg_flags = 0;
|
||||
|
||||
/* Fill the netlink message header */
|
||||
iov.iov_base = (void *)nlh;
|
||||
iov.iov_len = nlh->nlmsg_len;
|
||||
msg.msg_name = (void *)&dest_addr;
|
||||
msg.msg_namelen = sizeof(dest_addr);
|
||||
msg.msg_iov = &iov;
|
||||
msg.msg_iovlen = 1;
|
||||
|
||||
|
||||
/* Read message from kernel */
|
||||
while(1){
|
||||
recvmsg(sock_fd, &msg, 0);
|
||||
switch (nlh->nlmsg_type)
|
||||
{
|
||||
case MSG_NETLINK_BRCM_WAKEUP_MONITOR_TASK:
|
||||
case MSG_NETLINK_BRCM_LINK_STATUS_CHANGED:
|
||||
/*process the message */
|
||||
fprintf(stderr, "No Handle\n");
|
||||
break;
|
||||
case MSG_NETLINK_BRCM_LINK_HOTPLUG:
|
||||
arg=createargumetstruct((char *)NLMSG_DATA(nlh));
|
||||
if(hotplug_call(arg)){
|
||||
fprintf(stderr, "Unable to call hotplug.\n");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Unknown type\n");
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
close(sock_fd);
|
||||
return 0;
|
||||
|
||||
}
|
||||
28
bcmhotproxy/src/bcmhotproxy.h
Normal file
28
bcmhotproxy/src/bcmhotproxy.h
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#ifndef BCMHOTPROXY_H
|
||||
#define BCMHOTPROXY_H 1
|
||||
#include <sys/socket.h>
|
||||
#include <linux/netlink.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <syslog.h>
|
||||
#define MSG_NETLINK_BRCM_WAKEUP_MONITOR_TASK 0X1000
|
||||
|
||||
#define MSG_NETLINK_BRCM_LINK_STATUS_CHANGED 0X2000
|
||||
|
||||
#define MSG_NETLINK_BRCM_LINK_HOTPLUG 0X3000
|
||||
#define MAX_PAYLOAD 1024 /* maximum payload size*/
|
||||
#ifndef NETLINK_BRCM_MONITOR
|
||||
#define NETLINK_BRCM_MONITOR 25
|
||||
#endif
|
||||
typedef struct hotplug_arg hotplug_arg;
|
||||
|
||||
struct hotplug_arg
|
||||
{
|
||||
char action[20];
|
||||
char inteface[20];
|
||||
char subsystem[20];
|
||||
|
||||
};
|
||||
#endif
|
||||
153
bcmhotproxy/src/brcmdaemon.c
Normal file
153
bcmhotproxy/src/brcmdaemon.c
Normal file
|
|
@ -0,0 +1,153 @@
|
|||
#include "brcmdaemon.h"
|
||||
|
||||
/**************************************************************************
|
||||
Function: Print Usage
|
||||
|
||||
Description:
|
||||
Output the command-line options for this daemon.
|
||||
|
||||
Params:
|
||||
@argc - Standard argument count
|
||||
@argv - Standard argument array
|
||||
|
||||
Returns:
|
||||
returns void always
|
||||
**************************************************************************/
|
||||
void PrintUsage(int argc, char *argv[]) {
|
||||
if (argc >=1) {
|
||||
printf("Usage: %s -h -n\n", argv[0]);
|
||||
printf(" Options: \n");
|
||||
printf(" -ntDon't fork off as a daemon.\n");
|
||||
printf(" -htShow this help screen.\n");
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
Function: signal_handler
|
||||
|
||||
Description:
|
||||
This function handles select signals that the daemon may
|
||||
receive. This gives the daemon a chance to properly shut
|
||||
down in emergency situations. This function is installed
|
||||
as a signal handler in the 'main()' function.
|
||||
|
||||
Params:
|
||||
@sig - The signal received
|
||||
|
||||
Returns:
|
||||
returns void always
|
||||
**************************************************************************/
|
||||
void signal_handler(int sig) {
|
||||
|
||||
switch(sig) {
|
||||
case SIGHUP:
|
||||
syslog(LOG_WARNING, "Received SIGHUP signal.");
|
||||
break;
|
||||
case SIGTERM:
|
||||
syslog(LOG_WARNING, "Received SIGTERM signal.");
|
||||
break;
|
||||
default:
|
||||
syslog(LOG_WARNING, "Unhandled signal (%d) %s", strsignal(sig));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
Function: main
|
||||
|
||||
Description:
|
||||
The c standard 'main' entry point function.
|
||||
|
||||
Params:
|
||||
@argc - count of command line arguments given on command line
|
||||
@argv - array of arguments given on command line
|
||||
|
||||
Returns:
|
||||
returns integer which is passed back to the parent process
|
||||
**************************************************************************/
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
#if defined(DEBUG)
|
||||
int daemonize = 0;
|
||||
#else
|
||||
int daemonize = 1;
|
||||
#endif
|
||||
|
||||
// Setup signal handling before we start
|
||||
signal(SIGHUP, signal_handler);
|
||||
signal(SIGTERM, signal_handler);
|
||||
signal(SIGINT, signal_handler);
|
||||
signal(SIGQUIT, signal_handler);
|
||||
|
||||
int c;
|
||||
while( (c = getopt(argc, argv, "nh|help")) != -1) {
|
||||
switch(c){
|
||||
case 'h':
|
||||
PrintUsage(argc, argv);
|
||||
exit(0);
|
||||
break;
|
||||
case 'n':
|
||||
daemonize = 0;
|
||||
break;
|
||||
default:
|
||||
PrintUsage(argc, argv);
|
||||
exit(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
syslog(LOG_INFO, "%s daemon starting up", DAEMON_NAME);
|
||||
|
||||
// Setup syslog logging - see SETLOGMASK(3)
|
||||
#if defined(DEBUG)
|
||||
setlogmask(LOG_UPTO(LOG_DEBUG));
|
||||
openlog(DAEMON_NAME, LOG_CONS | LOG_NDELAY | LOG_PERROR | LOG_PID, LOG_USER);
|
||||
#else
|
||||
setlogmask(LOG_UPTO(LOG_INFO));
|
||||
openlog(DAEMON_NAME, LOG_CONS, LOG_USER);
|
||||
#endif
|
||||
|
||||
/* Our process ID and Session ID */
|
||||
pid_t pid, sid;
|
||||
|
||||
if (daemonize) {
|
||||
syslog(LOG_INFO, "starting the daemonizing process");
|
||||
|
||||
/* Fork off the parent process */
|
||||
pid = fork();
|
||||
if (pid < 0) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
/* If we got a good PID, then
|
||||
we can exit the parent process. */
|
||||
if (pid > 0) {
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
/* Change the file mode mask */
|
||||
umask(0);
|
||||
|
||||
/* Create a new SID for the child process */
|
||||
sid = setsid();
|
||||
if (sid < 0) {
|
||||
/* Log the failure */
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Change the current working directory */
|
||||
if ((chdir("/")) < 0) {
|
||||
/* Log the failure */
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Close out the standard file descriptors */
|
||||
close(STDIN_FILENO);
|
||||
close(STDOUT_FILENO);
|
||||
close(STDERR_FILENO);
|
||||
}
|
||||
|
||||
dispatcher();
|
||||
syslog(LOG_INFO, "%s daemon exiting", DAEMON_NAME);
|
||||
exit(0);
|
||||
}
|
||||
17
bcmhotproxy/src/brcmdaemon.h
Normal file
17
bcmhotproxy/src/brcmdaemon.h
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#ifndef BRCMDAEMON_H
|
||||
#define BRCMDAEMON_H 1
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <syslog.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <signal.h>
|
||||
|
||||
#define DAEMON_NAME "brcmnetlink"
|
||||
#define PID_FILE "/var/run/brcmnetlink.pid"
|
||||
#endif
|
||||
86
bcmkernel/Config.in
Normal file
86
bcmkernel/Config.in
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
menu "Profile and CFE"
|
||||
depends on PACKAGE_bcmkernel
|
||||
|
||||
choice
|
||||
prompt "Broadcom SDK version"
|
||||
default BRCM_SDK_VER_416030
|
||||
help
|
||||
Version of the Broadcom SDK to use.
|
||||
|
||||
config BRCM_SDK_VER_414040
|
||||
bool
|
||||
prompt "bcmkernel-4.14L.04"
|
||||
|
||||
config BRCM_SDK_VER_416021
|
||||
bool
|
||||
prompt "bcmkernel-4.16L.02A"
|
||||
|
||||
config BRCM_SDK_VER_416030
|
||||
bool
|
||||
prompt "bcmkernel-4.16L.03"
|
||||
|
||||
endchoice
|
||||
|
||||
config BCM_KERNEL_PROFILE
|
||||
string
|
||||
prompt "Broadcom kernel profile"
|
||||
default "96368GWV"
|
||||
help
|
||||
Profile to build the broadcom software with, 96368GWV, 963268GWV, 96362GWV, 96816GWV, 96816OV
|
||||
|
||||
config BCM_CFE_PASSWORD
|
||||
string
|
||||
prompt "Broadcom cfe password"
|
||||
default ""
|
||||
|
||||
config BCM_CHIP_ID
|
||||
string
|
||||
prompt "Broadcom chip id"
|
||||
default "6368"
|
||||
help
|
||||
Chip id to build the cfe with, 6328|6362|6368|6816|63268
|
||||
|
||||
config BCM_BLNAND
|
||||
string
|
||||
prompt "Broadcom boot loader nand"
|
||||
default "0"
|
||||
help
|
||||
Set this to 1 to build a boot loader for nand flash
|
||||
|
||||
config BCM_ENDPOINT_MODULE
|
||||
bool
|
||||
prompt "Broadcom endpoint voice FXS support"
|
||||
default y
|
||||
help
|
||||
Set this to include the endpoint module in image
|
||||
|
||||
config BCM_USBSOUND_MODULES
|
||||
bool
|
||||
prompt "Broadcom USB audio support"
|
||||
default n
|
||||
help
|
||||
Set this to include sound support modules in image
|
||||
|
||||
|
||||
config BCM_I2C
|
||||
bool
|
||||
prompt "Broadcom I2C support"
|
||||
default n
|
||||
help
|
||||
Set this to include the i2c modules in image
|
||||
|
||||
config BCM_BLUETOOTH
|
||||
bool
|
||||
prompt "Broadcom Bluetooth support"
|
||||
default n
|
||||
help
|
||||
Set this to include the Bluetooth modules in image
|
||||
|
||||
|
||||
config SECURE_BOOT_CFE
|
||||
prompt "Secure boot CFE"
|
||||
bool
|
||||
|
||||
|
||||
endmenu
|
||||
|
||||
280
bcmkernel/Makefile
Normal file
280
bcmkernel/Makefile
Normal file
|
|
@ -0,0 +1,280 @@
|
|||
#
|
||||
# Copyright (C) 2006-2008 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:=bcmkernel-3.4
|
||||
PKG_VERSION:=4.16
|
||||
PKG_RELEASE:=4
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=git@iopsys.inteno.se:bcmkernel-4.16L.02A
|
||||
PKG_SOURCE_PROTO:=git
|
||||
|
||||
PKG_SOURCE_VERSION:=23626cbda0195c1e20e68753137c8f3ed8dc030c
|
||||
|
||||
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(INCLUDE_DIR)/image.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
export CONFIG_BCM_CHIP_ID
|
||||
export CONFIG_BCM_KERNEL_PROFILE
|
||||
export CONFIG_SECURE_BOOT_CFE
|
||||
|
||||
|
||||
BCM_BS_PROFILE = $(shell echo $(CONFIG_BCM_KERNEL_PROFILE) | sed s/\"//g)
|
||||
|
||||
BCM_KERNEL_VERSION:=3.4.11-rt19
|
||||
BCM_SDK_VERSION:=bcm963xx
|
||||
RSTRIP:=true
|
||||
|
||||
define Package/bcmkernel
|
||||
SECTION:=net
|
||||
CATEGORY:=Base system
|
||||
TITLE:=Broadcom sdk 3.4 kernel
|
||||
URL:=
|
||||
MENU:=1
|
||||
endef
|
||||
|
||||
define Package/bcmkernel/description
|
||||
Broadcom kernel and userspace, compiled with the broadcom supplied tool-chain.
|
||||
endef
|
||||
|
||||
define Package/bcmkernel/config
|
||||
source "$(SOURCE)/Config.in"
|
||||
endef
|
||||
|
||||
|
||||
define Package/bcmkernel/removevoice
|
||||
touch $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra/endpointdd.ko
|
||||
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra/endpointdd.ko
|
||||
endef
|
||||
|
||||
ifeq ($(CONFIG_BCM_ENDPOINT_MODULE),y)
|
||||
define Package/bcmkernel/removevoice
|
||||
echo not removing $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra/endpointdd.ko
|
||||
endef
|
||||
endif
|
||||
|
||||
define Package/bcmkernel/removesound
|
||||
touch $(1)/lib/modules/$(BCM_KERNEL_VERSION)/snd
|
||||
touch $(1)/lib/modules/$(BCM_KERNEL_VERSION)/soundcore.ko
|
||||
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/snd*
|
||||
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/soundcore.ko
|
||||
endef
|
||||
|
||||
ifeq ($(BCM_USBSOUND_MODULES),y)
|
||||
define Package/bcmkernel/removesound
|
||||
echo not removing $(1)/lib/modules/$(BCM_KERNEL_VERSION)/snd*
|
||||
endef
|
||||
endif
|
||||
|
||||
|
||||
define Package/bcmkernel/removei2c
|
||||
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/i2c*
|
||||
endef
|
||||
|
||||
ifeq ($(CONFIG_BCM_I2C),y)
|
||||
define Package/bcmkernel/removei2c
|
||||
echo not removing $(1)/lib/modules/$(BCM_KERNEL_VERSION)/i2c*
|
||||
endef
|
||||
endif
|
||||
|
||||
#define Package/bcmkernel/prepare
|
||||
#endif
|
||||
|
||||
define Package/bcmkernel/install
|
||||
$(INSTALL_DIR) $(1)/lib/bcm
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(INSTALL_DIR) $(1)/etc/adsl
|
||||
$(INSTALL_DIR) $(1)/etc/wlan
|
||||
$(INSTALL_DIR) $(1)/etc/cms_entity_info.d
|
||||
|
||||
|
||||
|
||||
# Install header files
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/broadcom/include/bcm963xx
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/endpt/inc
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/codec
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/casCtl/inc
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/LinuxUser
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/opensource/include/bcm963xx
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/shared/opensource/include/bcm963xx
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/userspace/private/apps/vodsl/voip/inc
|
||||
|
||||
|
||||
$(CP) -r $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/shared/opensource/include/bcm963xx/* $(STAGING_DIR)/usr/include/bcm963xx/shared/opensource/include/bcm963xx
|
||||
|
||||
$(CP) -r $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/bcmdrivers/opensource/include/bcm963xx/* $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/opensource/include/bcm963xx/
|
||||
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgTypes.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgTypes.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgCountryCfg.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgCountryCfg.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgCountryCfgCustom.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgCountryCfgCustom.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgLogCfgCustom.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgLogCfgCustom.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgLog.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgLog.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/countryArchive.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/countryArchive.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgCountry.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgCountry.h
|
||||
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/casCtl/inc/casCtl.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/casCtl/inc/casCtl.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/codec/codec.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/codec/codec.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/endpt/inc/endpt.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/endpt/inc/endpt.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/endpt/inc/vrgEndpt.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/endpt/inc/vrgEndpt.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/LinuxUser/bosTypesLinuxUser.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/LinuxUser/bosTypesLinuxUser.h
|
||||
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosMutex.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosMutex.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosSpinlock.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosSpinlock.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosMsgQ.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosMsgQ.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosCritSect.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosCritSect.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosTypes.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosTypes.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosTime.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosTime.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosSem.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosSem.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosCfgCustom.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosCfgCustom.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosIpAddr.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosIpAddr.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosTimer.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosTimer.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosError.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosError.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosLog.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosLog.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosSleep.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosSleep.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosMisc.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosMisc.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosCfg.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosCfg.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosEvent.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosEvent.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosTask.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosTask.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosUtil.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosUtil.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosInit.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosInit.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosSocket.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosSocket.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosFile.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosFile.h
|
||||
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_drivers/inc/xdrvSlic.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc/xdrvSlic.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_drivers/inc/xdrvApm.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc/xdrvApm.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_drivers/inc/xdrvCas.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc/xdrvCas.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_drivers/inc/xdrvTypes.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc/xdrvTypes.h
|
||||
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/bcmdrivers/broadcom/include/bcm963xx/endptvoicestats.h $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/broadcom/include/bcm963xx/endptvoicestats.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/bcmdrivers/broadcom/include/bcm963xx/endpointdrv.h $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/broadcom/include/bcm963xx/endpointdrv.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/userspace/private/apps/vodsl/voip/inc/tpProfiles.h $(STAGING_DIR)/usr/include/bcm963xx/userspace/private/apps/vodsl/voip/inc
|
||||
|
||||
|
||||
|
||||
###
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/bin/* $(1)/usr/sbin/
|
||||
|
||||
rm -f $(1)/usr/sbin/dhcp6c
|
||||
rm -f $(1)/usr/sbin/dhcp6s
|
||||
rm -f $(1)/usr/sbin/dhcpc
|
||||
rm -f $(1)/usr/sbin/dhcpd
|
||||
rm -f $(1)/usr/sbin/dnsproxy
|
||||
rm -f $(1)/usr/sbin/httpd
|
||||
rm -f $(1)/usr/sbin/openssl
|
||||
rm -f $(1)/usr/sbin/racoon
|
||||
rm -f $(1)/usr/sbin/ripd
|
||||
rm -f $(1)/usr/sbin/send_cms_msg
|
||||
rm -f $(1)/usr/sbin/sshd
|
||||
rm -f $(1)/usr/sbin/ssk
|
||||
rm -f $(1)/usr/sbin/telnetd
|
||||
rm -f $(1)/usr/sbin/tr64c
|
||||
rm -f $(1)/usr/sbin/tr69c
|
||||
rm -f $(1)/usr/sbin/ubi*
|
||||
rm -f $(1)/usr/sbin/udhcpd
|
||||
rm -f $(1)/usr/sbin/upnp
|
||||
rm -f $(1)/usr/sbin/upnpd
|
||||
rm -f $(1)/usr/sbin/vodsl
|
||||
rm -f $(1)/usr/sbin/wlmngr
|
||||
rm -f $(1)/usr/sbin/zebra
|
||||
|
||||
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/etc/cms_entity_info.d/eid_bcm_kthreads.txt $(1)/etc/cms_entity_info.d/
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/etc/cms_entity_info.d/symbol_table.txt $(1)/etc/cms_entity_info.d/
|
||||
|
||||
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/* $(1)/usr/lib/
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/gpl/* $(1)/usr/lib/
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/private/* $(1)/usr/lib/
|
||||
|
||||
mv $(1)/usr/lib/ld-uClibc.so.0 $(1)/lib/bcm/
|
||||
mv $(1)/usr/lib/libc.so.0 $(1)/lib/bcm/
|
||||
mv $(1)/usr/lib/libdl.so.0 $(1)/lib/bcm/
|
||||
mv $(1)/usr/lib/libgcc_s.so.1 $(1)/lib/bcm/
|
||||
mv $(1)/usr/lib/libpthread.so.0 $(1)/lib/bcm/
|
||||
|
||||
# rm -f $(1)/usr/lib/libcrypt.so.0
|
||||
rm -f $(1)/usr/lib/libm.so.0
|
||||
rm -f $(1)/usr/lib/libutil.so.0
|
||||
rm -f $(1)/usr/lib/libcms_boardctl.so
|
||||
rm -f $(1)/usr/lib/libcms_msg.so
|
||||
rm -f $(1)/usr/lib/libcms_util.so
|
||||
# rm -f $(1)/usr/lib/libcrypto.so.0.9.7
|
||||
# rm -f $(1)/usr/lib/libssl.so.0.9.7
|
||||
rm -f $(1)/usr/lib/libnvram.so
|
||||
|
||||
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/public/* $(1)/usr/lib/
|
||||
|
||||
rm -rf $(1)/usr/lib/modules
|
||||
rm -rf $(1)/usr/lib/private
|
||||
rm -rf $(1)/usr/lib/public
|
||||
rm -rf $(1)/usr/lib/gpl
|
||||
|
||||
|
||||
rm -rf $(1)/lib/modules/$(BCM_KERNEL_VERSION)/*
|
||||
mkdir -p $(1)/lib/
|
||||
mkdir -p $(1)/lib/modules/
|
||||
mkdir -p $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
|
||||
mkdir -p $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra
|
||||
|
||||
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/extra/* $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra/
|
||||
find $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/ -name *.ko -exec cp {} $(1)/lib/modules/$(BCM_KERNEL_VERSION)/ \;
|
||||
# cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/crypto/* $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
|
||||
# cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/drivers/scsi/* $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
|
||||
# cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/drivers/usb/serial/* $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
|
||||
# cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/drivers/usb/storage/* $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
|
||||
# cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/fs/cifs/* $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
|
||||
# cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/net/ipv4/*.ko $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
|
||||
# cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/net/dns_resolver/* $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
|
||||
# cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/net/ipv4/netfilter/* $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
|
||||
# cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/net/ipv6/netfilter/* $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
|
||||
# cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/net/netfilter/* $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
|
||||
# cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/drivers/char/hw_random/* $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
|
||||
# cp $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/drivers/i2c/i2c-core.ko $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
|
||||
# cp $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/drivers/i2c/i2c-dev.ko $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
|
||||
# cp $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/drivers/i2c/algos/i2c-algo-bit.ko $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
|
||||
# cp $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/drivers/i2c/busses/i2c-gpio.ko $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
|
||||
# cp $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/drivers/i2c/busses/i2c-gpio-custom.ko $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
|
||||
|
||||
touch $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/bcmdrivers/broadcom/char/adsl/impl1/adsl_phy.bin
|
||||
# cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/bcmdrivers/broadcom/char/adsl/impl1/adsl_phy.bin $(1)/etc/adsl/adsl_phy.bin
|
||||
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/etc/wlan/* $(1)/etc/wlan
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/etc/telephonyProfiles.d $(1)/etc/
|
||||
|
||||
# rm -rf $(1)/lib/modules/$(BCM_KERNEL_VERSION)/bcm_usb.ko
|
||||
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/kernel/linux-3.4rt/vmlinux $(KDIR)/vmlinux.bcm.elf
|
||||
$(KERNEL_CROSS)strip --remove-section=.note --remove-section=.comment $(KDIR)/vmlinux.bcm.elf
|
||||
$(KERNEL_CROSS)objcopy $(OBJCOPY_STRIP) -O binary $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/kernel/linux-3.4rt/vmlinux $(KDIR)/vmlinux.bcm
|
||||
|
||||
# bootloader nor
|
||||
# cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/cfe/build/broadcom/bcm63xx_rom/bcm9$(CONFIG_BCM_CHIP_ID)_cfe.w $(KDIR)/bcm_bootloader_cfe.w
|
||||
# ram part of the bootloader for nand boot
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/cfe/build/broadcom/bcm63xx_ram/cfe$(CONFIG_BCM_CHIP_ID).bin $(KDIR)/cferam.000
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/cfe/build/broadcom/bcm63xx_rom/cfe$(CONFIG_BCM_CHIP_ID)_nand.v $(KDIR)/cfe$(CONFIG_BCM_CHIP_ID)_nand.v
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/cfe/ $(KDIR)/cfe
|
||||
# dd if=$(KDIR)/vmlinux.bcm.elf of=$(KDIR)/vmlinux.bcm bs=4096 count=1
|
||||
# $(KERNEL_CROSS)objcopy $(OBJCOPY_STRIP) -S $(LINUX_DIR)/vmlinux $(KERNEL_BUILD_DIR)/vmlinux.elf
|
||||
|
||||
$(call Package/bcmkernel/removevoice,$(1))
|
||||
$(call Package/bcmkernel/removesound,$(1))
|
||||
# $(call Package/bcmkernel/removei2c,$(1))
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,bcmkernel))
|
||||
38
bcmopen/Config.in
Normal file
38
bcmopen/Config.in
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
menu "Profile and CFE"
|
||||
depends on PACKAGE_bcmopen
|
||||
|
||||
config BCM_KERNEL_PROFILE
|
||||
string
|
||||
prompt "Broadcom kernel profile"
|
||||
default "96368GWV"
|
||||
help
|
||||
Profile to build the broadcom software with, 96368GWV, 963268GWV, 96362GWV, 96816GWV, 96816OV
|
||||
|
||||
config BCM_CHIP_ID
|
||||
string
|
||||
prompt "Broadcom chip id"
|
||||
default "6368"
|
||||
help
|
||||
Chip id to build the cfe with, 6328|6362|6368|6816|63268
|
||||
|
||||
config BCM_BLNAND
|
||||
string
|
||||
prompt "Broadcom boot loader nand"
|
||||
default "0"
|
||||
help
|
||||
Set this to 1 to build a boot loader for nand flash
|
||||
|
||||
config BCM_ENDPOINT_MODULE
|
||||
bool
|
||||
prompt "Broadcom endpoint voice FXS support"
|
||||
default y
|
||||
help
|
||||
Set this to include the endpoint module in image
|
||||
|
||||
config SECURE_BOOT_CFE
|
||||
prompt "Secure boot CFE"
|
||||
bool
|
||||
|
||||
|
||||
endmenu
|
||||
|
||||
263
bcmopen/Makefile
Normal file
263
bcmopen/Makefile
Normal file
|
|
@ -0,0 +1,263 @@
|
|||
#
|
||||
# Copyright (C) 2006-2008 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:=bcmopen
|
||||
PKG_VERSION:=consumer
|
||||
PKG_RELEASE:=1
|
||||
|
||||
TARGET_VERSION=$(shell echo $(CONFIG_TARGET_VERSION) | sed s/\"//g)
|
||||
TARGET_IBOARDID=$(shell echo $(CONFIG_TARGET_IBOARDID) | sed s/\"//g)
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).$(TARGET_VERSION).$(TARGET_IBOARDID).tar.gz
|
||||
PKG_SOURCE_URL:=http://ihgsp.inteno.se/ihgsp/consumer/
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(INCLUDE_DIR)/image.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
export CONFIG_BCM_CHIP_ID
|
||||
export CONFIG_BCM_KERNEL_PROFILE
|
||||
export CONFIG_SECURE_BOOT_CFE
|
||||
|
||||
|
||||
BCM_BS_PROFILE = $(shell echo $(CONFIG_BCM_KERNEL_PROFILE) | sed s/\"//g)
|
||||
|
||||
BCM_KERNEL_VERSION:=3.4.11-rt19
|
||||
BCM_SDK_VERSION:=bcm963xx
|
||||
RSTRIP:=true
|
||||
|
||||
define Package/bcmopen
|
||||
SECTION:=net
|
||||
CATEGORY:=Base system
|
||||
TITLE:=Broadcom sdk 3.4 kernel
|
||||
URL:=
|
||||
MENU:=1
|
||||
endef
|
||||
|
||||
define Package/bcmopen/description
|
||||
Broadcom kernel and userspace, compiled with the broadcom supplied tool-chain.
|
||||
endef
|
||||
|
||||
define Package/bcmopen/config
|
||||
source "$(SOURCE)/Config.in"
|
||||
endef
|
||||
|
||||
|
||||
define Package/bcmopen/removevoice
|
||||
touch $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra/endpointdd.ko
|
||||
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra/endpointdd.ko
|
||||
endef
|
||||
|
||||
ifeq ($(CONFIG_BCM_ENDPOINT_MODULE),y)
|
||||
define Package/bcmopen/removevoice
|
||||
echo not removing $(1)/lib/modules/$(BCM_KERNEL_VERSION)/endpointdd.ko
|
||||
endef
|
||||
endif
|
||||
|
||||
|
||||
define Package/bcmopen/removei2c
|
||||
rm $(1)/lib/modules/$(BCM_KERNEL_VERSION)/i2c*
|
||||
endef
|
||||
|
||||
ifeq ($(CONFIG_BCM_I2C),y)
|
||||
define Package/bcmopen/removei2c
|
||||
echo not removing $(1)/lib/modules/$(BCM_KERNEL_VERSION)/i2c*
|
||||
endef
|
||||
endif
|
||||
|
||||
#define Package/bcmkernel/prepare
|
||||
#endif
|
||||
|
||||
define Package/bcmopen/install
|
||||
$(INSTALL_DIR) $(1)/lib/bcm
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(INSTALL_DIR) $(1)/etc/adsl
|
||||
$(INSTALL_DIR) $(1)/etc/wlan
|
||||
$(INSTALL_DIR) $(1)/etc/cms_entity_info.d
|
||||
|
||||
|
||||
|
||||
# Install header files
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/broadcom/include/bcm963xx
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/endpt/inc
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/codec
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/casCtl/inc
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/LinuxUser
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/opensource/include/bcm963xx
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/bcm963xx/shared/opensource/include/bcm963xx
|
||||
|
||||
|
||||
$(CP) -r $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/shared/opensource/include/bcm963xx/* $(STAGING_DIR)/usr/include/bcm963xx/shared/opensource/include/bcm963xx
|
||||
|
||||
$(CP) -r $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/bcmdrivers/opensource/include/bcm963xx/* $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/opensource/include/bcm963xx/
|
||||
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgTypes.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgTypes.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgCountryCfg.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgCountryCfg.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgCountryCfgCustom.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgCountryCfgCustom.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgLogCfgCustom.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgLogCfgCustom.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgLog.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgLog.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/countryArchive.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/countryArchive.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/inc/vrgCountry.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc/vrgCountry.h
|
||||
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/casCtl/inc/casCtl.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/casCtl/inc/casCtl.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/codec/codec.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/codec/codec.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/endpt/inc/endpt.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/endpt/inc/endpt.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/voice_res_gw/endpt/inc/vrgEndpt.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/endpt/inc/vrgEndpt.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/LinuxUser/bosTypesLinuxUser.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/LinuxUser/bosTypesLinuxUser.h
|
||||
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosMutex.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosMutex.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosSpinlock.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosSpinlock.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosMsgQ.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosMsgQ.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosCritSect.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosCritSect.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosTypes.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosTypes.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosTime.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosTime.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosSem.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosSem.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosCfgCustom.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosCfgCustom.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosIpAddr.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosIpAddr.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosTimer.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosTimer.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosError.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosError.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosLog.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosLog.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosSleep.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosSleep.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosMisc.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosMisc.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosCfg.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosCfg.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosEvent.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosEvent.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosTask.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosTask.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosUtil.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosUtil.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosInit.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosInit.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosSocket.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosSocket.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_common/bos/publicInc/bosFile.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/bosFile.h
|
||||
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_drivers/inc/xdrvSlic.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc/xdrvSlic.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_drivers/inc/xdrvApm.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc/xdrvApm.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_drivers/inc/xdrvCas.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc/xdrvCas.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/xChange/dslx_common/xchg_drivers/inc/xdrvTypes.h $(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc/xdrvTypes.h
|
||||
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/bcmdrivers/broadcom/include/bcm963xx/endptvoicestats.h $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/broadcom/include/bcm963xx/endptvoicestats.h
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/bcmdrivers/broadcom/include/bcm963xx/endpointdrv.h $(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/broadcom/include/bcm963xx/endpointdrv.h
|
||||
|
||||
# create symlink to kernel build directory
|
||||
rm -f $(BUILD_DIR)/bcmkernel
|
||||
ln -sfn $(PKG_SOURCE_SUBDIR) $(BUILD_DIR)/bcmkernel
|
||||
|
||||
###
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/bin/* $(1)/usr/sbin/
|
||||
|
||||
rm -f $(1)/usr/sbin/dhcp6c
|
||||
rm -f $(1)/usr/sbin/dhcp6s
|
||||
rm -f $(1)/usr/sbin/dhcpc
|
||||
rm -f $(1)/usr/sbin/dhcpd
|
||||
rm -f $(1)/usr/sbin/dnsproxy
|
||||
rm -f $(1)/usr/sbin/httpd
|
||||
rm -f $(1)/usr/sbin/openssl
|
||||
rm -f $(1)/usr/sbin/racoon
|
||||
rm -f $(1)/usr/sbin/ripd
|
||||
rm -f $(1)/usr/sbin/send_cms_msg
|
||||
rm -f $(1)/usr/sbin/sshd
|
||||
rm -f $(1)/usr/sbin/ssk
|
||||
rm -f $(1)/usr/sbin/telnetd
|
||||
rm -f $(1)/usr/sbin/tr64c
|
||||
rm -f $(1)/usr/sbin/tr69c
|
||||
rm -f $(1)/usr/sbin/ubi*
|
||||
rm -f $(1)/usr/sbin/udhcpd
|
||||
rm -f $(1)/usr/sbin/upnp
|
||||
rm -f $(1)/usr/sbin/upnpd
|
||||
rm -f $(1)/usr/sbin/vodsl
|
||||
rm -f $(1)/usr/sbin/wlmngr
|
||||
rm -f $(1)/usr/sbin/zebra
|
||||
|
||||
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/etc/cms_entity_info.d/eid_bcm_kthreads.txt $(1)/etc/cms_entity_info.d/
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/etc/cms_entity_info.d/symbol_table.txt $(1)/etc/cms_entity_info.d/
|
||||
|
||||
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/* $(1)/usr/lib/
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/gpl/* $(1)/usr/lib/
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/private/* $(1)/usr/lib/
|
||||
|
||||
mv $(1)/usr/lib/ld-uClibc.so.0 $(1)/lib/bcm/
|
||||
mv $(1)/usr/lib/libc.so.0 $(1)/lib/bcm/
|
||||
mv $(1)/usr/lib/libdl.so.0 $(1)/lib/bcm/
|
||||
mv $(1)/usr/lib/libgcc_s.so.1 $(1)/lib/bcm/
|
||||
mv $(1)/usr/lib/libpthread.so.0 $(1)/lib/bcm/
|
||||
|
||||
rm -f $(1)/usr/lib/libcrypt.so.0
|
||||
rm -f $(1)/usr/lib/libm.so.0
|
||||
rm -f $(1)/usr/lib/libutil.so.0
|
||||
rm -f $(1)/usr/lib/libcms_boardctl.so
|
||||
rm -f $(1)/usr/lib/libcms_msg.so
|
||||
rm -f $(1)/usr/lib/libcms_util.so
|
||||
rm -f $(1)/usr/lib/libcrypto.so.0.9.7
|
||||
rm -f $(1)/usr/lib/libssl.so.0.9.7
|
||||
rm -f $(1)/usr/lib/libnvram.so
|
||||
|
||||
|
||||
$(CP) $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/public/* $(1)/usr/lib/
|
||||
|
||||
rm -rf $(1)/usr/lib/modules
|
||||
rm -rf $(1)/usr/lib/private
|
||||
rm -rf $(1)/usr/lib/public
|
||||
rm -rf $(1)/usr/lib/gpl
|
||||
|
||||
|
||||
rm -rf $(1)/lib/modules/$(BCM_KERNEL_VERSION)/*
|
||||
mkdir -p $(1)/lib/
|
||||
mkdir -p $(1)/lib/modules/
|
||||
mkdir -p $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
|
||||
mkdir -p $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra
|
||||
|
||||
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/extra/* $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra/
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/crypto/* $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/drivers/scsi/* $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/drivers/usb/serial/* $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/drivers/usb/storage/* $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/fs/cifs/* $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/net/ipv4/*.ko $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/net/dns_resolver/* $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/net/ipv4/netfilter/* $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/net/ipv6/netfilter/* $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/net/netfilter/* $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/drivers/char/hw_random/* $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
|
||||
cp $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/drivers/i2c/i2c-core.ko $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
|
||||
cp $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/drivers/i2c/i2c-dev.ko $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
|
||||
cp $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/drivers/i2c/algos/i2c-algo-bit.ko $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
|
||||
cp $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/drivers/i2c/busses/i2c-gpio.ko $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
|
||||
cp $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/lib/modules/$(BCM_KERNEL_VERSION)/kernel/drivers/i2c/busses/i2c-gpio-custom.ko $(1)/lib/modules/$(BCM_KERNEL_VERSION)/
|
||||
|
||||
touch $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/bcmdrivers/broadcom/char/adsl/impl1/adsl_phy.bin
|
||||
# cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/bcmdrivers/broadcom/char/adsl/impl1/adsl_phy.bin $(1)/etc/adsl/adsl_phy.bin
|
||||
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/etc/wlan/*_map.bin $(1)/etc/wlan
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/$(BCM_BS_PROFILE)/fs/etc/telephonyProfiles.d $(1)/etc/
|
||||
|
||||
# rm -rf $(1)/lib/modules/$(BCM_KERNEL_VERSION)/bcm_usb.ko
|
||||
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/kernel/linux-3.4rt/vmlinux $(KDIR)/vmlinux.bcm.elf
|
||||
$(KERNEL_CROSS)strip --remove-section=.note --remove-section=.comment $(KDIR)/vmlinux.bcm.elf
|
||||
$(KERNEL_CROSS)objcopy $(OBJCOPY_STRIP) -O binary $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/kernel/linux-3.4rt/vmlinux $(KDIR)/vmlinux.bcm
|
||||
|
||||
# bootloader nor
|
||||
# cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/cfe/build/broadcom/bcm63xx_rom/bcm9$(CONFIG_BCM_CHIP_ID)_cfe.w $(KDIR)/bcm_bootloader_cfe.w
|
||||
# ram part of the bootloader for nand boot
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/cfe/build/broadcom/bcm63xx_ram/cfe$(CONFIG_BCM_CHIP_ID).bin $(KDIR)/cferam.000
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/cfe/build/broadcom/bcm63xx_rom/cfe$(CONFIG_BCM_CHIP_ID)_nand.v $(KDIR)/cfe$(CONFIG_BCM_CHIP_ID)_nand.v
|
||||
cp -R $(PKG_BUILD_DIR)/$(BCM_SDK_VERSION)/targets/cfe/ $(KDIR)/cfe
|
||||
# dd if=$(KDIR)/vmlinux.bcm.elf of=$(KDIR)/vmlinux.bcm bs=4096 count=1
|
||||
# $(KERNEL_CROSS)objcopy $(OBJCOPY_STRIP) -S $(LINUX_DIR)/vmlinux $(KERNEL_BUILD_DIR)/vmlinux.elf
|
||||
|
||||
$(call Package/bcmopen/removevoice,$(1))
|
||||
$(call Package/bcmopen/removei2c,$(1))
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,bcmopen))
|
||||
17
block-mount/Config.in
Normal file
17
block-mount/Config.in
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#
|
||||
# Copyright (C) 2010 Vertical Communications
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
config EXTROOT_SETTLETIME
|
||||
int
|
||||
prompt "Settle time for root block device (s)" if PACKAGE_block-mount
|
||||
default 20
|
||||
help
|
||||
This is the amount of time, in seconds, to wait for the block device
|
||||
the root filesystem is on to become available, after the kernel that
|
||||
modules for the rootfs and device are loaded.
|
||||
|
||||
|
||||
70
block-mount/Makefile
Normal file
70
block-mount/Makefile
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
#
|
||||
# Copyright (C) 2006-2012 OpenWrt.org
|
||||
# Copyright (C) 2010 Vertical Communications
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=block-mount
|
||||
PKG_VERSION:=0.2.0
|
||||
PKG_RELEASE:=9
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/block-mount/Default
|
||||
SECTION:=base
|
||||
CATEGORY:=Base system
|
||||
endef
|
||||
|
||||
define Package/block-mount
|
||||
$(call Package/block-mount/Default)
|
||||
TITLE:=Block device mounting and checking
|
||||
DEPENDS:= +blkid +swap-utils
|
||||
MENU:=1
|
||||
endef
|
||||
|
||||
define Package/block-mount/description
|
||||
Scripts used to mount and check block devices (filesystems and swap), as well
|
||||
as hotplug scripts to automount and check block devices when hotplug event (e.g.
|
||||
from plugging in a device) occurs.
|
||||
Also includes preinit scripts for mounting a block device as the root filesystem.
|
||||
This allows one to have the root filesystem on devices other than the built in flash
|
||||
device.
|
||||
endef
|
||||
|
||||
define Package/block-mount/config
|
||||
source "$(SOURCE)/Config.in"
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
define Package/block-mount/conffiles
|
||||
/etc/config/fstab
|
||||
endef
|
||||
|
||||
define Package/block-mount/install
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/fstab.init $(1)/etc/init.d/fstab
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_DATA) ./files/fstab.config $(1)/etc/config/fstab
|
||||
$(INSTALL_DIR) $(1)/lib/functions/fsck
|
||||
$(INSTALL_DATA) ./files/mount.sh $(1)/lib/functions/
|
||||
$(INSTALL_DATA) ./files/fsck.sh $(1)/lib/functions/
|
||||
$(INSTALL_DATA) ./files/block.sh $(1)/lib/functions/
|
||||
$(INSTALL_DIR) $(1)/etc/hotplug.d/block
|
||||
$(INSTALL_DATA) ./files/10-swap $(1)/etc/hotplug.d/block/
|
||||
$(INSTALL_DATA) ./files/20-fsck $(1)/etc/hotplug.d/block/
|
||||
$(INSTALL_DATA) ./files/40-mount $(1)/etc/hotplug.d/block/
|
||||
$(INSTALL_DATA) ./files/extmount.sh $(1)/lib/functions/
|
||||
$(INSTALL_DIR) $(1)/lib/preinit
|
||||
$(INSTALL_DATA) ./files/50_determine_usb_root $(1)/lib/preinit/
|
||||
$(INSTALL_DATA) ./files/55_determine_extroot_sysupgrade $(1)/lib/preinit/
|
||||
$(INSTALL_DATA) ./files/60_pivot_usb_root $(1)/lib/preinit/
|
||||
echo "extroot_settle_time=\"$(CONFIG_EXTROOT_SETTLETIME)\"" >$(1)/lib/preinit/00_extroot.conf
|
||||
$(INSTALL_DIR) $(1)/overlay
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,block-mount))
|
||||
78
block-mount/files/10-swap
Normal file
78
block-mount/files/10-swap
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
#!/bin/sh
|
||||
# Copyright (C) 2009-2010 OpenWrt.org
|
||||
# Copyright (C) 2010 Vertical Communications
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
. /lib/functions/block.sh
|
||||
|
||||
blkdev=`dirname $DEVPATH`
|
||||
|
||||
if [ `basename $blkdev` != "block" ]; then
|
||||
|
||||
device=`basename $DEVPATH`
|
||||
|
||||
|
||||
case "$ACTION" in
|
||||
add)
|
||||
local autoswap_from_fstab
|
||||
local automount_from_fstab
|
||||
local from_fstab
|
||||
local anon_mount
|
||||
local anon_swap
|
||||
local anon_fsck
|
||||
local mds_mount_device
|
||||
local sds_swap_device
|
||||
local sds_swap_enabled
|
||||
local use_device
|
||||
local do_swap=0
|
||||
|
||||
mount_dev_section_cb() {
|
||||
mds_mount_device="$3"
|
||||
}
|
||||
|
||||
swap_dev_section_cb() {
|
||||
sds_swap_device="$2"
|
||||
sds_swap_enabled="$3"
|
||||
return 0
|
||||
}
|
||||
|
||||
config_get_automount
|
||||
automount_from_fstab="$from_fstab"
|
||||
|
||||
[ "$automount_from_fstab" -eq 1 ] && {
|
||||
config_get_mount_section_by_device "/dev/$device"
|
||||
}
|
||||
|
||||
# skip trying swap if this device is defined as a mount point
|
||||
[ -z "$mds_mount_device" ] && {
|
||||
config_get_autoswap
|
||||
autoswap_from_fstab="$from_fstab"
|
||||
|
||||
[ "$autoswap_from_fstab" -eq 1 ] && {
|
||||
config_get_swap_section_by_device "/dev/$device"
|
||||
use_device="$sds_swap_device"
|
||||
do_swap="$sds_swap_enabled"
|
||||
}
|
||||
|
||||
[ -z "$use_device" ] && [ "$anon_swap" -eq 1 ] && {
|
||||
use_device="/dev/$device" && do_swap=1
|
||||
}
|
||||
}
|
||||
|
||||
[ -n "$use_device" ] && [ "$do_swap" -eq 1 ] && {
|
||||
grep -q "$use_device" /proc/swaps || grep -q "$use_device" /proc/mounts || {
|
||||
swapon "$use_device"
|
||||
}
|
||||
}
|
||||
reset_dev_section_cb
|
||||
;;
|
||||
remove)
|
||||
grep -q "/dev/$device" /proc/swaps && {
|
||||
swapoff "/dev/$device"
|
||||
}
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
83
block-mount/files/20-fsck
Normal file
83
block-mount/files/20-fsck
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
#!/bin/sh
|
||||
# Copyright (C) 2009-2010 OpenWrt.org
|
||||
# Copyright (C) 2010 Vertical Communications
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
. /lib/functions/block.sh
|
||||
. /lib/functions/fsck.sh
|
||||
|
||||
blkdev=`dirname $DEVPATH`
|
||||
|
||||
if [ `basename $blkdev` != "block" ]; then
|
||||
|
||||
device=`basename $DEVPATH`
|
||||
|
||||
case "$ACTION" in
|
||||
add)
|
||||
local from_fstab
|
||||
local anon_mount
|
||||
local anon_swap
|
||||
local anon_fsck
|
||||
local mds_mount_target
|
||||
local mds_mount_device
|
||||
local mds_mount_fstype
|
||||
local mds_mount_enabled_fsck
|
||||
local sds_swap_device
|
||||
local use_device
|
||||
local do_fsck=0
|
||||
local fsck_type
|
||||
|
||||
local autoswap_from_fstab
|
||||
local automount_from_fstab
|
||||
local hotplug_blkid_fstype_match
|
||||
|
||||
mount_dev_section_cb() {
|
||||
mds_mount_device="$3"
|
||||
mds_mount_fstype="$4"
|
||||
mds_mount_enabled_fsck="$7"
|
||||
}
|
||||
|
||||
swap_dev_section_cb() {
|
||||
sds_swap_device="$2"
|
||||
return 0
|
||||
}
|
||||
|
||||
config_get_automount
|
||||
automount_from_fstab="$from_fstab"
|
||||
|
||||
[ "$automount_from_fstab" -eq 1 ] && {
|
||||
config_get_mount_section_by_device "/dev/$device"
|
||||
use_device="$mds_mount_device"
|
||||
[ "$mds_mount_enabled_fsck" -eq 1 ] && {
|
||||
do_fsck=1
|
||||
fsck_type="$mds_mount_fstype"
|
||||
}
|
||||
}
|
||||
|
||||
[ -z "$use_device" ] && {
|
||||
config_get_autoswap
|
||||
autoswap_from_fstab="$from_fstab"
|
||||
|
||||
[ "$autoswap_from_fstab" -eq 1 ] && {
|
||||
config_get_swap_section_by_device "/dev/$device"
|
||||
use_device="$sds_swap_device" && do_fsck=0
|
||||
}
|
||||
}
|
||||
|
||||
grep -q "/dev/$device" /proc/swaps || grep -q "/dev/$device" /proc/mounts || {
|
||||
[ "$anon_fsck" -eq 1 ] && [ -z "$use_device" ] && {
|
||||
use_device="/dev/$device" && do_fsck=1 && mds_mount_fstype="" && hotplug_blkid_fstype_match=0
|
||||
}
|
||||
}
|
||||
|
||||
[ "$do_fsck" -eq 1 ] && {
|
||||
libmount_fsck "$use_device" "$fsck_type" "$do_fsck"
|
||||
}
|
||||
|
||||
reset_dev_section_cb
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
107
block-mount/files/40-mount
Normal file
107
block-mount/files/40-mount
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
#!/bin/sh
|
||||
# Copyright (C) 2009-2012 OpenWrt.org
|
||||
# Copyright (C) 2010 Vertical Communications
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
. /lib/functions/block.sh
|
||||
|
||||
blkdev=`dirname $DEVPATH`
|
||||
if [ `basename $blkdev` != "block" ]; then
|
||||
|
||||
device=`basename $DEVPATH`
|
||||
mountpoint=`sed -ne "s|^[^ ]*/$device ||; T; s/ .*//p" /proc/self/mounts`
|
||||
|
||||
# Determine mount path
|
||||
usbno=$(echo $DEVPATH | awk -F'/' '{print$7}')
|
||||
case "$usbno" in
|
||||
*:*) usbno=$(echo $DEVPATH | awk -F'/' '{print$6}') ;;
|
||||
esac
|
||||
mnfct="$(cat /sys/bus/usb/devices/$usbno/manufacturer | sed 's/ //g')"
|
||||
prdct="$(cat /sys/bus/usb/devices/$usbno/product | sed 's/ //g')"
|
||||
mnthd="${mnfct:-$prdct}"
|
||||
serial="$(cat /sys/bus/usb/devices/$usbno/serial | sed 's/ //g')"
|
||||
|
||||
case "$ACTION" in
|
||||
add)
|
||||
|
||||
local from_fstab
|
||||
local anon_mount
|
||||
local anon_swap
|
||||
local anon_fsck
|
||||
local mds_mount_target
|
||||
local mds_mount_device
|
||||
local mds_mount_fstype
|
||||
local sds_swap_device
|
||||
local use_device
|
||||
local do_fsck=0
|
||||
local fsck_type
|
||||
|
||||
local autoswap_from_fstab
|
||||
local automount_from_fstab
|
||||
|
||||
mount_dev_section_cb() {
|
||||
mds_mount_target="$2"
|
||||
mds_mount_device="$3"
|
||||
mds_mount_fstype="$4"
|
||||
mds_mount_enabled="$6"
|
||||
}
|
||||
|
||||
swap_dev_section_cb() {
|
||||
sds_swap_device="$2"
|
||||
return 0
|
||||
}
|
||||
|
||||
config_get_automount
|
||||
automount_from_fstab="$from_fstab"
|
||||
[ "$automount_from_fstab" -eq 1 ] && {
|
||||
config_get_mount_section_by_device "/dev/$device"
|
||||
use_device="$mds_mount_device"
|
||||
[ "$mds_mount_enabled" -eq 1 ] && {
|
||||
if [ -n "$mds_mount_target" ]; then
|
||||
grep -q "/dev/$device" /proc/swaps || grep -q "/dev/$device" /proc/mounts || {
|
||||
( mkdir -p "$mds_mount_target" && mount "$mds_mount_target" ) 2>&1 | tee /proc/self/fd/2 | logger -t 'fstab'
|
||||
}
|
||||
else
|
||||
logger -t 'fstab' "Mount enabled for $mds_mount_device but it doesn't have a defined mountpoint (target)"
|
||||
fi
|
||||
}
|
||||
}
|
||||
|
||||
[ -z "$use_device" ] && {
|
||||
config_get_autoswap
|
||||
autoswap_from_fstab="$from_fstab"
|
||||
|
||||
[ "$autoswap_from_fstab" -eq 1 ] && {
|
||||
config_get_swap_section_by_device "/dev/$device"
|
||||
use_device="$sds_swap_device"
|
||||
}
|
||||
}
|
||||
|
||||
grep -q "/dev/$device" /proc/swaps || grep -q "/dev/$device" /proc/mounts || {
|
||||
[ "$anon_mount" -eq 1 -a -z "$use_device" ] && {
|
||||
case "$device" in
|
||||
mtdblock*) ;;
|
||||
*)
|
||||
mntdir="$mnthd$serial"
|
||||
( mkdir -p /mnt/$mntdir && mount /dev/$device /mnt/$mntdir -o umask=0 || ntfs-3g /dev/$device /mnt/$mntdir ) 2>&1 | tee /proc/self/fd/2 | logger -t 'fstab'
|
||||
echo "/dev/$device /mnt/$mntdir" >> /var/usbmounts
|
||||
[ -n "$mntdir" ] && ubus send usb 2>/dev/null
|
||||
;;
|
||||
esac
|
||||
}
|
||||
}
|
||||
reset_dev_section_cb
|
||||
;;
|
||||
remove)
|
||||
umount /dev/$device
|
||||
umount $mountpoint
|
||||
rm -rf $mountpoint
|
||||
sed -i "/$device/ d" /var/usbmounts
|
||||
[ -n "$device" ] && ubus send usb 2>/dev/null
|
||||
;;
|
||||
esac
|
||||
|
||||
fi
|
||||
|
||||
65
block-mount/files/50_determine_usb_root
Normal file
65
block-mount/files/50_determine_usb_root
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
#!/bin/sh
|
||||
# Copyright (C) 2010 Vertical Communications
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
|
||||
|
||||
determine_external_root() {
|
||||
pi_include /lib/functions/extmount.sh
|
||||
pi_include /lib/functions/mount.sh
|
||||
|
||||
local OLD_UCI_CONFIG_DIR="$UCI_CONFIG_DIR"
|
||||
local OLD_PATH="$PATH"
|
||||
local OLD_LD_LIBRARY_PATH="$LD_LIBRARY_PATH"
|
||||
set_jffs_mp
|
||||
determine_root_device
|
||||
|
||||
# extroot requires extroot and fstab config files, therefore
|
||||
# we assume configuration is incomplete and not to be used if either of them
|
||||
# is missing (for jffs versions of these files on squashfs image)
|
||||
if [ "$jffs" = "/tmp/overlay" ] && [ -r "/tmp/overlay/etc/config/fstab" ]; then
|
||||
UCI_CONFIG_DIR="/tmp/overlay/etc/config"
|
||||
ER_IS_SQUASHFS=true
|
||||
ER_OVERLAY_PREFIX="/tmp/overlay"
|
||||
PATH=$ER_OVERLAY_PREFIX/sbin:$PATH
|
||||
LD_LIBRARY_PATH=$ER_OVERLAY_PREFIX/usr/lib:$LD_LIBRARY_PATH
|
||||
export PATH LD_LIBRARY_PATH
|
||||
fi
|
||||
|
||||
# For squashfs on firstboot root_device will be tmpfs for the ramoverlay,
|
||||
# unless there is a saved config, in which case it will be /dev/root,
|
||||
# however in the case of a saved config, it won't be restored until after
|
||||
# this script, so there won't be a config on the first boot after
|
||||
# flashing a squashfs-based filesystem
|
||||
# For ext2, ramdisk, or jffs2 root filesystems root_device is /dev/root
|
||||
# For squashfs after firstboot, root filesystem is /dev/root
|
||||
# We only use the config from the root or jffs if the root_device is
|
||||
# /dev/root
|
||||
[ "$root_device" = "/dev/root" ] && {
|
||||
er_load_modules
|
||||
[ -n "$extroot_settle_time" ] && [ "$extroot_settle_time" -gt 0 ] && {
|
||||
sleep $extroot_settle_time
|
||||
}
|
||||
config_load fstab
|
||||
config_foreach config_mount_by_section mount 1
|
||||
ER_OVERLAY_ROM="/no-extroot"
|
||||
|
||||
[ "$rootfs_found" = "1" ] && grep -q ' /overlay ' /proc/mounts && {
|
||||
pi_extroot_mount_success=true
|
||||
pi_mount_skip_next=false
|
||||
ER_OVERLAY_ROM="/overlay"
|
||||
}
|
||||
[ "$rootfs_found" = "1" ] && grep -q ' /rom ' /proc/mounts && {
|
||||
pi_extroot_mount_success=true
|
||||
pi_mount_skip_next=false
|
||||
ER_OVERLAY_ROM="/rom"
|
||||
}
|
||||
}
|
||||
UCI_CONFIG_DIR="$OLD_UCI_CONFIG_DIR"
|
||||
PATH="$OLD_PATH"
|
||||
LD_LIBRARY_PATH="$OLD_LD_LIBRARY_PATH"
|
||||
export PATH LD_LIBRARY_PATH
|
||||
}
|
||||
|
||||
boot_hook_add preinit_mount_root determine_external_root
|
||||
|
||||
63
block-mount/files/55_determine_extroot_sysupgrade
Normal file
63
block-mount/files/55_determine_extroot_sysupgrade
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
#!/bin/sh
|
||||
# Copyright (C) 2010 Daniel Dickinson
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
|
||||
|
||||
check_set_md5sum() {
|
||||
local er_md5sum_file
|
||||
er_md5sum_file="${ER_OVERLAY_PREFIX}/.extroot.md5sum"
|
||||
local er_disabled
|
||||
if [ "${ER_OVERLAY_ROM}" = "/rom" ]; then
|
||||
er_disabled=/tmp/whole_root-disabled
|
||||
else
|
||||
er_disabled=/tmp${ER_OVERLAY_ROM}-disabled
|
||||
fi
|
||||
|
||||
local er_extroot_md5sum
|
||||
if [ -f $md5sum_file ]; then
|
||||
er_extroot_md5sum="$(cat $er_md5sum_file)"
|
||||
fi
|
||||
|
||||
local er_overlay_file="${ER_OVERLAY_ROM}/etc/extroot.md5sum"
|
||||
|
||||
local er_extroot_overlay_md5sum
|
||||
if [ -f "$er_overlay_file" ]; then
|
||||
er_extroot_overlay_md5sum="$(cat $er_overlay_file)"
|
||||
fi
|
||||
|
||||
if [ -z "$er_extroot_overlay_md5sum" ]; then
|
||||
cat $er_md5sum_file >$er_overlay_file
|
||||
elif [ "$er_extroot_overlay_md5sum" != "$er_extroot_md5sum" ]; then
|
||||
pi_extroot_mount_success="false"
|
||||
mkdir -p $er_disabled
|
||||
mount --move ${ER_OVERLAY_ROM} $er_disabled
|
||||
fi
|
||||
}
|
||||
|
||||
set_jffs_md5sum() {
|
||||
# We do this anytime block-extroot exists, even on the first boot with
|
||||
# no extroot defined.
|
||||
|
||||
local er_md5sum_file
|
||||
er_md5sum_file="${ER_OVERLAY_PREFIX}/.extroot.md5sum"
|
||||
|
||||
local er_extroot_md5sum
|
||||
if [ -f $er_md5sum_file ]; then
|
||||
er_extroot_md5sum="$(cat $er_md5sum_file)"
|
||||
fi
|
||||
if [ -z "$er_extroot_md5sum" ]; then
|
||||
dd if=/dev/urandom count=32 bs=1k 2>/dev/null | md5sum | cut -f1 -d\ >$er_md5sum_file
|
||||
fi
|
||||
}
|
||||
|
||||
determine_extroot_sysupgrade() {
|
||||
check_skip || set_jffs_md5sum
|
||||
|
||||
check_skip || [ "$pi_extroot_mount_success" != "true" ] || {
|
||||
check_set_md5sum
|
||||
}
|
||||
}
|
||||
|
||||
boot_hook_add preinit_mount_root determine_extroot_sysupgrade
|
||||
|
||||
27
block-mount/files/60_pivot_usb_root
Normal file
27
block-mount/files/60_pivot_usb_root
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#!/bin/sh
|
||||
# Copyright (C) 2010 Vertical Communications
|
||||
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
|
||||
# Determine if we are requested to mount external root
|
||||
|
||||
external_root_pivot() {
|
||||
check_skip || [ "$pi_extroot_mount_success" != "true" ] || {
|
||||
echo "switching to external rootfs"
|
||||
if [ "$ER_OVERLAY_ROM" = "/overlay" ]; then
|
||||
if [ "$ER_IS_SQUASHFS" = "true" ]; then
|
||||
umount /tmp/overlay
|
||||
fi
|
||||
mount -o remount,ro / && fopivot /overlay /rom && pi_mount_skip_next=true
|
||||
elif [ "$ER_OVERLAY_ROM" = "/rom" ]; then
|
||||
if [ "$ER_IS_SQUASHFS" = "true" ]; then
|
||||
umount /tmp/overlay
|
||||
fi
|
||||
mount -o remount,ro / && pivot_rom /rom /rom && pi_mount_skip_next=true
|
||||
fi
|
||||
}
|
||||
}
|
||||
|
||||
boot_hook_add preinit_mount_root external_root_pivot
|
||||
|
||||
264
block-mount/files/block.sh
Normal file
264
block-mount/files/block.sh
Normal file
|
|
@ -0,0 +1,264 @@
|
|||
#!/bin/sh
|
||||
# Copyright 2010 Vertical Communications
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
reset_block_cb() {
|
||||
mount_cb() {
|
||||
dmc_mount_cfg="$1"
|
||||
shift # skip optional param
|
||||
dmc_target="$2"
|
||||
dmc_mount_device="$3"
|
||||
dmc_fstype="$4"
|
||||
dmc_options="$5"
|
||||
dmc_enabled="$6"
|
||||
dmc_enabled_fsck="$7"
|
||||
dmc_uuid="$8"
|
||||
dmc_label="$9"
|
||||
shift
|
||||
dmc_is_rootfs="$9"
|
||||
return 0
|
||||
}
|
||||
swap_cb() {
|
||||
dsc_swap_cfg="$1"
|
||||
shift # skip optional param
|
||||
dsc_swap_device="$2"
|
||||
dsc_enabled="$3"
|
||||
dsc_uuid="$4"
|
||||
dsc_label="$5"
|
||||
return 0
|
||||
}
|
||||
}
|
||||
reset_block_cb
|
||||
|
||||
reset_dev_section_cb() {
|
||||
mount_dev_section_cb() {
|
||||
dmds_mount_cfg="$1"
|
||||
dmds_mount_target="$2"
|
||||
dmds_mount_device="$3"
|
||||
dmds_mount_fstype="$4"
|
||||
dmds_mount_options="$5"
|
||||
dmds_mount_enabled="$6"
|
||||
dmds_mount_enabled_fsck="$7"
|
||||
dmds_mount_uuid="$8"
|
||||
dmds_mount_label="$9"
|
||||
shift
|
||||
dmds_is_rootfs="$9"
|
||||
return 0
|
||||
}
|
||||
swap_dev_section_cb() {
|
||||
dsds_swap_cfg="$1"
|
||||
dsds_swap_device="$2"
|
||||
dsds_swap_enabled="$3"
|
||||
dsds_swap_uuid="$4"
|
||||
dsds_swap_label="$5"
|
||||
return 0
|
||||
}
|
||||
}
|
||||
reset_dev_section_cb
|
||||
|
||||
config_get_mount() {
|
||||
local gm_cfg="$1"
|
||||
local gm_param="$2"
|
||||
local gm_target
|
||||
local gm_device
|
||||
local gm_fstype
|
||||
local gm_options
|
||||
local gm_enabled
|
||||
local gm_enabled_fsck
|
||||
local gm_uuid
|
||||
local gm_label
|
||||
local gm_is_rootfs
|
||||
config_get gm_target "$1" target
|
||||
config_get gm_device "$1" device
|
||||
config_get gm_fstype "$1" fstype 'auto'
|
||||
config_get gm_options "$1" options 'rw'
|
||||
config_get_bool gm_enabled "$1" enabled 1
|
||||
config_get_bool gm_enabled_fsck "$1" enabled_fsck 0
|
||||
config_get gm_uuid "$1" uuid
|
||||
config_get gm_label "$1" label
|
||||
config_get_bool gm_is_rootfs "$1" is_rootfs 0
|
||||
mount_cb "$gm_cfg" "$gm_param" "$gm_target" "$gm_device" "$gm_fstype" "$gm_options" "$gm_enabled" "$gm_enabled_fsck" "$gm_uuid" "$gm_label" "$gm_is_rootfs"
|
||||
}
|
||||
|
||||
config_get_swap() {
|
||||
local gs_cfg="$1"
|
||||
local gs_param="$2"
|
||||
local gs_device
|
||||
local gs_enabled
|
||||
local gs_uuid
|
||||
local gs_label
|
||||
config_get gs_device "$1" device
|
||||
config_get_bool gs_enabled "$1" enabled 1
|
||||
config_get gs_uuid "$1" uuid
|
||||
config_get gs_label "$1" label
|
||||
|
||||
swap_cb "$gs_cfg" "$gs_param" "$gs_device" "$gs_enabled" "$gs_uuid" "$gs_label"
|
||||
}
|
||||
|
||||
config_get_automount() {
|
||||
config_load fstab
|
||||
config_get_bool from_fstab "automount" from_fstab 1
|
||||
config_get_bool anon_mount "automount" anon_mount 1
|
||||
config_get_bool anon_fsck "automount" anon_fsck 0
|
||||
}
|
||||
|
||||
config_get_autoswap() {
|
||||
config_load fstab
|
||||
config_get_bool from_fstab "autoswap" from_fstab 1
|
||||
config_get_bool anon_swap "autoswap" anon_swap 0
|
||||
}
|
||||
|
||||
config_create_swap_fstab_entry() {
|
||||
local device="$1"
|
||||
local enabled="$2"
|
||||
|
||||
[ -n "$device" ] || return 0
|
||||
|
||||
local fstabnew
|
||||
|
||||
mkdir -p /var/lock
|
||||
lock /var/lock/fstab.lck
|
||||
fstabnew="$(mktemp -t '.fstab.XXXXXXXX')"
|
||||
cat /tmp/fstab | grep -E -v "^$device[[:blank:]]" >>"$fstabnew"
|
||||
[ "$enabled" -eq 1 ] && echo "$device none swap sw 0 0" >> "$fstabnew"
|
||||
cat "$fstabnew" >/tmp/fstab
|
||||
rm -f $fstabnew
|
||||
lock -u /var/lock/fstab.lck
|
||||
}
|
||||
|
||||
config_create_mount_fstab_entry() {
|
||||
local device="$1"
|
||||
local target="$2"
|
||||
local fstype="$3"
|
||||
local options="$4"
|
||||
local enabled="$5"
|
||||
options="${options:-rw}"
|
||||
[ "$enabled" -eq 0 ] && options="noauto,$options"
|
||||
[ -n "$target" ] || return 0
|
||||
[ -n "$device" ] || return 0
|
||||
|
||||
local fstabnew
|
||||
|
||||
mkdir -p /var/lock
|
||||
lock /var/lock/fstab.lck
|
||||
fstabnew="$(mktemp -t '.fstab.XXXXXXXX')"
|
||||
cat /tmp/fstab | grep -E -v "^$device[[:blank:]]" | grep -v "$target" >>"$fstabnew"
|
||||
echo "$device $target $fstype $options 0 0" >>"$fstabnew"
|
||||
cat "$fstabnew" >/tmp/fstab
|
||||
rm -f $fstabnew
|
||||
lock -u /var/lock/fstab.lck
|
||||
}
|
||||
|
||||
libmount_find_token() {
|
||||
local token="$1"
|
||||
local value="$2"
|
||||
local device
|
||||
device="$(blkid -w /dev/null -c /dev/null | grep "$token=\"$value\"" | cut -f1 -d:)"
|
||||
echo "$device"
|
||||
}
|
||||
|
||||
libmount_find_device_by_id() {
|
||||
local uuid="$1"
|
||||
local label="$2"
|
||||
local device="$3"
|
||||
local cfg_device="$4"
|
||||
local found_device
|
||||
|
||||
if [ -n "$uuid" ]; then
|
||||
found_device="$(libmount_find_token "UUID" "$uuid")"
|
||||
elif [ -n "$label" ]; then
|
||||
found_device="$(libmount_find_token "LABEL" "$label")"
|
||||
elif [ "$device" = "$cfg_device" ]; then
|
||||
found_device="$device"
|
||||
elif [ -z "$device" ] && [ -e "$cfg_device" ]; then
|
||||
found_device="$cfg_device"
|
||||
fi
|
||||
[ -n "$device" ] && [ "$device" != "$found_device" ] && {
|
||||
found_device=""
|
||||
}
|
||||
echo "$found_device"
|
||||
}
|
||||
|
||||
config_get_mount_section_by_device() {
|
||||
local msbd_device="$1"
|
||||
local msbd_mount_cfg=
|
||||
local msbd_target=
|
||||
local msbd_mount_device=
|
||||
local msbd_fstype=
|
||||
local msbd_options=
|
||||
local msbd_enabled=
|
||||
local msbd_enabled_fsck=
|
||||
local msbd_uuid=
|
||||
local msbd_label=
|
||||
local msbd_is_rootfs
|
||||
local msbd_blkid_fstype_match=
|
||||
mount_cb() {
|
||||
local mc_cfg="$1"
|
||||
local mc_device="$2"
|
||||
shift
|
||||
local mc_target="$2"
|
||||
local mc_cfgdevice="$3"
|
||||
local mc_fstype="$4"
|
||||
local mc_uuid="$8"
|
||||
local mc_label="$9"
|
||||
shift
|
||||
local mc_is_rootfs="$9"
|
||||
local mc_found_device=""
|
||||
|
||||
mc_found_device="$(libmount_find_device_by_id "$mc_uuid" "$mc_label" "$mc_device" "$mc_cfgdevice")"
|
||||
if [ -n "$mc_found_device" ]; then
|
||||
msbd_mount_cfg="$mc_cfg"
|
||||
msbd_target="$mc_target"
|
||||
msbd_mount_device="$mc_found_device"
|
||||
msbd_fstype="$mc_fstype"
|
||||
msbd_options="$4"
|
||||
msbd_enabled="$5"
|
||||
msbd_enabled_fsck="$6"
|
||||
msbd_uuid="$7"
|
||||
msbd_label="$8"
|
||||
msbd_is_rootfs="$9"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
config_foreach config_get_mount mount "$msbd_device"
|
||||
[ -n "$msbd_mount_device" ] && config_create_mount_fstab_entry "$msbd_mount_device" "$msbd_target" "$msbd_fstype" "$msbd_options" "$msbd_enabled"
|
||||
mount_dev_section_cb "$msbd_mount_cfg" "$msbd_target" "$msbd_mount_device" "$msbd_fstype" "$msbd_options" "$msbd_enabled" "$msbd_enabled_fsck" "$msbd_uuid" "$msbd_label" "$msbd_is_rootfs"
|
||||
reset_block_cb
|
||||
}
|
||||
|
||||
config_get_swap_section_by_device() {
|
||||
local ssbd_device="$1"
|
||||
local ssbd_swap_cfg=
|
||||
local ssbd_swap_device=
|
||||
local ssbd_enabled=
|
||||
local ssbd_uuid=
|
||||
local ssbd_label=
|
||||
swap_cb() {
|
||||
local sc_cfg="$1"
|
||||
local sc_device="$2"
|
||||
local sc_uuid="$5"
|
||||
local sc_label="$6"
|
||||
local sc_cfgdevice="$3"
|
||||
local sc_found_device
|
||||
|
||||
sc_found_device="$(libmount_find_device_by_id "$sc_uuid" "$sc_label" "$sc_device" "$sc_cfgdevice")"
|
||||
if [ -n "$sc_found_device" ]; then
|
||||
ssbd_swap_cfg="$sc_cfg"
|
||||
ssbd_swap_device="$sc_found_device"
|
||||
ssbd_enabled="$4"
|
||||
ssbd_uuid="$5"
|
||||
ssbd_label="$6"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
config_foreach config_get_swap swap "$ssbd_device"
|
||||
[ -n "$ssbd_swap_device" ] && config_create_swap_fstab_entry "$ssbd_swap_device" "$ssbd_enabled"
|
||||
swap_dev_section_cb "$ssbd_swap_cfg" "$ssbd_swap_device" "$ssbd_enabled" "$ssbd_uuid" "$ssbd_label"
|
||||
reset_block_cb
|
||||
}
|
||||
|
||||
|
||||
37
block-mount/files/extmount.sh
Normal file
37
block-mount/files/extmount.sh
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#!/bin/sh
|
||||
# Copyright (C) 2006-2011 OpenWrt.org
|
||||
# Copyright (C) 2010 Vertical Communications
|
||||
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
|
||||
determine_root_device() {
|
||||
root_device="$(mount | grep ' / ' | cut -f1 -d\ | grep -v rootfs )"
|
||||
}
|
||||
|
||||
set_jffs_mp() {
|
||||
jffs="$(awk '/jffs2/ {print $2}' /proc/mounts)"
|
||||
}
|
||||
|
||||
er_load_modules() {
|
||||
mkdir -p /tmp/extroot_modules/modules.d
|
||||
mkdir -p /tmp/extroot_modules/modules
|
||||
cp -L /etc/modules-boot.d/* /tmp/overlay/etc/modules-boot.d/* /tmp/extroot_modules/modules.d
|
||||
ln -sf /lib/modules/*/* /tmp/overlay/lib/modules/*/* /tmp/extroot_modules/modules
|
||||
local modules="$(cat /tmp/extroot_modules/modules.d/* 2>/dev/null)"
|
||||
cd /tmp/extroot_modules/modules && [ -n "$modules" ] && {
|
||||
echo "$modules" | sed -e 's/^\([^#].*\)/insmod \.\/\1.ko/'| sh 2>&- || :
|
||||
}
|
||||
rm -rf /tmp/extroot_modules
|
||||
}
|
||||
|
||||
pivot_rom() { # <new_root> <old_root>
|
||||
mount -o move /proc $1/proc && \
|
||||
pivot_root $1 $1$2 && {
|
||||
mount -o move $2/dev /dev
|
||||
mount -o move $2/tmp /tmp
|
||||
mount -o move $2/sys /sys 2>&-
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
34
block-mount/files/fsck.sh
Normal file
34
block-mount/files/fsck.sh
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#!/bin/sh
|
||||
# Copyright 2010 Vertical Communications
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
libmount_fsck() {
|
||||
local device="$1"
|
||||
local fsck_fstype="$2"
|
||||
local fsck_enabled="$3"
|
||||
local known_type
|
||||
local found_fsck=0
|
||||
|
||||
|
||||
grep -q "$device" /proc/swaps || grep -q "$device" /proc/mounts || {
|
||||
[ -e "$device" ] && [ "$fsck_enabled" -eq 1 ] && {
|
||||
for known_type in $libmount_known_fsck; do
|
||||
if [ "$known_type" = "$fsck_fstype" ]; then
|
||||
fsck_${known_type} "$device"
|
||||
found_fsck=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ "$found_fsck" -ne 1 ]; then
|
||||
logger -t 'fstab' "Unable to check/repair $device; no known fsck for filesystem type $fstype"
|
||||
fi
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
libmount_known_fsck=""
|
||||
|
||||
pi_include /lib/functions/fsck
|
||||
|
||||
20
block-mount/files/fstab.config
Normal file
20
block-mount/files/fstab.config
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
config global automount
|
||||
option from_fstab 0
|
||||
option anon_mount 1
|
||||
|
||||
config global autoswap
|
||||
option from_fstab 0
|
||||
option anon_swap 0
|
||||
|
||||
config mount
|
||||
option target /mnt
|
||||
option device /dev/sda1
|
||||
option fstype ext4
|
||||
option options rw,sync
|
||||
option enabled 0
|
||||
option enabled_fsck 0
|
||||
|
||||
config swap
|
||||
option device /dev/sda2
|
||||
option enabled 0
|
||||
|
||||
88
block-mount/files/fstab.init
Normal file
88
block-mount/files/fstab.init
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2007 OpenWrt.org
|
||||
# Copyright (C) 2010 Vertical Communications
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
|
||||
START=20
|
||||
|
||||
EXTRA_COMMANDS="overlay_enable whole_root_enable"
|
||||
EXTRA_HELP=" overlay_enable Reenable overlay rootfs. (After you fix it).
|
||||
whole_root_enable Reenable whole-disk rootfs. (After you fix it)."
|
||||
|
||||
rootfs_enable() {
|
||||
local extroot_type="$1"
|
||||
|
||||
if [ ! -d /tmp/${extroot_type}-disabled ]; then
|
||||
echo "No disabled ${extroot_type} present (/tmp/${extroot_type}-disabled). Can't renable."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm -f /tmp/${extroot_type}-disabled/.extroot.md5sum
|
||||
rm -f /tmp/${extroot_type}-disabled/etc/extroot.md5sum
|
||||
echo "Please reboot router to complete re-enabling external rootfs."
|
||||
}
|
||||
|
||||
overlay_enable() {
|
||||
rootfs_enable overlay
|
||||
}
|
||||
|
||||
whole_root_enable() {
|
||||
rootfs_enable whole_root
|
||||
}
|
||||
|
||||
do_mount() {
|
||||
local cfg="$1"
|
||||
config_mount_by_section "$cfg"
|
||||
}
|
||||
|
||||
do_swapon() {
|
||||
local cfg="$1"
|
||||
config_swapon_by_section "$cfg"
|
||||
}
|
||||
|
||||
do_unmount() {
|
||||
local cfg="$1"
|
||||
|
||||
config_get target "$cfg" target
|
||||
config_get_bool enabled "$cfg" "enabled" '1'
|
||||
[ -n "$target" -a "$enabled" -gt 0 ] || return 0
|
||||
umount $target
|
||||
}
|
||||
|
||||
do_swapoff() {
|
||||
local cfg="$1"
|
||||
|
||||
config_get device "$cfg" device
|
||||
config_get_bool enabled "$cfg" "enabled" '1'
|
||||
[ -n "$device" -a "$enabled" -gt 0 ] && type swapoff >/dev/null || return 0
|
||||
swapoff $device
|
||||
}
|
||||
|
||||
start() {
|
||||
. /lib/functions/mount.sh
|
||||
|
||||
config_load fstab
|
||||
mkdir -p /var/lock
|
||||
lock /var/lock/fstab.lck
|
||||
[ -e /tmp/fstab ] || {
|
||||
echo '# WARNING: this is an auto generated file, please use uci to set defined filesystems' > /tmp/fstab
|
||||
}
|
||||
lock -u /var/lock/fstab.lck
|
||||
config_foreach do_swapon swap
|
||||
config_foreach do_mount mount
|
||||
config_foreach do_swapon swap # do swap a second time so that swap on filesystems is enabled
|
||||
}
|
||||
|
||||
stop() {
|
||||
. /lib/functions/mount.sh
|
||||
|
||||
config_load fstab
|
||||
config_foreach do_unmount mount
|
||||
config_foreach do_swapoff swap
|
||||
swapoff -a
|
||||
}
|
||||
|
||||
|
||||
103
block-mount/files/mount.sh
Normal file
103
block-mount/files/mount.sh
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
#!/bin/sh
|
||||
# Copyright 2010 Vertical Communications
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
|
||||
pi_include /lib/functions/block.sh
|
||||
pi_include /lib/functions/fsck.sh
|
||||
|
||||
config_mount_by_section() {
|
||||
local cfg="$1"
|
||||
local find_rootfs="$2"
|
||||
|
||||
mount_cb() {
|
||||
local cfg="$1"
|
||||
local device="$2"
|
||||
shift
|
||||
local target="$2"
|
||||
local cfgdevice="$3"
|
||||
local fstype="$4"
|
||||
local options="$5"
|
||||
local enabled="$6"
|
||||
local enabled_fsck="$7"
|
||||
local uuid="$8"
|
||||
local label="$9"
|
||||
shift
|
||||
local is_rootfs="$9"
|
||||
shift
|
||||
local found_device=""
|
||||
|
||||
found_device="$(libmount_find_device_by_id "$uuid" "$label" "$device" "$cfgdevice")"
|
||||
if [ -n "$found_device" ]; then
|
||||
if [ "$find_rootfs" != "1" ] || ( [ "$is_rootfs" -eq 1 ] || [ "$target" = "/" ] || [ "$target" = "/overlay" ] ); then
|
||||
[ "$enabled_fsck" -eq 1 ] && {
|
||||
grep -q "$found_device" /proc/swaps || grep -q "$found_device" /proc/mounts || {
|
||||
libmount_fsck "$found_device" "$fstype" "$enabled_fsck"
|
||||
}
|
||||
}
|
||||
|
||||
if [ "$find_rootfs" = "1" ]; then
|
||||
if [ "$is_rootfs" -eq 1 ]; then
|
||||
target=/overlay
|
||||
elif [ "$target" = "/" ]; then
|
||||
target=/rom
|
||||
fi
|
||||
else
|
||||
if [ "$is_rootfs" -eq 1 ] || [ "$target" = "/overlay" ]; then
|
||||
target=/tmp/overlay-disabled
|
||||
elif [ "$target" = "/" ] || [ "$target" = "/rom" ]; then
|
||||
target="/tmp/whole_root-disabled"
|
||||
fi
|
||||
fi
|
||||
|
||||
config_create_mount_fstab_entry "$found_device" "$target" "$fstype" "$options" "$enabled"
|
||||
grep -q "$found_device" /proc/swaps || grep -q "$found_device" /proc/mounts || {
|
||||
[ "$enabled" -eq 1 ] && mkdir -p "$target" && mount "$target" 2>&1 | tee /proc/self/fd/2 | logger -t 'fstab'
|
||||
}
|
||||
|
||||
fi
|
||||
fi
|
||||
[ "$find_rootfs" = "1" ] && {
|
||||
[ "$target" = "/overlay" ] && {
|
||||
rootfs_found=1
|
||||
}
|
||||
[ "$target" = "/rom" ] && {
|
||||
rootfs_found=1
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
config_get_mount "$cfg"
|
||||
reset_block_cb
|
||||
}
|
||||
|
||||
config_swapon_by_section() {
|
||||
local cfg="$1"
|
||||
|
||||
swap_cb() {
|
||||
local cfg="$1"
|
||||
local device="$2"
|
||||
local cfgdevice="$3"
|
||||
local enabled="$4"
|
||||
local uuid="$5"
|
||||
local label="$6"
|
||||
local uuid
|
||||
local label
|
||||
|
||||
local found_device=""
|
||||
|
||||
found_device="$(libmount_find_device_by_id "$uuid" "$label" "$device" "$cfgdevice")"
|
||||
|
||||
if [ -n "$found_device" ]; then
|
||||
config_create_swap_fstab_entry "$found_device" "$enabled"
|
||||
grep -q "$found_device" /proc/swaps || grep -q "$found_device" /proc/mounts || {
|
||||
[ "$enabled" -eq 1 ] && swapon "$found_device" | tee /proc/self/fd/2 | logger -t 'fstab'
|
||||
}
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
config_get_swap "$cfg"
|
||||
reset_block_cb
|
||||
}
|
||||
54
brcm-h/Makefile
Normal file
54
brcm-h/Makefile
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
#
|
||||
# Copyright (C) 2006-2008 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:=brcm-h
|
||||
PKG_VERSION:=1
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=git@iopsys.inteno.se:brcm-h
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_VERSION:=HEAD
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(INCLUDE_DIR)/image.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
|
||||
|
||||
define Package/brcm-h
|
||||
SECTION:=net
|
||||
CATEGORY:=Base system
|
||||
TITLE:=Broadcom header files
|
||||
URL:=
|
||||
endef
|
||||
|
||||
define Package/brcm-h/description
|
||||
Broadcom header files
|
||||
endef
|
||||
|
||||
|
||||
define Package/brcm--h/install
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/brcm
|
||||
$(CP) -r $(PACKAGE_BUILD_DIR)/bcm963xx/bcmdrivers/broadcom/include/bcm963xx/* $(STAGING_DIR)/usr/include/brcm \
|
||||
$(CP) -r $(PACKAGE_BUILD_DIR)/bcm963xx/bcmdrivers/opensource/include/bcm963xx/* $(STAGING_DIR)/usr/include/brcm \
|
||||
$(CP) -r $(PACKAGE_BUILD_DIR)/bcm963xx/xChange/dslx_common/voice_res_gw/endpt/inc/* $(STAGING_DIR)/usr/include/brcm \
|
||||
$(CP) -r $(PACKAGE_BUILD_DIR)/bcm963xx/xChange/dslx_common/voice_res_gw/inc/* $(STAGING_DIR)/usr/include/brcm \
|
||||
$(CP) -r $(PACKAGE_BUILD_DIR)/bcm963xx/xChange/dslx_common/voice_res_gw/codec/* $(STAGING_DIR)/usr/include/brcm \
|
||||
$(CP) -r $(PACKAGE_BUILD_DIR)/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/* $(STAGING_DIR)/usr/include/brcm \
|
||||
$(CP) -r $(PACKAGE_BUILD_DIR)/bcm963xx/xChange/dslx_common/voice_res_gw/casCtl/inc/* $(STAGING_DIR)/usr/include/brcm \
|
||||
$(CP) -r $(PACKAGE_BUILD_DIR)/bcm963xx/xChange/dslx_common/xchg_drivers/inc/* $(STAGING_DIR)/usr/include/brcm \
|
||||
|
||||
endef
|
||||
|
||||
|
||||
|
||||
|
||||
$(eval $(call BuildPackage,brcm-h))
|
||||
53
brcm_fw_tool/Makefile
Normal file
53
brcm_fw_tool/Makefile
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
#
|
||||
# Copyright (C) 2006-2009 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
|
||||
|
||||
export BUILD_DIR
|
||||
|
||||
PKG_NAME:=brcm_fw_tool
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_BUILD_DIR := $(KERNEL_BUILD_DIR)/$(PKG_NAME)
|
||||
STAMP_PREPARED := $(STAMP_PREPARED)_$(call confvar,CONFIG_MTD_REDBOOT_PARTS)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/brcm_fw_tool
|
||||
SECTION:=utils
|
||||
CATEGORY:=Base system
|
||||
TITLE:=Update utility for Broadcom nand firmware images
|
||||
DEPENDS:=+bcmkernel
|
||||
endef
|
||||
|
||||
define Package/brcm_fw_tool/description
|
||||
This package contains an utility useful to upgrade from other firmware or
|
||||
older OpenWrt releases.
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
mkdir -p $(PKG_BUILD_DIR)
|
||||
$(CP) ./src/* $(PKG_BUILD_DIR)/
|
||||
endef
|
||||
|
||||
target=$(firstword $(subst -, ,$(BOARD)))
|
||||
|
||||
MAKE_FLAGS += TARGET="$(target)"
|
||||
TARGET_CFLAGS += -Dtarget_$(target)=1 -Wall
|
||||
|
||||
ifdef CONFIG_MTD_REDBOOT_PARTS
|
||||
MAKE_FLAGS += FIS_SUPPORT=1
|
||||
TARGET_CFLAGS += -DFIS_SUPPORT=1
|
||||
endif
|
||||
|
||||
define Package/brcm_fw_tool/install
|
||||
$(INSTALL_DIR) $(1)/sbin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/brcm_fw_tool $(1)/sbin/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,brcm_fw_tool))
|
||||
16
brcm_fw_tool/src/Makefile
Normal file
16
brcm_fw_tool/src/Makefile
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
CC = gcc
|
||||
CFLAGS += -Wall
|
||||
|
||||
CFLAGS += -I$(STAGING_DIR)/usr/include/bcm963xx/shared/opensource/include/bcm963xx/
|
||||
CFLAGS += -I$(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/opensource/include/bcm963xx/
|
||||
|
||||
|
||||
%.o: %.c
|
||||
$(CC) -c $(CFLAGS) -o $@ $<
|
||||
|
||||
obj = brcm_fw_tool.o jffs2.o crc32.o
|
||||
obj.brcm47xx = $(obj.brcm)
|
||||
|
||||
brcm_fw_tool: $(obj) $(obj.$(TARGET))
|
||||
clean:
|
||||
rm -f *.o jffs2
|
||||
1077
brcm_fw_tool/src/brcm_fw_tool.c
Normal file
1077
brcm_fw_tool/src/brcm_fw_tool.c
Normal file
File diff suppressed because it is too large
Load diff
11
brcm_fw_tool/src/brcm_fw_tool.h
Normal file
11
brcm_fw_tool/src/brcm_fw_tool.h
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#ifndef __mtd_h
|
||||
#define __mtd_h
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#define JFFS2_EOF "\xde\xad\xc0\xde"
|
||||
|
||||
extern int quiet;
|
||||
extern int mtd_replace_jffs2(const char *mtd, int fd, int ofs, const char *filename, int nand_erasesize);
|
||||
|
||||
#endif /* __mtd_h */
|
||||
95
brcm_fw_tool/src/crc32.c
Normal file
95
brcm_fw_tool/src/crc32.c
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
* COPYRIGHT (C) 1986 Gary S. Brown. You may use this program, or
|
||||
* code or tables extracted from it, as desired without restriction.
|
||||
*
|
||||
* First, the polynomial itself and its table of feedback terms. The
|
||||
* polynomial is
|
||||
* X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0
|
||||
*
|
||||
* Note that we take it "backwards" and put the highest-order term in
|
||||
* the lowest-order bit. The X^32 term is "implied"; the LSB is the
|
||||
* X^31 term, etc. The X^0 term (usually shown as "+1") results in
|
||||
* the MSB being 1
|
||||
*
|
||||
* Note that the usual hardware shift register implementation, which
|
||||
* is what we're using (we're merely optimizing it by doing eight-bit
|
||||
* chunks at a time) shifts bits into the lowest-order term. In our
|
||||
* implementation, that means shifting towards the right. Why do we
|
||||
* do it this way? Because the calculated CRC must be transmitted in
|
||||
* order from highest-order term to lowest-order term. UARTs transmit
|
||||
* characters in order from LSB to MSB. By storing the CRC this way
|
||||
* we hand it to the UART in the order low-byte to high-byte; the UART
|
||||
* sends each low-bit to hight-bit; and the result is transmission bit
|
||||
* by bit from highest- to lowest-order term without requiring any bit
|
||||
* shuffling on our part. Reception works similarly
|
||||
*
|
||||
* The feedback terms table consists of 256, 32-bit entries. Notes
|
||||
*
|
||||
* The table can be generated at runtime if desired; code to do so
|
||||
* is shown later. It might not be obvious, but the feedback
|
||||
* terms simply represent the results of eight shift/xor opera
|
||||
* tions for all combinations of data and CRC register values
|
||||
*
|
||||
* The values must be right-shifted by eight bits by the "updcrc
|
||||
* logic; the shift must be unsigned (bring in zeroes). On some
|
||||
* hardware you could probably optimize the shift in assembler by
|
||||
* using byte-swap instructions
|
||||
* polynomial $edb88320
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
const uint32_t crc32_table[256] = {
|
||||
0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
|
||||
0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
|
||||
0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
|
||||
0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
|
||||
0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
|
||||
0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
|
||||
0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
|
||||
0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
|
||||
0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
|
||||
0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
|
||||
0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
|
||||
0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
|
||||
0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
|
||||
0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
|
||||
0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
|
||||
0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
|
||||
0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
|
||||
0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
|
||||
0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
|
||||
0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
|
||||
0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
|
||||
0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
|
||||
0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
|
||||
0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
|
||||
0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
|
||||
0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
|
||||
0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
|
||||
0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
|
||||
0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
|
||||
0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
|
||||
0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
|
||||
0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
|
||||
0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
|
||||
0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
|
||||
0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
|
||||
0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
|
||||
0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
|
||||
0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
|
||||
0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
|
||||
0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
|
||||
0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
|
||||
0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
|
||||
0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
|
||||
0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
|
||||
0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
|
||||
0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
|
||||
0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
|
||||
0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
|
||||
0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
|
||||
0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
|
||||
0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
|
||||
0x2d02ef8dL
|
||||
};
|
||||
26
brcm_fw_tool/src/crc32.h
Normal file
26
brcm_fw_tool/src/crc32.h
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#ifndef CRC32_H
|
||||
#define CRC32_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
extern const uint32_t crc32_table[256];
|
||||
|
||||
/* Return a 32-bit CRC of the contents of the buffer. */
|
||||
|
||||
static inline uint32_t
|
||||
crc32(uint32_t val, const void *ss, int len)
|
||||
{
|
||||
const unsigned char *s = ss;
|
||||
while (--len >= 0)
|
||||
val = crc32_table[(val ^ *s++) & 0xff] ^ (val >> 8);
|
||||
return val;
|
||||
}
|
||||
|
||||
static inline unsigned int crc32buf(char *buf, size_t len)
|
||||
{
|
||||
return crc32(0xFFFFFFFF, buf, len);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
350
brcm_fw_tool/src/jffs2.c
Normal file
350
brcm_fw_tool/src/jffs2.c
Normal file
|
|
@ -0,0 +1,350 @@
|
|||
/*
|
||||
* jffs2 on-disk structure generator for mtd
|
||||
*
|
||||
* Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License v2
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* 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.
|
||||
* Based on:
|
||||
* JFFS2 -- Journalling Flash File System, Version 2.
|
||||
* Copyright © 2001-2007 Red Hat, Inc.
|
||||
* Created by David Woodhouse <dwmw2@infradead.org>
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
#include <endian.h>
|
||||
#include "jffs2.h"
|
||||
#include "crc32.h"
|
||||
#include "brcm_fw_tool.h"
|
||||
|
||||
#define PAD(x) (((x)+3)&~3)
|
||||
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
# define CLEANMARKER "\x19\x85\x20\x03\x00\x00\x00\x0c\xf0\x60\xdc\x98"
|
||||
#else
|
||||
# define CLEANMARKER "\x85\x19\x03\x20\x0c\x00\x00\x00\xb1\xb0\x1e\xe4"
|
||||
#endif
|
||||
|
||||
static int last_ino = 0;
|
||||
static int last_version = 0;
|
||||
static char *buf = NULL;
|
||||
static int ofs = 0;
|
||||
static int outfd = -1;
|
||||
static int mtdofs = 0;
|
||||
static int target_ino = 0;
|
||||
static int erasesize = 128*1024;
|
||||
|
||||
static void prep_eraseblock(void);
|
||||
|
||||
static void pad(int size)
|
||||
{
|
||||
if ((ofs % size == 0) && (ofs < erasesize))
|
||||
return;
|
||||
|
||||
if (ofs < erasesize) {
|
||||
memset(buf + ofs, 0xff, (size - (ofs % size)));
|
||||
ofs += (size - (ofs % size));
|
||||
}
|
||||
ofs = ofs % erasesize;
|
||||
if (ofs == 0) {
|
||||
write(outfd, buf, erasesize);
|
||||
mtdofs += erasesize;
|
||||
}
|
||||
}
|
||||
|
||||
static inline int rbytes(void)
|
||||
{
|
||||
return erasesize - (ofs % erasesize);
|
||||
}
|
||||
|
||||
static inline void add_data(char *ptr, int len)
|
||||
{
|
||||
if (ofs + len > erasesize) {
|
||||
pad(erasesize);
|
||||
prep_eraseblock();
|
||||
}
|
||||
memcpy(buf + ofs, ptr, len);
|
||||
ofs += len;
|
||||
}
|
||||
|
||||
static void prep_eraseblock(void)
|
||||
{
|
||||
if (ofs > 0)
|
||||
return;
|
||||
|
||||
add_data(CLEANMARKER, sizeof(CLEANMARKER) - 1);
|
||||
}
|
||||
|
||||
static int add_dirent(const char *name, const char type, int parent)
|
||||
{
|
||||
struct jffs2_raw_dirent *de;
|
||||
|
||||
if (ofs - erasesize < sizeof(struct jffs2_raw_dirent) + strlen(name))
|
||||
pad(erasesize);
|
||||
|
||||
prep_eraseblock();
|
||||
last_ino++;
|
||||
memset(buf + ofs, 0, sizeof(struct jffs2_raw_dirent));
|
||||
de = (struct jffs2_raw_dirent *) (buf + ofs);
|
||||
|
||||
de->magic = JFFS2_MAGIC_BITMASK;
|
||||
de->nodetype = JFFS2_NODETYPE_DIRENT;
|
||||
de->type = type;
|
||||
de->name_crc = crc32(0, name, strlen(name));
|
||||
de->ino = last_ino++;
|
||||
de->pino = parent;
|
||||
de->totlen = sizeof(*de) + strlen(name);
|
||||
de->hdr_crc = crc32(0, (void *) de, sizeof(struct jffs2_unknown_node) - 4);
|
||||
de->version = last_version++;
|
||||
de->mctime = 0;
|
||||
de->nsize = strlen(name);
|
||||
de->node_crc = crc32(0, (void *) de, sizeof(*de) - 8);
|
||||
memcpy(de->name, name, strlen(name));
|
||||
|
||||
ofs += sizeof(struct jffs2_raw_dirent) + de->nsize;
|
||||
pad(4);
|
||||
|
||||
return de->ino;
|
||||
}
|
||||
|
||||
static int add_dir(const char *name, int parent)
|
||||
{
|
||||
struct jffs2_raw_inode ri;
|
||||
int inode;
|
||||
|
||||
inode = add_dirent(name, IFTODT(S_IFDIR), parent);
|
||||
|
||||
if (rbytes() < sizeof(ri))
|
||||
pad(erasesize);
|
||||
prep_eraseblock();
|
||||
|
||||
memset(&ri, 0, sizeof(ri));
|
||||
ri.magic = JFFS2_MAGIC_BITMASK;
|
||||
ri.nodetype = JFFS2_NODETYPE_INODE;
|
||||
ri.totlen = sizeof(ri);
|
||||
ri.hdr_crc = crc32(0, &ri, sizeof(struct jffs2_unknown_node) - 4);
|
||||
|
||||
ri.ino = inode;
|
||||
ri.mode = S_IFDIR | 0755;
|
||||
ri.uid = ri.gid = 0;
|
||||
ri.atime = ri.ctime = ri.mtime = 0;
|
||||
ri.isize = ri.csize = ri.dsize = 0;
|
||||
ri.version = 1;
|
||||
ri.node_crc = crc32(0, &ri, sizeof(ri) - 8);
|
||||
ri.data_crc = 0;
|
||||
|
||||
add_data((char *) &ri, sizeof(ri));
|
||||
pad(4);
|
||||
return inode;
|
||||
}
|
||||
|
||||
static void add_file(const char *name, int parent)
|
||||
{
|
||||
int inode, f_offset = 0, fd;
|
||||
struct jffs2_raw_inode ri;
|
||||
struct stat st;
|
||||
char wbuf[4096];
|
||||
const char *fname;
|
||||
|
||||
if (stat(name, &st)) {
|
||||
fprintf(stderr, "File %s does not exist\n", name);
|
||||
return;
|
||||
}
|
||||
|
||||
fname = strrchr(name, '/');
|
||||
if (fname)
|
||||
fname++;
|
||||
else
|
||||
fname = name;
|
||||
|
||||
inode = add_dirent(fname, IFTODT(S_IFREG), parent);
|
||||
memset(&ri, 0, sizeof(ri));
|
||||
ri.magic = JFFS2_MAGIC_BITMASK;
|
||||
ri.nodetype = JFFS2_NODETYPE_INODE;
|
||||
|
||||
ri.ino = inode;
|
||||
ri.mode = st.st_mode;
|
||||
ri.uid = ri.gid = 0;
|
||||
ri.atime = st.st_atime;
|
||||
ri.ctime = st.st_ctime;
|
||||
ri.mtime = st.st_mtime;
|
||||
ri.isize = st.st_size;
|
||||
ri.compr = 0;
|
||||
ri.usercompr = 0;
|
||||
|
||||
fd = open(name, 0);
|
||||
if (fd < 0) {
|
||||
fprintf(stderr, "File %s does not exist\n", name);
|
||||
return;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
int len = 0;
|
||||
|
||||
for (;;) {
|
||||
len = rbytes() - sizeof(ri);
|
||||
if (len > 128)
|
||||
break;
|
||||
|
||||
pad(erasesize);
|
||||
prep_eraseblock();
|
||||
}
|
||||
|
||||
if (len > sizeof(wbuf))
|
||||
len = sizeof(wbuf);
|
||||
|
||||
len = read(fd, wbuf, len);
|
||||
if (len <= 0)
|
||||
break;
|
||||
|
||||
ri.totlen = sizeof(ri) + len;
|
||||
ri.hdr_crc = crc32(0, &ri, sizeof(struct jffs2_unknown_node) - 4);
|
||||
ri.version = ++last_version;
|
||||
ri.offset = f_offset;
|
||||
ri.csize = ri.dsize = len;
|
||||
ri.node_crc = crc32(0, &ri, sizeof(ri) - 8);
|
||||
ri.data_crc = crc32(0, wbuf, len);
|
||||
f_offset += len;
|
||||
add_data((char *) &ri, sizeof(ri));
|
||||
add_data(wbuf, len);
|
||||
pad(4);
|
||||
prep_eraseblock();
|
||||
}
|
||||
|
||||
close(fd);
|
||||
}
|
||||
|
||||
int mtd_replace_jffs2(const char *mtd, int fd, int ofs, const char *filename, int nand_erasesize)
|
||||
{
|
||||
outfd = fd;
|
||||
mtdofs = ofs;
|
||||
erasesize = nand_erasesize;
|
||||
|
||||
buf = malloc(erasesize);
|
||||
target_ino = 1;
|
||||
if (!last_ino)
|
||||
last_ino = 1;
|
||||
add_file(filename, target_ino);
|
||||
pad(erasesize);
|
||||
|
||||
/* add eof marker, pad to eraseblock size and write the data */
|
||||
add_data(JFFS2_EOF, sizeof(JFFS2_EOF) - 1);
|
||||
pad(erasesize);
|
||||
free(buf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void mtd_parse_jffs2data(const char *buf, const char *dir)
|
||||
{
|
||||
struct jffs2_unknown_node *node = (struct jffs2_unknown_node *) buf;
|
||||
unsigned int ofs = 0;
|
||||
|
||||
while (ofs < erasesize) {
|
||||
node = (struct jffs2_unknown_node *) (buf + ofs);
|
||||
if (node->magic != 0x1985)
|
||||
break;
|
||||
|
||||
ofs += PAD(node->totlen);
|
||||
if (node->nodetype == JFFS2_NODETYPE_DIRENT) {
|
||||
struct jffs2_raw_dirent *de = (struct jffs2_raw_dirent *) node;
|
||||
|
||||
/* is this the right directory name and is it a subdirectory of / */
|
||||
if (*dir && (de->pino == 1) && !strncmp((char *) de->name, dir, de->nsize))
|
||||
target_ino = de->ino;
|
||||
|
||||
/* store the last inode and version numbers for adding extra files */
|
||||
if (last_ino < de->ino)
|
||||
last_ino = de->ino;
|
||||
if (last_version < de->version)
|
||||
last_version = de->version;
|
||||
}
|
||||
}
|
||||
}
|
||||
int quiet = 0;
|
||||
int mtd_write_jffs2(const char *mtd, const char *filename, const char *dir)
|
||||
{
|
||||
int err = -1, fdeof = 0;
|
||||
|
||||
if (quiet < 2)
|
||||
fprintf(stderr, "Appending %s to jffs2 partition %s\n", filename, mtd);
|
||||
|
||||
buf = malloc(erasesize);
|
||||
if (!buf) {
|
||||
fprintf(stderr, "Out of memory!\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (!*dir)
|
||||
target_ino = 1;
|
||||
|
||||
/* parse the structure of the jffs2 first
|
||||
* locate the directory that the file is going to be placed in */
|
||||
for(;;) {
|
||||
struct jffs2_unknown_node *node = (struct jffs2_unknown_node *) buf;
|
||||
|
||||
if (read(outfd, buf, erasesize) != erasesize) {
|
||||
fdeof = 1;
|
||||
break;
|
||||
}
|
||||
mtdofs += erasesize;
|
||||
|
||||
if (node->magic == 0x8519) {
|
||||
fprintf(stderr, "Error: wrong endianness filesystem\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* assume no magic == end of filesystem
|
||||
* the filesystem will probably end with be32(0xdeadc0de) */
|
||||
if (node->magic != 0x1985)
|
||||
break;
|
||||
|
||||
mtd_parse_jffs2data(buf, dir);
|
||||
}
|
||||
|
||||
if (fdeof) {
|
||||
fprintf(stderr, "Error: No room for additional data\n");
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* jump back one eraseblock */
|
||||
mtdofs -= erasesize;
|
||||
lseek(outfd, mtdofs, SEEK_SET);
|
||||
|
||||
ofs = 0;
|
||||
|
||||
if (!last_ino)
|
||||
last_ino = 1;
|
||||
|
||||
if (!target_ino)
|
||||
target_ino = add_dir(dir, 1);
|
||||
|
||||
add_file(filename, target_ino);
|
||||
pad(erasesize);
|
||||
|
||||
/* add eof marker, pad to eraseblock size and write the data */
|
||||
add_data(JFFS2_EOF, sizeof(JFFS2_EOF) - 1);
|
||||
pad(erasesize);
|
||||
|
||||
err = 0;
|
||||
|
||||
done:
|
||||
close(outfd);
|
||||
if (buf)
|
||||
free(buf);
|
||||
|
||||
return err;
|
||||
}
|
||||
216
brcm_fw_tool/src/jffs2.h
Normal file
216
brcm_fw_tool/src/jffs2.h
Normal file
|
|
@ -0,0 +1,216 @@
|
|||
/*
|
||||
* JFFS2 -- Journalling Flash File System, Version 2.
|
||||
*
|
||||
* Copyright (C) 2001-2003 Red Hat, Inc.
|
||||
*
|
||||
* Created by David Woodhouse <dwmw2@infradead.org>
|
||||
*
|
||||
* For licensing information, see the file 'LICENCE' in the
|
||||
* jffs2 directory.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __LINUX_JFFS2_H__
|
||||
#define __LINUX_JFFS2_H__
|
||||
|
||||
#define JFFS2_SUPER_MAGIC 0x72b6
|
||||
|
||||
/* You must include something which defines the C99 uintXX_t types.
|
||||
We don't do it from here because this file is used in too many
|
||||
different environments. */
|
||||
|
||||
/* Values we may expect to find in the 'magic' field */
|
||||
#define JFFS2_OLD_MAGIC_BITMASK 0x1984
|
||||
#define JFFS2_MAGIC_BITMASK 0x1985
|
||||
#define KSAMTIB_CIGAM_2SFFJ 0x8519 /* For detecting wrong-endian fs */
|
||||
#define JFFS2_EMPTY_BITMASK 0xffff
|
||||
#define JFFS2_DIRTY_BITMASK 0x0000
|
||||
|
||||
/* Summary node MAGIC marker */
|
||||
#define JFFS2_SUM_MAGIC 0x02851885
|
||||
|
||||
/* We only allow a single char for length, and 0xFF is empty flash so
|
||||
we don't want it confused with a real length. Hence max 254.
|
||||
*/
|
||||
#define JFFS2_MAX_NAME_LEN 254
|
||||
|
||||
/* How small can we sensibly write nodes? */
|
||||
#define JFFS2_MIN_DATA_LEN 128
|
||||
|
||||
#define JFFS2_COMPR_NONE 0x00
|
||||
#define JFFS2_COMPR_ZERO 0x01
|
||||
#define JFFS2_COMPR_RTIME 0x02
|
||||
#define JFFS2_COMPR_RUBINMIPS 0x03
|
||||
#define JFFS2_COMPR_COPY 0x04
|
||||
#define JFFS2_COMPR_DYNRUBIN 0x05
|
||||
#define JFFS2_COMPR_ZLIB 0x06
|
||||
/* Compatibility flags. */
|
||||
#define JFFS2_COMPAT_MASK 0xc000 /* What do to if an unknown nodetype is found */
|
||||
#define JFFS2_NODE_ACCURATE 0x2000
|
||||
/* INCOMPAT: Fail to mount the filesystem */
|
||||
#define JFFS2_FEATURE_INCOMPAT 0xc000
|
||||
/* ROCOMPAT: Mount read-only */
|
||||
#define JFFS2_FEATURE_ROCOMPAT 0x8000
|
||||
/* RWCOMPAT_COPY: Mount read/write, and copy the node when it's GC'd */
|
||||
#define JFFS2_FEATURE_RWCOMPAT_COPY 0x4000
|
||||
/* RWCOMPAT_DELETE: Mount read/write, and delete the node when it's GC'd */
|
||||
#define JFFS2_FEATURE_RWCOMPAT_DELETE 0x0000
|
||||
|
||||
#define JFFS2_NODETYPE_DIRENT (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 1)
|
||||
#define JFFS2_NODETYPE_INODE (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 2)
|
||||
#define JFFS2_NODETYPE_CLEANMARKER (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 3)
|
||||
#define JFFS2_NODETYPE_PADDING (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 4)
|
||||
|
||||
#define JFFS2_NODETYPE_SUMMARY (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 6)
|
||||
|
||||
#define JFFS2_NODETYPE_XATTR (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 8)
|
||||
#define JFFS2_NODETYPE_XREF (JFFS2_FEATURE_INCOMPAT | JFFS2_NODE_ACCURATE | 9)
|
||||
|
||||
/* XATTR Related */
|
||||
#define JFFS2_XPREFIX_USER 1 /* for "user." */
|
||||
#define JFFS2_XPREFIX_SECURITY 2 /* for "security." */
|
||||
#define JFFS2_XPREFIX_ACL_ACCESS 3 /* for "system.posix_acl_access" */
|
||||
#define JFFS2_XPREFIX_ACL_DEFAULT 4 /* for "system.posix_acl_default" */
|
||||
#define JFFS2_XPREFIX_TRUSTED 5 /* for "trusted.*" */
|
||||
|
||||
#define JFFS2_ACL_VERSION 0x0001
|
||||
|
||||
// Maybe later...
|
||||
//#define JFFS2_NODETYPE_CHECKPOINT (JFFS2_FEATURE_RWCOMPAT_DELETE | JFFS2_NODE_ACCURATE | 3)
|
||||
//#define JFFS2_NODETYPE_OPTIONS (JFFS2_FEATURE_RWCOMPAT_COPY | JFFS2_NODE_ACCURATE | 4)
|
||||
|
||||
|
||||
#define JFFS2_INO_FLAG_PREREAD 1 /* Do read_inode() for this one at
|
||||
mount time, don't wait for it to
|
||||
happen later */
|
||||
#define JFFS2_INO_FLAG_USERCOMPR 2 /* User has requested a specific
|
||||
compression type */
|
||||
|
||||
|
||||
/* These can go once we've made sure we've caught all uses without
|
||||
byteswapping */
|
||||
|
||||
typedef uint32_t jint32_t;
|
||||
|
||||
typedef uint32_t jmode_t;
|
||||
|
||||
typedef uint16_t jint16_t;
|
||||
|
||||
struct jffs2_unknown_node
|
||||
{
|
||||
/* All start like this */
|
||||
jint16_t magic;
|
||||
jint16_t nodetype;
|
||||
jint32_t totlen; /* So we can skip over nodes we don't grok */
|
||||
jint32_t hdr_crc;
|
||||
};
|
||||
|
||||
struct jffs2_raw_dirent
|
||||
{
|
||||
jint16_t magic;
|
||||
jint16_t nodetype; /* == JFFS2_NODETYPE_DIRENT */
|
||||
jint32_t totlen;
|
||||
jint32_t hdr_crc;
|
||||
jint32_t pino;
|
||||
jint32_t version;
|
||||
jint32_t ino; /* == zero for unlink */
|
||||
jint32_t mctime;
|
||||
uint8_t nsize;
|
||||
uint8_t type;
|
||||
uint8_t unused[2];
|
||||
jint32_t node_crc;
|
||||
jint32_t name_crc;
|
||||
uint8_t name[0];
|
||||
};
|
||||
|
||||
/* The JFFS2 raw inode structure: Used for storage on physical media. */
|
||||
/* The uid, gid, atime, mtime and ctime members could be longer, but
|
||||
are left like this for space efficiency. If and when people decide
|
||||
they really need them extended, it's simple enough to add support for
|
||||
a new type of raw node.
|
||||
*/
|
||||
struct jffs2_raw_inode
|
||||
{
|
||||
jint16_t magic; /* A constant magic number. */
|
||||
jint16_t nodetype; /* == JFFS2_NODETYPE_INODE */
|
||||
jint32_t totlen; /* Total length of this node (inc data, etc.) */
|
||||
jint32_t hdr_crc;
|
||||
jint32_t ino; /* Inode number. */
|
||||
jint32_t version; /* Version number. */
|
||||
jmode_t mode; /* The file's type or mode. */
|
||||
jint16_t uid; /* The file's owner. */
|
||||
jint16_t gid; /* The file's group. */
|
||||
jint32_t isize; /* Total resultant size of this inode (used for truncations) */
|
||||
jint32_t atime; /* Last access time. */
|
||||
jint32_t mtime; /* Last modification time. */
|
||||
jint32_t ctime; /* Change time. */
|
||||
jint32_t offset; /* Where to begin to write. */
|
||||
jint32_t csize; /* (Compressed) data size */
|
||||
jint32_t dsize; /* Size of the node's data. (after decompression) */
|
||||
uint8_t compr; /* Compression algorithm used */
|
||||
uint8_t usercompr; /* Compression algorithm requested by the user */
|
||||
jint16_t flags; /* See JFFS2_INO_FLAG_* */
|
||||
jint32_t data_crc; /* CRC for the (compressed) data. */
|
||||
jint32_t node_crc; /* CRC for the raw inode (excluding data) */
|
||||
uint8_t data[0];
|
||||
};
|
||||
|
||||
struct jffs2_raw_xattr {
|
||||
jint16_t magic;
|
||||
jint16_t nodetype; /* = JFFS2_NODETYPE_XATTR */
|
||||
jint32_t totlen;
|
||||
jint32_t hdr_crc;
|
||||
jint32_t xid; /* XATTR identifier number */
|
||||
jint32_t version;
|
||||
uint8_t xprefix;
|
||||
uint8_t name_len;
|
||||
jint16_t value_len;
|
||||
jint32_t data_crc;
|
||||
jint32_t node_crc;
|
||||
uint8_t data[0];
|
||||
} __attribute__((packed));
|
||||
|
||||
struct jffs2_raw_xref
|
||||
{
|
||||
jint16_t magic;
|
||||
jint16_t nodetype; /* = JFFS2_NODETYPE_XREF */
|
||||
jint32_t totlen;
|
||||
jint32_t hdr_crc;
|
||||
jint32_t ino; /* inode number */
|
||||
jint32_t xid; /* XATTR identifier number */
|
||||
jint32_t xseqno; /* xref sequencial number */
|
||||
jint32_t node_crc;
|
||||
} __attribute__((packed));
|
||||
|
||||
struct jffs2_raw_summary
|
||||
{
|
||||
jint16_t magic;
|
||||
jint16_t nodetype; /* = JFFS2_NODETYPE_SUMMARY */
|
||||
jint32_t totlen;
|
||||
jint32_t hdr_crc;
|
||||
jint32_t sum_num; /* number of sum entries*/
|
||||
jint32_t cln_mkr; /* clean marker size, 0 = no cleanmarker */
|
||||
jint32_t padded; /* sum of the size of padding nodes */
|
||||
jint32_t sum_crc; /* summary information crc */
|
||||
jint32_t node_crc; /* node crc */
|
||||
jint32_t sum[0]; /* inode summary info */
|
||||
};
|
||||
|
||||
union jffs2_node_union
|
||||
{
|
||||
struct jffs2_raw_inode i;
|
||||
struct jffs2_raw_dirent d;
|
||||
struct jffs2_raw_xattr x;
|
||||
struct jffs2_raw_xref r;
|
||||
struct jffs2_raw_summary s;
|
||||
struct jffs2_unknown_node u;
|
||||
};
|
||||
|
||||
/* Data payload for device nodes. */
|
||||
union jffs2_device_node {
|
||||
jint16_t old;
|
||||
jint32_t new;
|
||||
};
|
||||
|
||||
#endif /* __LINUX_JFFS2_H__ */
|
||||
58
brcminfo/Makefile
Normal file
58
brcminfo/Makefile
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
#
|
||||
# Copyright (C) 2006-2010 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_NAME:=brcminfo
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
|
||||
STAMP_PREPARED := $(STAMP_PREPARED)_$(call confvar,CONFIG_MTD_REDBOOT_PARTS)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/brcminfo
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=Broadcom voice driver info utility
|
||||
URL:=
|
||||
DEPENDS:= +bcmkernel
|
||||
endef
|
||||
|
||||
define Package/brcminfo/description
|
||||
Utility that prints information regarding voice configuration
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
mkdir -p $(PKG_BUILD_DIR)
|
||||
$(CP) ./src/* $(PKG_BUILD_DIR)/
|
||||
endef
|
||||
|
||||
target=$(firstword $(subst -, ,$(BOARD)))
|
||||
|
||||
MAKE_FLAGS += TARGET="$(target)"
|
||||
|
||||
|
||||
EXTRA_CFLAGS += -DBOS_OS_LINUXUSER
|
||||
|
||||
EXTRA_CFLAGS += -I$(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/broadcom/include/bcm963xx/
|
||||
EXTRA_CFLAGS += -I$(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/opensource/include/bcm963xx/
|
||||
EXTRA_CFLAGS += -I$(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/endpt/inc/
|
||||
EXTRA_CFLAGS += -I$(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc
|
||||
EXTRA_CFLAGS += -I$(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/codec
|
||||
EXTRA_CFLAGS += -I$(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc/
|
||||
EXTRA_CFLAGS += -I$(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/casCtl/inc/
|
||||
EXTRA_CFLAGS += -I$(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc
|
||||
|
||||
TARGET_CFLAGS += -D$(CONFIG_TARGET_IBOARDID) -Dtarget_$(target)=1 -Wall
|
||||
|
||||
define Package/brcminfo/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
cp $(PKG_BUILD_DIR)/brcminfo $(1)/usr/bin/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,brcminfo))
|
||||
15
brcminfo/src/Makefile
Normal file
15
brcminfo/src/Makefile
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
# Makefile for brcminfo utility
|
||||
|
||||
%.o: %.c
|
||||
$(CC) -c $(CFLAGS) -o $@ $<
|
||||
|
||||
OBJS = brcminfo.o
|
||||
all: main
|
||||
|
||||
dynamic: all
|
||||
|
||||
main: brcminfo.o
|
||||
$(CC) $(LDFLAGS) $(EXTRA_CFLAGS) -o brcminfo brcminfo.o -lm
|
||||
|
||||
clean:
|
||||
rm -f brcminfo ${OBJS}
|
||||
92
brcminfo/src/brcminfo.c
Normal file
92
brcminfo/src/brcminfo.c
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
* brcminfo.c
|
||||
* Minor utility that will attempt to read the number of available
|
||||
* endpoints from the brcm voice driver
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include <endpointdrv.h>
|
||||
|
||||
static int endpoint_fd = -1;
|
||||
static int num_fxs_endpoints = -1;
|
||||
static int num_fxo_endpoints = -1;
|
||||
static int num_dect_endpoints = -1;
|
||||
static int num_endpoints = -1;
|
||||
|
||||
int vrgEndptDriverOpen(void)
|
||||
{
|
||||
endpoint_fd = open("/dev/bcmendpoint0", O_RDWR);
|
||||
if (endpoint_fd == -1) {
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int vrgEndptDriverClose(void)
|
||||
{
|
||||
int result = close(endpoint_fd);
|
||||
endpoint_fd = -1;
|
||||
return result;
|
||||
}
|
||||
|
||||
static int brcm_get_endpoints_count(void)
|
||||
{
|
||||
ENDPOINTDRV_ENDPOINTCOUNT_PARM endpointCount;
|
||||
endpointCount.size = sizeof(ENDPOINTDRV_ENDPOINTCOUNT_PARM);
|
||||
|
||||
if ( ioctl( endpoint_fd, ENDPOINTIOCTL_FXSENDPOINTCOUNT, &endpointCount ) != IOCTL_STATUS_SUCCESS ) {
|
||||
return -1;
|
||||
} else {
|
||||
num_fxs_endpoints = endpointCount.endpointNum;
|
||||
}
|
||||
|
||||
if ( ioctl( endpoint_fd, ENDPOINTIOCTL_FXOENDPOINTCOUNT, &endpointCount ) != IOCTL_STATUS_SUCCESS ) {
|
||||
return -1;
|
||||
} else {
|
||||
num_fxo_endpoints = endpointCount.endpointNum;
|
||||
}
|
||||
|
||||
if ( ioctl( endpoint_fd, ENDPOINTIOCTL_DECTENDPOINTCOUNT, &endpointCount ) != IOCTL_STATUS_SUCCESS ) {
|
||||
return -1;
|
||||
} else {
|
||||
num_dect_endpoints = endpointCount.endpointNum;
|
||||
}
|
||||
|
||||
num_endpoints = num_fxs_endpoints + num_fxo_endpoints + num_dect_endpoints;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int result;
|
||||
|
||||
result = vrgEndptDriverOpen();
|
||||
if (result != 0) {
|
||||
printf("Could not open endpoint driver\n");
|
||||
return result;
|
||||
}
|
||||
|
||||
result = brcm_get_endpoints_count();
|
||||
if (result == 0) {
|
||||
printf("DECT Endpoints:\t%d\n", num_dect_endpoints);
|
||||
printf("FXS Endpoints:\t%d\n", num_fxs_endpoints);
|
||||
printf("FXO Endpoints:\t%d\n", num_fxo_endpoints);
|
||||
printf("All Endpoints:\t%d\n", num_endpoints);
|
||||
}
|
||||
else {
|
||||
printf("Endpoint counting failed, maybe driver is not initialized?\n");
|
||||
}
|
||||
|
||||
result = vrgEndptDriverClose();
|
||||
if (result != 0) {
|
||||
printf("Could not close endpoint driver\n");
|
||||
return result;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
51
bridge-utils/Makefile
Normal file
51
bridge-utils/Makefile
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
#
|
||||
# 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:=bridge-utils
|
||||
PKG_RELEASE:=1
|
||||
PKG_SOURCE_URL:=@SF/bridge
|
||||
PKG_VERSION:=1.5
|
||||
PKG_MD5SUM:=ec7b381160b340648dede58c31bb2238
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/bridge
|
||||
SECTION:=net
|
||||
CATEGORY:=Base system
|
||||
TITLE:=Ethernet bridging configuration utility
|
||||
URL:=http://bridge.sourceforge.net/
|
||||
endef
|
||||
|
||||
define Package/bridge/description
|
||||
Manage ethernet bridging: a way to connect networks together to
|
||||
form a larger network.
|
||||
endef
|
||||
|
||||
CONFIGURE_ARGS += \
|
||||
--with-linux-headers="$(LINUX_DIR)" \
|
||||
|
||||
define Build/Prepare
|
||||
$(call Build/Prepare/Default)
|
||||
( cd $(PKG_BUILD_DIR) ; \
|
||||
[ -f ./configure ] || { \
|
||||
ln -sf configure.in configure.ac ; \
|
||||
autoconf ; \
|
||||
} \
|
||||
)
|
||||
endef
|
||||
|
||||
define Package/bridge/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/brctl/brctl $(1)/usr/sbin
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,bridge))
|
||||
11
bridge-utils/patches/001-libbridge_cflags.patch
Normal file
11
bridge-utils/patches/001-libbridge_cflags.patch
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
--- a/libbridge/Makefile.in
|
||||
+++ b/libbridge/Makefile.in
|
||||
@@ -5,7 +5,7 @@ AR=ar
|
||||
RANLIB=@RANLIB@
|
||||
|
||||
CC=@CC@
|
||||
-CFLAGS = -Wall -g $(KERNEL_HEADERS)
|
||||
+CFLAGS = -Wall -g @CFLAGS@ $(KERNEL_HEADERS)
|
||||
|
||||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
37
broadcom-diag/Makefile
Normal file
37
broadcom-diag/Makefile
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#
|
||||
# Copyright (C) 2006-2010 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_NAME:=broadcom-diag
|
||||
PKG_RELEASE:=10
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define KernelPackage/diag
|
||||
SUBMENU:=Other modules
|
||||
DEPENDS:=@TARGET_brcm47xx
|
||||
TITLE:=Driver for router LEDs and Buttons
|
||||
FILES:=$(PKG_BUILD_DIR)/diag.ko
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
mkdir -p $(PKG_BUILD_DIR)
|
||||
$(CP) ./src/* $(PKG_BUILD_DIR)/
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
$(MAKE) -C "$(LINUX_DIR)" \
|
||||
CROSS_COMPILE="$(TARGET_CROSS)" \
|
||||
ARCH="$(LINUX_KARCH)" \
|
||||
SUBDIRS="$(PKG_BUILD_DIR)" \
|
||||
EXTRA_CFLAGS="$(BUILDFLAGS)" \
|
||||
modules
|
||||
endef
|
||||
|
||||
$(eval $(call KernelPackage,diag))
|
||||
17
broadcom-diag/src/Makefile
Normal file
17
broadcom-diag/src/Makefile
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#
|
||||
# Makefile for diag driver
|
||||
#
|
||||
# Copyright (C) 2005 Felix Fietkau <nbd@openwrt.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version
|
||||
# 2 of the License, or (at your option) any later version.
|
||||
#
|
||||
|
||||
obj-m := diag.o
|
||||
|
||||
ifeq ($(MAKING_MODULES),1)
|
||||
|
||||
-include $(TOPDIR)/Rules.make
|
||||
endif
|
||||
1686
broadcom-diag/src/diag.c
Normal file
1686
broadcom-diag/src/diag.c
Normal file
File diff suppressed because it is too large
Load diff
134
broadcom-diag/src/diag.h
Normal file
134
broadcom-diag/src/diag.h
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
/*
|
||||
* diag.h - GPIO interface driver for Broadcom boards
|
||||
*
|
||||
* Copyright (C) 2006 Mike Baker <mbm@openwrt.org>,
|
||||
* Felix Fietkau <nbd@openwrt.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <linux/irq.h>
|
||||
#define MODULE_NAME "diag"
|
||||
|
||||
#define MAX_GPIO 16
|
||||
#define FLASH_TIME HZ/6
|
||||
|
||||
enum polarity_t {
|
||||
REVERSE = 0,
|
||||
NORMAL = 1,
|
||||
INPUT = 2,
|
||||
};
|
||||
|
||||
enum {
|
||||
PROC_BUTTON,
|
||||
PROC_LED,
|
||||
PROC_MODEL,
|
||||
PROC_GPIOMASK
|
||||
};
|
||||
|
||||
struct prochandler_t {
|
||||
int type;
|
||||
void *ptr;
|
||||
};
|
||||
|
||||
struct button_t {
|
||||
struct prochandler_t proc;
|
||||
char *name;
|
||||
u32 gpio;
|
||||
unsigned long seen;
|
||||
u8 pressed;
|
||||
};
|
||||
|
||||
struct led_t {
|
||||
struct prochandler_t proc;
|
||||
char *name;
|
||||
u32 gpio;
|
||||
u8 polarity;
|
||||
u8 flash;
|
||||
u8 state;
|
||||
};
|
||||
|
||||
struct platform_t {
|
||||
char *name;
|
||||
|
||||
struct button_t buttons[MAX_GPIO];
|
||||
u32 button_mask;
|
||||
u32 button_polarity;
|
||||
void (*platform_init)(void);
|
||||
|
||||
struct led_t leds[MAX_GPIO];
|
||||
};
|
||||
|
||||
struct event_t {
|
||||
struct work_struct wq;
|
||||
unsigned long seen;
|
||||
char *name, *action;
|
||||
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0)
|
||||
struct sk_buff *skb;
|
||||
#else
|
||||
char *scratch;
|
||||
char *argv[4];
|
||||
char *envp[7];
|
||||
u8 enr, anr;
|
||||
#endif
|
||||
};
|
||||
|
||||
extern char *nvram_get(char *str);
|
||||
|
||||
static struct platform_t platform;
|
||||
|
||||
/* buttons */
|
||||
|
||||
static void register_buttons(struct button_t *b);
|
||||
static void unregister_buttons(struct button_t *b);
|
||||
|
||||
static void hotplug_button(struct work_struct *work);
|
||||
static irqreturn_t button_handler(int irq, void *dev_id);
|
||||
|
||||
/* leds */
|
||||
|
||||
static void register_leds(struct led_t *l);
|
||||
static void unregister_leds(struct led_t *l);
|
||||
|
||||
static void set_led_extif(struct led_t *led);
|
||||
static void led_flash(unsigned long dummy);
|
||||
|
||||
/* 2.4 compatibility */
|
||||
#ifndef TIMER_INITIALIZER
|
||||
#define TIMER_INITIALIZER(_function, _expires, _data) \
|
||||
{ \
|
||||
/* _expires and _data currently unused */ \
|
||||
function: _function \
|
||||
}
|
||||
#endif
|
||||
|
||||
static struct timer_list led_timer = TIMER_INITIALIZER(&led_flash, 0, 0);
|
||||
|
||||
/* proc */
|
||||
|
||||
static struct proc_dir_entry *diag, *leds;
|
||||
|
||||
static ssize_t diag_proc_read(struct file *file, char *buf, size_t count, loff_t *ppos);
|
||||
static ssize_t diag_proc_write(struct file *file, const char *buf, size_t count, loff_t *ppos);
|
||||
|
||||
static struct file_operations diag_proc_fops = {
|
||||
read: diag_proc_read,
|
||||
write: diag_proc_write
|
||||
};
|
||||
|
||||
static struct prochandler_t proc_model = { .type = PROC_MODEL };
|
||||
static struct prochandler_t proc_gpiomask = { .type = PROC_GPIOMASK };
|
||||
|
||||
16
broadcom-diag/src/gpio.h
Normal file
16
broadcom-diag/src/gpio.h
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#ifndef __DIAG_GPIO_H
|
||||
#define __DIAG_GPIO_H
|
||||
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/ssb/ssb_embedded.h>
|
||||
#include <linux/gpio.h>
|
||||
#include <bcm47xx.h>
|
||||
|
||||
#define EXTIF_ADDR 0x1f000000
|
||||
#define EXTIF_UART (EXTIF_ADDR + 0x00800000)
|
||||
|
||||
#define GPIO_TYPE_NORMAL (0x0 << 24)
|
||||
#define GPIO_TYPE_EXTIF (0x1 << 24)
|
||||
#define GPIO_TYPE_MASK (0xf << 24)
|
||||
|
||||
#endif /* __DIAG_GPIO_H */
|
||||
54
broadcom-nvram/Makefile
Normal file
54
broadcom-nvram/Makefile
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
#
|
||||
# Copyright (C) 2006-2010 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_NAME:=broadcom-nvram
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_BUILD_DIR := $(KERNEL_BUILD_DIR)/$(PKG_NAME)
|
||||
STAMP_PREPARED := $(STAMP_PREPARED)_$(call confvar,CONFIG_MTD_REDBOOT_PARTS)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
LDFLAGS+= \
|
||||
-Wl,-rpath-link=$(STAGING_DIR)/usr/lib \
|
||||
-Wl,-rpath-link=$(STAGING_DIR)/lib
|
||||
|
||||
RSTRIP:=true
|
||||
|
||||
define Package/bcmnvram
|
||||
CATEGORY:=Libraries
|
||||
TITLE:=Broadcom nvram emulator library
|
||||
URL:=
|
||||
DEPENDS:=PACKAGE_libuci:libuci
|
||||
endef
|
||||
|
||||
define Package/bcmnvram/description
|
||||
Broadcom nvram to uci wrapper
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
mkdir -p $(PKG_BUILD_DIR)
|
||||
$(CP) ./src/* $(PKG_BUILD_DIR)/
|
||||
endef
|
||||
|
||||
target=$(firstword $(subst -, ,$(BOARD)))
|
||||
|
||||
MAKE_FLAGS += TARGET="$(target)"
|
||||
TARGET_CFLAGS += -Dtarget_$(target)=1 -Wall
|
||||
|
||||
define Package/bcmnvram/install
|
||||
$(CP) ./files/* $(1)/
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
cp $(PKG_BUILD_DIR)/libnvram.so $(1)/usr/lib/
|
||||
cp $(PKG_BUILD_DIR)/uci_test $(1)/usr/bin/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,bcmnvram))
|
||||
3
broadcom-nvram/files/etc/config/broadcom
Normal file
3
broadcom-nvram/files/etc/config/broadcom
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
config 'broadcom' 'nvram'
|
||||
|
||||
|
||||
23
broadcom-nvram/src/Makefile
Normal file
23
broadcom-nvram/src/Makefile
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# Makefile for broadcom nvram to uci wrapper
|
||||
|
||||
|
||||
%.o: %.c
|
||||
$(CC) -c $(CFLAGS) -o $@ $<
|
||||
|
||||
OBJS = nvram_emu_lib.o ucix.o main.o
|
||||
|
||||
all: libnvram main
|
||||
|
||||
dynamic: all
|
||||
|
||||
libnvram: nvram_emu_lib.o
|
||||
$(CC) -c $(CFLAGS) $(LDFLAGS) -fPIC -o ucix_shared.o ucix.c -luci
|
||||
$(CC) -c $(CFLAGS) $(LDFLAGS) -fPIC -o nvram_emu_lib.o nvram_emu_lib.c -luci
|
||||
$(CC) $(LDFLAGS) -shared -Wl,-soname,libnvram.so -o libnvram.so nvram_emu_lib.o ucix_shared.o -luci
|
||||
|
||||
main: main.o ucix.o
|
||||
$(CC) $(LDFLAGS) -o uci_test main.o ucix.o -luci
|
||||
|
||||
clean:
|
||||
rm -f libnvram.so ucix_shared.o uci_test ${OBJS}
|
||||
|
||||
30
broadcom-nvram/src/main.c
Normal file
30
broadcom-nvram/src/main.c
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
// uci test program Copyright Benjamin Larsson 2012 <benjamin@southpole.se>
|
||||
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <uci.h>
|
||||
#include "ucix.h"
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct uci_context *ctx;
|
||||
const char *ucitmp;
|
||||
|
||||
ctx = ucix_init("broadcom");
|
||||
if(!ctx)
|
||||
printf("Failed to load config file");
|
||||
|
||||
ucitmp = ucix_get_option(ctx, "broadcom", "nvram", "test");
|
||||
printf("test = %s\n",ucitmp);
|
||||
ucix_add_section(ctx, "broadcom", "nvram", "broadcom");
|
||||
ucix_add_option(ctx, "broadcom", "nvram", "test", "tomte");
|
||||
ucix_add_option(ctx, "broadcom", "nvram", "test2", "tomte2");
|
||||
printf("Hello world\n");
|
||||
ucix_commit(ctx, "broadcom");
|
||||
ucitmp = ucix_get_option(ctx, "broadcom", "nvram", "test");
|
||||
printf("test = %s\n",ucitmp);
|
||||
ucix_cleanup(ctx);
|
||||
}
|
||||
173
broadcom-nvram/src/nvram_emu_lib.c
Normal file
173
broadcom-nvram/src/nvram_emu_lib.c
Normal file
|
|
@ -0,0 +1,173 @@
|
|||
/** Broadcom libnvram.so compatible wrapper
|
||||
*
|
||||
* Copyright 2012 Benjamin Larsson <benjamin@southpole.se>
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted,
|
||||
provided that the above copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
OF THIS SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "uci.h"
|
||||
|
||||
|
||||
struct uci_context *ctx = NULL;
|
||||
struct uci_ptr ptr;
|
||||
int nvram_inited = 0;
|
||||
int nvram_debug = 0;
|
||||
|
||||
/** Function prototypes are taken from bcmnvram.h Copyright Broadcom Corporation.
|
||||
* Only some of the nvram_* functions exposed from libnvram.so are implemented.
|
||||
* get, getall, unset, set, commit
|
||||
*/
|
||||
|
||||
|
||||
/* uci does not support . in the key part, replace it with _ */
|
||||
|
||||
static const char * filter_dots_in_string(char *key) {
|
||||
int length = 0;
|
||||
int i;
|
||||
length = strlen(key);
|
||||
for (i=0 ; i<length ; i++) {
|
||||
if (key[i] == '.')
|
||||
key[i] = '_';
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
static void nvram_display_section(struct uci_section *s)
|
||||
{
|
||||
struct uci_element *e;
|
||||
struct uci_option *o;
|
||||
|
||||
printf("%s.%s=%s\n", s->package->e.name, s->e.name, s->type);
|
||||
uci_foreach_element(&s->options, e) {
|
||||
o = uci_to_option(e);
|
||||
printf("%s.%s.%s=%s\n", o->section->package->e.name, o->section->e.name, o->e.name, o->v.string);
|
||||
}
|
||||
}
|
||||
|
||||
void nvram_init() {
|
||||
if (!nvram_inited) {
|
||||
ctx = ucix_init("broadcom");
|
||||
if(!ctx) {
|
||||
printf("Failed to load config file \"broadcom\"\n");
|
||||
return;
|
||||
}
|
||||
ucix_add_section(ctx, "broadcom", "nvram", "broadcom");
|
||||
ucix_add_option(ctx, "broadcom", "nvram", "init", "1");
|
||||
ucix_commit(ctx, "broadcom");
|
||||
nvram_debug = ucix_get_option_int(ctx, "broadcom", "nvram", "debug");
|
||||
nvram_inited = 1;
|
||||
if (nvram_debug)
|
||||
printf("nvram_init()\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get the value of an NVRAM variable. The pointer returned may be
|
||||
* invalid after a set.
|
||||
* @param name name of variable to get
|
||||
* @return value of variable or NULL if undefined
|
||||
*/
|
||||
const char * nvram_get(const char *name) {
|
||||
const char *ucitmp;
|
||||
nvram_init();
|
||||
ucitmp = ucix_get_option(ctx, "broadcom", "nvram", filter_dots_in_string(name));
|
||||
if (nvram_debug)
|
||||
printf("%s=nvram_get(%s)\n", ucitmp, name);
|
||||
|
||||
return ucitmp;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Set the value of an NVRAM variable. The name and value strings are
|
||||
* copied into private storage. Pointers to previously set values
|
||||
* may become invalid. The new value may be immediately
|
||||
* retrieved but will not be permanently stored until a commit.
|
||||
* @param name name of variable to set
|
||||
* @param value value of variable
|
||||
* @return 0 on success and errno on failure
|
||||
*/
|
||||
int nvram_set(const char *name, const char *value) {
|
||||
nvram_init();
|
||||
ucix_add_option(ctx, "broadcom", "nvram", filter_dots_in_string(name), value);
|
||||
ucix_commit(ctx, "broadcom");
|
||||
if (nvram_debug)
|
||||
printf("nvram_set(%s, %s)\n", filter_dots_in_string(name), value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Unset an NVRAM variable. Pointers to previously set values
|
||||
* remain valid until a set.
|
||||
* @param name name of variable to unset
|
||||
* @return 0 on success and errno on failure
|
||||
* NOTE: use nvram_commit to commit this change to flash.
|
||||
*/
|
||||
int nvram_unset(const char *name){
|
||||
nvram_init();
|
||||
ucix_del(ctx, "broadcom", "nvram", filter_dots_in_string(name));
|
||||
ucix_commit(ctx, "broadcom");
|
||||
if (nvram_debug)
|
||||
printf("nvram_unset(%s)\n", filter_dots_in_string(name));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Commit NVRAM variables to permanent storage. All pointers to values
|
||||
* may be invalid after a commit.
|
||||
* NVRAM values are undefined after a commit.
|
||||
* @return 0 on success and errno on failure
|
||||
*/
|
||||
int nvram_commit(void){
|
||||
nvram_init();
|
||||
ucix_commit(ctx, "broadcom");
|
||||
if (nvram_debug)
|
||||
printf("nvram_commit()\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get all NVRAM variables (format name=value\0 ... \0\0).
|
||||
* @param buf buffer to store variables
|
||||
* @param count size of buffer in bytes
|
||||
* @return 0 on success and errno on failure
|
||||
*/
|
||||
int nvram_getall(char *nvram_buf, int count) {
|
||||
nvram_init();
|
||||
|
||||
ptr.package = "broadcom";
|
||||
ptr.section = "nvram";
|
||||
|
||||
if (uci_lookup_ptr(ctx, &ptr, NULL, true) != UCI_OK)
|
||||
return 1;
|
||||
|
||||
if (!(ptr.flags & UCI_LOOKUP_COMPLETE))
|
||||
return 1;
|
||||
|
||||
nvram_display_section(ptr.s);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
172
broadcom-nvram/src/ucix.c
Normal file
172
broadcom-nvram/src/ucix.c
Normal file
|
|
@ -0,0 +1,172 @@
|
|||
/*
|
||||
* 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.
|
||||
*
|
||||
* Copyright (C) 2008 John Crispin <blogic@openwrt.org>
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <uci_config.h>
|
||||
#include <uci.h>
|
||||
#include "ucix.h"
|
||||
|
||||
static struct uci_ptr ptr;
|
||||
|
||||
static inline int ucix_get_ptr(struct uci_context *ctx, const char *p, const char *s, const char *o, const char *t)
|
||||
{
|
||||
memset(&ptr, 0, sizeof(ptr));
|
||||
ptr.package = p;
|
||||
ptr.section = s;
|
||||
ptr.option = o;
|
||||
ptr.value = t;
|
||||
return uci_lookup_ptr(ctx, &ptr, NULL, true);
|
||||
}
|
||||
|
||||
struct uci_context* ucix_init(const char *config_file)
|
||||
{
|
||||
struct uci_context *ctx = uci_alloc_context();
|
||||
uci_add_delta_path(ctx, "/var/state");
|
||||
if(uci_load(ctx, config_file, NULL) != UCI_OK)
|
||||
{
|
||||
printf("%s/%s is missing or corrupt\n", ctx->savedir, config_file);
|
||||
return NULL;
|
||||
}
|
||||
return ctx;
|
||||
}
|
||||
|
||||
struct uci_context* ucix_init_path(const char *path, const char *config_file)
|
||||
{
|
||||
struct uci_context *ctx = uci_alloc_context();
|
||||
if(path)
|
||||
uci_set_confdir(ctx, path);
|
||||
if(uci_load(ctx, config_file, NULL) != UCI_OK)
|
||||
{
|
||||
printf("%s/%s is missing or corrupt\n", ctx->savedir, config_file);
|
||||
return NULL;
|
||||
}
|
||||
return ctx;
|
||||
}
|
||||
|
||||
void ucix_cleanup(struct uci_context *ctx)
|
||||
{
|
||||
uci_free_context(ctx);
|
||||
}
|
||||
|
||||
void ucix_save(struct uci_context *ctx)
|
||||
{
|
||||
uci_set_savedir(ctx, "/tmp/.uci/");
|
||||
uci_save(ctx, NULL);
|
||||
}
|
||||
|
||||
void ucix_save_state(struct uci_context *ctx)
|
||||
{
|
||||
uci_set_savedir(ctx, "/var/state/");
|
||||
uci_save(ctx, NULL);
|
||||
}
|
||||
|
||||
const char* ucix_get_option(struct uci_context *ctx, const char *p, const char *s, const char *o)
|
||||
{
|
||||
struct uci_element *e = NULL;
|
||||
const char *value = NULL;
|
||||
if(ucix_get_ptr(ctx, p, s, o, NULL))
|
||||
return NULL;
|
||||
if (!(ptr.flags & UCI_LOOKUP_COMPLETE))
|
||||
return NULL;
|
||||
e = ptr.last;
|
||||
switch (e->type)
|
||||
{
|
||||
case UCI_TYPE_SECTION:
|
||||
value = uci_to_section(e)->type;
|
||||
break;
|
||||
case UCI_TYPE_OPTION:
|
||||
switch(ptr.o->type) {
|
||||
case UCI_TYPE_STRING:
|
||||
value = ptr.o->v.string;
|
||||
break;
|
||||
default:
|
||||
value = NULL;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
int ucix_get_option_int(struct uci_context *ctx, const char *p, const char *s, const char *o, int def)
|
||||
{
|
||||
const char *tmp = ucix_get_option(ctx, p, s, o);
|
||||
int ret = def;
|
||||
|
||||
if (tmp)
|
||||
ret = atoi(tmp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ucix_add_section(struct uci_context *ctx, const char *p, const char *s, const char *t)
|
||||
{
|
||||
if(ucix_get_ptr(ctx, p, s, NULL, t))
|
||||
return;
|
||||
uci_set(ctx, &ptr);
|
||||
}
|
||||
|
||||
void ucix_add_option(struct uci_context *ctx, const char *p, const char *s, const char *o, const char *t)
|
||||
{
|
||||
if(ucix_get_ptr(ctx, p, s, o, (t)?(t):("")))
|
||||
return;
|
||||
uci_set(ctx, &ptr);
|
||||
}
|
||||
|
||||
void ucix_add_option_int(struct uci_context *ctx, const char *p, const char *s, const char *o, int t)
|
||||
{
|
||||
char tmp[64];
|
||||
snprintf(tmp, 64, "%d", t);
|
||||
ucix_add_option(ctx, p, s, o, tmp);
|
||||
}
|
||||
|
||||
void ucix_del(struct uci_context *ctx, const char *p, const char *s, const char *o)
|
||||
{
|
||||
if(!ucix_get_ptr(ctx, p, s, o, NULL))
|
||||
uci_delete(ctx, &ptr);
|
||||
}
|
||||
|
||||
void ucix_revert(struct uci_context *ctx, const char *p, const char *s, const char *o)
|
||||
{
|
||||
if(!ucix_get_ptr(ctx, p, s, o, NULL))
|
||||
uci_revert(ctx, &ptr);
|
||||
}
|
||||
|
||||
void ucix_for_each_section_type(struct uci_context *ctx,
|
||||
const char *p, const char *t,
|
||||
void (*cb)(const char*, void*), void *priv)
|
||||
{
|
||||
struct uci_element *e;
|
||||
if(ucix_get_ptr(ctx, p, NULL, NULL, NULL))
|
||||
return;
|
||||
uci_foreach_element(&ptr.p->sections, e)
|
||||
if (!strcmp(t, uci_to_section(e)->type))
|
||||
cb(e->name, priv);
|
||||
}
|
||||
|
||||
int ucix_commit(struct uci_context *ctx, const char *p)
|
||||
{
|
||||
if(ucix_get_ptr(ctx, p, NULL, NULL, NULL))
|
||||
return 1;
|
||||
return uci_commit(ctx, &ptr.p, false);
|
||||
}
|
||||
|
||||
41
broadcom-nvram/src/ucix.h
Normal file
41
broadcom-nvram/src/ucix.h
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* 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.
|
||||
*
|
||||
* Copyright (C) 2008 John Crispin <blogic@openwrt.org>
|
||||
*/
|
||||
|
||||
#ifndef _UCI_H__
|
||||
#define _UCI_H__
|
||||
struct uci_context* ucix_init(const char *config_file);
|
||||
struct uci_context* ucix_init_path(const char *path, const char *config_file);
|
||||
void ucix_cleanup(struct uci_context *ctx);
|
||||
void ucix_save(struct uci_context *ctx);
|
||||
void ucix_save_state(struct uci_context *ctx);
|
||||
const char* ucix_get_option(struct uci_context *ctx,
|
||||
const char *p, const char *s, const char *o);
|
||||
int ucix_get_option_int(struct uci_context *ctx,
|
||||
const char *p, const char *s, const char *o, int def);
|
||||
void ucix_add_section(struct uci_context *ctx,
|
||||
const char *p, const char *s, const char *t);
|
||||
void ucix_add_option(struct uci_context *ctx,
|
||||
const char *p, const char *s, const char *o, const char *t);
|
||||
void ucix_add_option_int(struct uci_context *ctx,
|
||||
const char *p, const char *s, const char *o, int t);
|
||||
int ucix_commit(struct uci_context *ctx, const char *p);
|
||||
void ucix_revert(struct uci_context *ctx,
|
||||
const char *p, const char *s, const char *o);
|
||||
void ucix_del(struct uci_context *ctx, const char *p,
|
||||
const char *s, const char *o);
|
||||
#endif
|
||||
29
compcache/Config.in
Normal file
29
compcache/Config.in
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
menu "Configuration"
|
||||
depends on PACKAGE_compcache
|
||||
|
||||
config COMPCACHE_ENABLE
|
||||
bool "enabled on boot"
|
||||
default n
|
||||
help
|
||||
Enables compressed ram swap devices.
|
||||
|
||||
config COMPCACHE_RAM_REPORTED
|
||||
string "swap space reported to kernel in kb"
|
||||
default "2048"
|
||||
help
|
||||
This is the amount of memory that will be reported
|
||||
to the kernel as swap. The real ram in use will differ,
|
||||
because of lzo compression.
|
||||
Example:
|
||||
16 MB = 2048 KB
|
||||
32 MB = 4098 KB
|
||||
|
||||
config COMPCACHE_BACKUP_DEV
|
||||
string "Backup device for compcache"
|
||||
default ""
|
||||
help
|
||||
Compcache will use this as a backup device for swap.
|
||||
Example:
|
||||
/dev/sda5
|
||||
|
||||
endmenu
|
||||
75
compcache/Makefile
Normal file
75
compcache/Makefile
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
#
|
||||
# Copyright (C) 2009-2010 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_NAME:=compcache
|
||||
PKG_VERSION:=0.6.2
|
||||
PKG_RELEASE:=2
|
||||
PKG_SOURCE_URL:=http://compcache.googlecode.com/files/
|
||||
PKG_MD5SUM:=27aec78dc50e34fb800c74e879057743
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define KernelPackage/ramzswap
|
||||
SUBMENU:=Other modules
|
||||
DEPENDS:=@BUSYBOX_CONFIG_SWAPONOFF
|
||||
TITLE:=Driver for compressed ram swap device
|
||||
VERSION:=$(LINUX_VERSION)-$(BOARD)-$(LINUX_RELEASE)+$(PKG_RELEASE)
|
||||
FILES:=$(PKG_BUILD_DIR)/ramzswap.ko \
|
||||
$(PKG_BUILD_DIR)/sub-projects/compression/lzo-kmod/lzo1x.ko
|
||||
URL:=http://code.google.com/p/compcache/
|
||||
endef
|
||||
|
||||
define Package/compcache
|
||||
SECTION:=util
|
||||
CATEGORY:=Utilities
|
||||
DEPENDS:=+kmod-ramzswap
|
||||
TITLE:=Compressed ram swap device
|
||||
URL:=http://code.google.com/p/compcache/
|
||||
MENU:=1
|
||||
endef
|
||||
|
||||
include $(INCLUDE_DIR)/kernel-defaults.mk
|
||||
|
||||
LZO = sub-projects/compression/lzo-kmod
|
||||
RZSC = sub-projects/rzscontrol
|
||||
|
||||
BUILDFLAGS:=-DCONFIG_RAMZSWAP_STATS \
|
||||
-I$(PKG_BUILD_DIR)/$(LZO) \
|
||||
-Wall
|
||||
|
||||
RZSCFLAGS:=-I$(PKG_BUILD_DIR)/$(RZSC)/../include \
|
||||
-I$(PKG_BUILD_DIR)/$(RZSC)/../..
|
||||
|
||||
define Build/Compile
|
||||
$(MAKE) $(KERNEL_MAKEOPTS) EXTRA_CFLAGS="$(BUILDFLAGS)" M="$(PKG_BUILD_DIR)" modules
|
||||
$(TARGET_CC) $(TARGET_CFLAGS) $(RZSCFLAGS) $(PKG_BUILD_DIR)/$(RZSC)/rzscontrol.c -o $(PKG_BUILD_DIR)/rzscontrol
|
||||
endef
|
||||
|
||||
define Package/compcache/install
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_DATA) ./files/compcache.config $(1)/etc/config/compcache
|
||||
$(SED) 's,%ENABLED%,$(if $(CONFIG_COMPCACHE_ENABLE),1,0),g' \
|
||||
-e 's,%RAM_REPORTED%,$(call qstrip,$(CONFIG_COMPCACHE_RAM_REPORTED)),g' \
|
||||
-e 's,%BACKUP_DEV%,$(call qstrip,$(CONFIG_COMPCACHE_BACKUP_DEV)),g' \
|
||||
$(1)/etc/config/compcache
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/compcache.init $(1)/etc/init.d/compcache
|
||||
$(INSTALL_DIR) $(1)/sbin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/rzscontrol $(1)/sbin/rzscontrol
|
||||
endef
|
||||
|
||||
define Package/compcache/config
|
||||
source "$(SOURCE)/Config.in"
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,compcache))
|
||||
$(eval $(call KernelPackage,ramzswap))
|
||||
4
compcache/files/compcache.config
Normal file
4
compcache/files/compcache.config
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
config compcache
|
||||
option 'enabled' '%ENABLED%'
|
||||
option 'size_kbytes' '%RAM_REPORTED%'
|
||||
option 'backup_dev' '%BACKUP_DEV%'
|
||||
48
compcache/files/compcache.init
Normal file
48
compcache/files/compcache.init
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2008 OpenWrt.org
|
||||
START=14
|
||||
|
||||
load_modules() {
|
||||
local section="$1"
|
||||
config_get "size_kbytes" "$section" "size_kbytes"
|
||||
config_get "backup_dev" "$section" "backup_dev"
|
||||
#CC_PARAM_STR="memlimit_kb=$1 backing_dev=$BACKING_DEV"
|
||||
config_get_bool "enabled" "$section" "enabled" '1'
|
||||
if [ "$enabled" -gt 0 ]; then
|
||||
if [ "`cat /proc/swaps | grep 'ramzswap0'`" != "" ]; then
|
||||
echo "compcache already loaded"
|
||||
else
|
||||
if [ "$backup_dev" != "" ]; then
|
||||
params_set="memlimit_kb=$size_kbytes backing_swap=$backup_dev"
|
||||
else
|
||||
params_set="disksize_kb=$size_kbytes"
|
||||
fi
|
||||
if [ "`lsmod | grep 'ramzswap'`" == "" ]; then
|
||||
insmod lzo1x
|
||||
insmod ramzswap $params_set
|
||||
sleep 2
|
||||
swapon /dev/ramzswap0
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
remove_modules() {
|
||||
local section="$1"
|
||||
config_get_bool "enabled" "$section" "enabled" '1'
|
||||
if [ "$enabled" -gt 0 ]; then
|
||||
[ "`cat /proc/swaps | grep 'ramzswap0'`" != "" ] && swapoff /dev/ramzswap0
|
||||
[ "`lsmod | grep 'ramzswap'`" != "" ] && rmmod ramzswap &> /dev/null
|
||||
[ "`lsmod | grep 'lzo1x'`" != "" ] && rmmod lzo1x &> /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
start() {
|
||||
config_load "compcache"
|
||||
config_foreach load_modules "compcache"
|
||||
}
|
||||
|
||||
stop() {
|
||||
config_load "compcache"
|
||||
config_foreach remove_modules "compcache"
|
||||
}
|
||||
647
compcache/patches/000-provide_lzo_kmod.patch
Normal file
647
compcache/patches/000-provide_lzo_kmod.patch
Normal file
|
|
@ -0,0 +1,647 @@
|
|||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -1,14 +1,17 @@
|
||||
KERNEL_BUILD_PATH ?= "/lib/modules/$(shell uname -r)/build"
|
||||
|
||||
XVM = sub-projects/allocators/xvmalloc-kmod
|
||||
+LZO = sub-projects/compression/lzo-kmod
|
||||
EXTRA_CFLAGS := -DCONFIG_RAMZSWAP_STATS \
|
||||
-Wall
|
||||
|
||||
-obj-m += ramzswap.o
|
||||
+obj-m += ramzswap.o $(LZO)/lzo1x.o
|
||||
ramzswap-objs := ramzswap_drv.o $(XVM)/xvmalloc.o
|
||||
+
|
||||
|
||||
all:
|
||||
make -C $(KERNEL_BUILD_PATH) M=$(PWD) modules
|
||||
+ make -C $(KERNEL_BUILD_PATH) M=$(PWD)/$(LZO) modules
|
||||
make -C sub-projects/rzscontrol
|
||||
|
||||
doc:
|
||||
@@ -16,5 +19,6 @@ doc:
|
||||
|
||||
clean:
|
||||
make -C $(KERNEL_BUILD_PATH) M=$(PWD) clean
|
||||
+ make -C $(KERNEL_BUILD_PATH) M=$(PWD)/$(LZO) clean
|
||||
make -C sub-projects/rzscontrol clean
|
||||
@rm -rf *.ko
|
||||
--- a/ramzswap_drv.c
|
||||
+++ b/ramzswap_drv.c
|
||||
@@ -23,13 +23,13 @@
|
||||
#include <linux/device.h>
|
||||
#include <linux/genhd.h>
|
||||
#include <linux/highmem.h>
|
||||
-#include <linux/lzo.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/swap.h>
|
||||
#include <linux/swapops.h>
|
||||
#include <linux/vmalloc.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
+#include "lzo.h"
|
||||
#include "compat.h"
|
||||
#include "ramzswap_drv.h"
|
||||
|
||||
--- /dev/null
|
||||
+++ b/sub-projects/compression/lzo-kmod/lzo1x.c
|
||||
@@ -0,0 +1,7 @@
|
||||
+#include <linux/module.h>
|
||||
+
|
||||
+#include "lzo1x_compress.c"
|
||||
+#include "lzo1x_decompress.c"
|
||||
+
|
||||
+MODULE_LICENSE("GPL");
|
||||
+MODULE_DESCRIPTION("LZO1X Lib");
|
||||
--- /dev/null
|
||||
+++ b/sub-projects/compression/lzo-kmod/lzo1x_compress.c
|
||||
@@ -0,0 +1,227 @@
|
||||
+/*
|
||||
+ * LZO1X Compressor from MiniLZO
|
||||
+ *
|
||||
+ * Copyright (C) 1996-2005 Markus F.X.J. Oberhumer <markus@oberhumer.com>
|
||||
+ *
|
||||
+ * The full LZO package can be found at:
|
||||
+ * http://www.oberhumer.com/opensource/lzo/
|
||||
+ *
|
||||
+ * Changed for kernel use by:
|
||||
+ * Nitin Gupta <nitingupta910@gmail.com>
|
||||
+ * Richard Purdie <rpurdie@openedhand.com>
|
||||
+ */
|
||||
+
|
||||
+#include <linux/module.h>
|
||||
+#include <linux/kernel.h>
|
||||
+#include <asm/unaligned.h>
|
||||
+
|
||||
+#include "lzodefs.h"
|
||||
+#include "lzo.h"
|
||||
+
|
||||
+static noinline size_t
|
||||
+_lzo1x_1_do_compress(const unsigned char *in, size_t in_len,
|
||||
+ unsigned char *out, size_t *out_len, void *wrkmem)
|
||||
+{
|
||||
+ const unsigned char * const in_end = in + in_len;
|
||||
+ const unsigned char * const ip_end = in + in_len - M2_MAX_LEN - 5;
|
||||
+ const unsigned char ** const dict = wrkmem;
|
||||
+ const unsigned char *ip = in, *ii = ip;
|
||||
+ const unsigned char *end, *m, *m_pos;
|
||||
+ size_t m_off, m_len, dindex;
|
||||
+ unsigned char *op = out;
|
||||
+
|
||||
+ ip += 4;
|
||||
+
|
||||
+ for (;;) {
|
||||
+ dindex = ((size_t)(0x21 * DX3(ip, 5, 5, 6)) >> 5) & D_MASK;
|
||||
+ m_pos = dict[dindex];
|
||||
+
|
||||
+ if (m_pos < in)
|
||||
+ goto literal;
|
||||
+
|
||||
+ if (ip == m_pos || ((size_t)(ip - m_pos) > M4_MAX_OFFSET))
|
||||
+ goto literal;
|
||||
+
|
||||
+ m_off = ip - m_pos;
|
||||
+ if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3])
|
||||
+ goto try_match;
|
||||
+
|
||||
+ dindex = (dindex & (D_MASK & 0x7ff)) ^ (D_HIGH | 0x1f);
|
||||
+ m_pos = dict[dindex];
|
||||
+
|
||||
+ if (m_pos < in)
|
||||
+ goto literal;
|
||||
+
|
||||
+ if (ip == m_pos || ((size_t)(ip - m_pos) > M4_MAX_OFFSET))
|
||||
+ goto literal;
|
||||
+
|
||||
+ m_off = ip - m_pos;
|
||||
+ if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3])
|
||||
+ goto try_match;
|
||||
+
|
||||
+ goto literal;
|
||||
+
|
||||
+try_match:
|
||||
+ if (get_unaligned((const unsigned short *)m_pos)
|
||||
+ == get_unaligned((const unsigned short *)ip)) {
|
||||
+ if (likely(m_pos[2] == ip[2]))
|
||||
+ goto match;
|
||||
+ }
|
||||
+
|
||||
+literal:
|
||||
+ dict[dindex] = ip;
|
||||
+ ++ip;
|
||||
+ if (unlikely(ip >= ip_end))
|
||||
+ break;
|
||||
+ continue;
|
||||
+
|
||||
+match:
|
||||
+ dict[dindex] = ip;
|
||||
+ if (ip != ii) {
|
||||
+ size_t t = ip - ii;
|
||||
+
|
||||
+ if (t <= 3) {
|
||||
+ op[-2] |= t;
|
||||
+ } else if (t <= 18) {
|
||||
+ *op++ = (t - 3);
|
||||
+ } else {
|
||||
+ size_t tt = t - 18;
|
||||
+
|
||||
+ *op++ = 0;
|
||||
+ while (tt > 255) {
|
||||
+ tt -= 255;
|
||||
+ *op++ = 0;
|
||||
+ }
|
||||
+ *op++ = tt;
|
||||
+ }
|
||||
+ do {
|
||||
+ *op++ = *ii++;
|
||||
+ } while (--t > 0);
|
||||
+ }
|
||||
+
|
||||
+ ip += 3;
|
||||
+ if (m_pos[3] != *ip++ || m_pos[4] != *ip++
|
||||
+ || m_pos[5] != *ip++ || m_pos[6] != *ip++
|
||||
+ || m_pos[7] != *ip++ || m_pos[8] != *ip++) {
|
||||
+ --ip;
|
||||
+ m_len = ip - ii;
|
||||
+
|
||||
+ if (m_off <= M2_MAX_OFFSET) {
|
||||
+ m_off -= 1;
|
||||
+ *op++ = (((m_len - 1) << 5)
|
||||
+ | ((m_off & 7) << 2));
|
||||
+ *op++ = (m_off >> 3);
|
||||
+ } else if (m_off <= M3_MAX_OFFSET) {
|
||||
+ m_off -= 1;
|
||||
+ *op++ = (M3_MARKER | (m_len - 2));
|
||||
+ goto m3_m4_offset;
|
||||
+ } else {
|
||||
+ m_off -= 0x4000;
|
||||
+
|
||||
+ *op++ = (M4_MARKER | ((m_off & 0x4000) >> 11)
|
||||
+ | (m_len - 2));
|
||||
+ goto m3_m4_offset;
|
||||
+ }
|
||||
+ } else {
|
||||
+ end = in_end;
|
||||
+ m = m_pos + M2_MAX_LEN + 1;
|
||||
+
|
||||
+ while (ip < end && *m == *ip) {
|
||||
+ m++;
|
||||
+ ip++;
|
||||
+ }
|
||||
+ m_len = ip - ii;
|
||||
+
|
||||
+ if (m_off <= M3_MAX_OFFSET) {
|
||||
+ m_off -= 1;
|
||||
+ if (m_len <= 33) {
|
||||
+ *op++ = (M3_MARKER | (m_len - 2));
|
||||
+ } else {
|
||||
+ m_len -= 33;
|
||||
+ *op++ = M3_MARKER | 0;
|
||||
+ goto m3_m4_len;
|
||||
+ }
|
||||
+ } else {
|
||||
+ m_off -= 0x4000;
|
||||
+ if (m_len <= M4_MAX_LEN) {
|
||||
+ *op++ = (M4_MARKER
|
||||
+ | ((m_off & 0x4000) >> 11)
|
||||
+ | (m_len - 2));
|
||||
+ } else {
|
||||
+ m_len -= M4_MAX_LEN;
|
||||
+ *op++ = (M4_MARKER
|
||||
+ | ((m_off & 0x4000) >> 11));
|
||||
+m3_m4_len:
|
||||
+ while (m_len > 255) {
|
||||
+ m_len -= 255;
|
||||
+ *op++ = 0;
|
||||
+ }
|
||||
+
|
||||
+ *op++ = (m_len);
|
||||
+ }
|
||||
+ }
|
||||
+m3_m4_offset:
|
||||
+ *op++ = ((m_off & 63) << 2);
|
||||
+ *op++ = (m_off >> 6);
|
||||
+ }
|
||||
+
|
||||
+ ii = ip;
|
||||
+ if (unlikely(ip >= ip_end))
|
||||
+ break;
|
||||
+ }
|
||||
+
|
||||
+ *out_len = op - out;
|
||||
+ return in_end - ii;
|
||||
+}
|
||||
+
|
||||
+int lzo1x_1_compress(const unsigned char *in, size_t in_len, unsigned char *out,
|
||||
+ size_t *out_len, void *wrkmem)
|
||||
+{
|
||||
+ const unsigned char *ii;
|
||||
+ unsigned char *op = out;
|
||||
+ size_t t;
|
||||
+
|
||||
+ if (unlikely(in_len <= M2_MAX_LEN + 5)) {
|
||||
+ t = in_len;
|
||||
+ } else {
|
||||
+ t = _lzo1x_1_do_compress(in, in_len, op, out_len, wrkmem);
|
||||
+ op += *out_len;
|
||||
+ }
|
||||
+
|
||||
+ if (t > 0) {
|
||||
+ ii = in + in_len - t;
|
||||
+
|
||||
+ if (op == out && t <= 238) {
|
||||
+ *op++ = (17 + t);
|
||||
+ } else if (t <= 3) {
|
||||
+ op[-2] |= t;
|
||||
+ } else if (t <= 18) {
|
||||
+ *op++ = (t - 3);
|
||||
+ } else {
|
||||
+ size_t tt = t - 18;
|
||||
+
|
||||
+ *op++ = 0;
|
||||
+ while (tt > 255) {
|
||||
+ tt -= 255;
|
||||
+ *op++ = 0;
|
||||
+ }
|
||||
+
|
||||
+ *op++ = tt;
|
||||
+ }
|
||||
+ do {
|
||||
+ *op++ = *ii++;
|
||||
+ } while (--t > 0);
|
||||
+ }
|
||||
+
|
||||
+ *op++ = M4_MARKER | 1;
|
||||
+ *op++ = 0;
|
||||
+ *op++ = 0;
|
||||
+
|
||||
+ *out_len = op - out;
|
||||
+ return LZO_E_OK;
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(lzo1x_1_compress);
|
||||
+
|
||||
+MODULE_LICENSE("GPL");
|
||||
+MODULE_DESCRIPTION("LZO1X-1 Compressor");
|
||||
+
|
||||
--- /dev/null
|
||||
+++ b/sub-projects/compression/lzo-kmod/lzo1x_decompress.c
|
||||
@@ -0,0 +1,255 @@
|
||||
+/*
|
||||
+ * LZO1X Decompressor from MiniLZO
|
||||
+ *
|
||||
+ * Copyright (C) 1996-2005 Markus F.X.J. Oberhumer <markus@oberhumer.com>
|
||||
+ *
|
||||
+ * The full LZO package can be found at:
|
||||
+ * http://www.oberhumer.com/opensource/lzo/
|
||||
+ *
|
||||
+ * Changed for kernel use by:
|
||||
+ * Nitin Gupta <nitingupta910@gmail.com>
|
||||
+ * Richard Purdie <rpurdie@openedhand.com>
|
||||
+ */
|
||||
+
|
||||
+#include <linux/module.h>
|
||||
+#include <linux/kernel.h>
|
||||
+#include <asm/byteorder.h>
|
||||
+#include <asm/unaligned.h>
|
||||
+
|
||||
+#include "lzodefs.h"
|
||||
+#include "lzo.h"
|
||||
+
|
||||
+#define HAVE_IP(x, ip_end, ip) ((size_t)(ip_end - ip) < (x))
|
||||
+#define HAVE_OP(x, op_end, op) ((size_t)(op_end - op) < (x))
|
||||
+#define HAVE_LB(m_pos, out, op) (m_pos < out || m_pos >= op)
|
||||
+
|
||||
+#define COPY4(dst, src) \
|
||||
+ put_unaligned(get_unaligned((const u32 *)(src)), (u32 *)(dst))
|
||||
+
|
||||
+int lzo1x_decompress_safe(const unsigned char *in, size_t in_len,
|
||||
+ unsigned char *out, size_t *out_len)
|
||||
+{
|
||||
+ const unsigned char * const ip_end = in + in_len;
|
||||
+ unsigned char * const op_end = out + *out_len;
|
||||
+ const unsigned char *ip = in, *m_pos;
|
||||
+ unsigned char *op = out;
|
||||
+ size_t t;
|
||||
+
|
||||
+ *out_len = 0;
|
||||
+
|
||||
+ if (*ip > 17) {
|
||||
+ t = *ip++ - 17;
|
||||
+ if (t < 4)
|
||||
+ goto match_next;
|
||||
+ if (HAVE_OP(t, op_end, op))
|
||||
+ goto output_overrun;
|
||||
+ if (HAVE_IP(t + 1, ip_end, ip))
|
||||
+ goto input_overrun;
|
||||
+ do {
|
||||
+ *op++ = *ip++;
|
||||
+ } while (--t > 0);
|
||||
+ goto first_literal_run;
|
||||
+ }
|
||||
+
|
||||
+ while ((ip < ip_end)) {
|
||||
+ t = *ip++;
|
||||
+ if (t >= 16)
|
||||
+ goto match;
|
||||
+ if (t == 0) {
|
||||
+ if (HAVE_IP(1, ip_end, ip))
|
||||
+ goto input_overrun;
|
||||
+ while (*ip == 0) {
|
||||
+ t += 255;
|
||||
+ ip++;
|
||||
+ if (HAVE_IP(1, ip_end, ip))
|
||||
+ goto input_overrun;
|
||||
+ }
|
||||
+ t += 15 + *ip++;
|
||||
+ }
|
||||
+ if (HAVE_OP(t + 3, op_end, op))
|
||||
+ goto output_overrun;
|
||||
+ if (HAVE_IP(t + 4, ip_end, ip))
|
||||
+ goto input_overrun;
|
||||
+
|
||||
+ COPY4(op, ip);
|
||||
+ op += 4;
|
||||
+ ip += 4;
|
||||
+ if (--t > 0) {
|
||||
+ if (t >= 4) {
|
||||
+ do {
|
||||
+ COPY4(op, ip);
|
||||
+ op += 4;
|
||||
+ ip += 4;
|
||||
+ t -= 4;
|
||||
+ } while (t >= 4);
|
||||
+ if (t > 0) {
|
||||
+ do {
|
||||
+ *op++ = *ip++;
|
||||
+ } while (--t > 0);
|
||||
+ }
|
||||
+ } else {
|
||||
+ do {
|
||||
+ *op++ = *ip++;
|
||||
+ } while (--t > 0);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+first_literal_run:
|
||||
+ t = *ip++;
|
||||
+ if (t >= 16)
|
||||
+ goto match;
|
||||
+ m_pos = op - (1 + M2_MAX_OFFSET);
|
||||
+ m_pos -= t >> 2;
|
||||
+ m_pos -= *ip++ << 2;
|
||||
+
|
||||
+ if (HAVE_LB(m_pos, out, op))
|
||||
+ goto lookbehind_overrun;
|
||||
+
|
||||
+ if (HAVE_OP(3, op_end, op))
|
||||
+ goto output_overrun;
|
||||
+ *op++ = *m_pos++;
|
||||
+ *op++ = *m_pos++;
|
||||
+ *op++ = *m_pos;
|
||||
+
|
||||
+ goto match_done;
|
||||
+
|
||||
+ do {
|
||||
+match:
|
||||
+ if (t >= 64) {
|
||||
+ m_pos = op - 1;
|
||||
+ m_pos -= (t >> 2) & 7;
|
||||
+ m_pos -= *ip++ << 3;
|
||||
+ t = (t >> 5) - 1;
|
||||
+ if (HAVE_LB(m_pos, out, op))
|
||||
+ goto lookbehind_overrun;
|
||||
+ if (HAVE_OP(t + 3 - 1, op_end, op))
|
||||
+ goto output_overrun;
|
||||
+ goto copy_match;
|
||||
+ } else if (t >= 32) {
|
||||
+ t &= 31;
|
||||
+ if (t == 0) {
|
||||
+ if (HAVE_IP(1, ip_end, ip))
|
||||
+ goto input_overrun;
|
||||
+ while (*ip == 0) {
|
||||
+ t += 255;
|
||||
+ ip++;
|
||||
+ if (HAVE_IP(1, ip_end, ip))
|
||||
+ goto input_overrun;
|
||||
+ }
|
||||
+ t += 31 + *ip++;
|
||||
+ }
|
||||
+ m_pos = op - 1;
|
||||
+ m_pos -= le16_to_cpu(get_unaligned(
|
||||
+ (const unsigned short *)ip)) >> 2;
|
||||
+ ip += 2;
|
||||
+ } else if (t >= 16) {
|
||||
+ m_pos = op;
|
||||
+ m_pos -= (t & 8) << 11;
|
||||
+
|
||||
+ t &= 7;
|
||||
+ if (t == 0) {
|
||||
+ if (HAVE_IP(1, ip_end, ip))
|
||||
+ goto input_overrun;
|
||||
+ while (*ip == 0) {
|
||||
+ t += 255;
|
||||
+ ip++;
|
||||
+ if (HAVE_IP(1, ip_end, ip))
|
||||
+ goto input_overrun;
|
||||
+ }
|
||||
+ t += 7 + *ip++;
|
||||
+ }
|
||||
+ m_pos -= le16_to_cpu(get_unaligned(
|
||||
+ (const unsigned short *)ip)) >> 2;
|
||||
+ ip += 2;
|
||||
+ if (m_pos == op)
|
||||
+ goto eof_found;
|
||||
+ m_pos -= 0x4000;
|
||||
+ } else {
|
||||
+ m_pos = op - 1;
|
||||
+ m_pos -= t >> 2;
|
||||
+ m_pos -= *ip++ << 2;
|
||||
+
|
||||
+ if (HAVE_LB(m_pos, out, op))
|
||||
+ goto lookbehind_overrun;
|
||||
+ if (HAVE_OP(2, op_end, op))
|
||||
+ goto output_overrun;
|
||||
+
|
||||
+ *op++ = *m_pos++;
|
||||
+ *op++ = *m_pos;
|
||||
+ goto match_done;
|
||||
+ }
|
||||
+
|
||||
+ if (HAVE_LB(m_pos, out, op))
|
||||
+ goto lookbehind_overrun;
|
||||
+ if (HAVE_OP(t + 3 - 1, op_end, op))
|
||||
+ goto output_overrun;
|
||||
+
|
||||
+ if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4) {
|
||||
+ COPY4(op, m_pos);
|
||||
+ op += 4;
|
||||
+ m_pos += 4;
|
||||
+ t -= 4 - (3 - 1);
|
||||
+ do {
|
||||
+ COPY4(op, m_pos);
|
||||
+ op += 4;
|
||||
+ m_pos += 4;
|
||||
+ t -= 4;
|
||||
+ } while (t >= 4);
|
||||
+ if (t > 0)
|
||||
+ do {
|
||||
+ *op++ = *m_pos++;
|
||||
+ } while (--t > 0);
|
||||
+ } else {
|
||||
+copy_match:
|
||||
+ *op++ = *m_pos++;
|
||||
+ *op++ = *m_pos++;
|
||||
+ do {
|
||||
+ *op++ = *m_pos++;
|
||||
+ } while (--t > 0);
|
||||
+ }
|
||||
+match_done:
|
||||
+ t = ip[-2] & 3;
|
||||
+ if (t == 0)
|
||||
+ break;
|
||||
+match_next:
|
||||
+ if (HAVE_OP(t, op_end, op))
|
||||
+ goto output_overrun;
|
||||
+ if (HAVE_IP(t + 1, ip_end, ip))
|
||||
+ goto input_overrun;
|
||||
+
|
||||
+ *op++ = *ip++;
|
||||
+ if (t > 1) {
|
||||
+ *op++ = *ip++;
|
||||
+ if (t > 2)
|
||||
+ *op++ = *ip++;
|
||||
+ }
|
||||
+
|
||||
+ t = *ip++;
|
||||
+ } while (ip < ip_end);
|
||||
+ }
|
||||
+
|
||||
+ *out_len = op - out;
|
||||
+ return LZO_E_EOF_NOT_FOUND;
|
||||
+
|
||||
+eof_found:
|
||||
+ *out_len = op - out;
|
||||
+ return (ip == ip_end ? LZO_E_OK :
|
||||
+ (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN));
|
||||
+input_overrun:
|
||||
+ *out_len = op - out;
|
||||
+ return LZO_E_INPUT_OVERRUN;
|
||||
+
|
||||
+output_overrun:
|
||||
+ *out_len = op - out;
|
||||
+ return LZO_E_OUTPUT_OVERRUN;
|
||||
+
|
||||
+lookbehind_overrun:
|
||||
+ *out_len = op - out;
|
||||
+ return LZO_E_LOOKBEHIND_OVERRUN;
|
||||
+}
|
||||
+
|
||||
+EXPORT_SYMBOL_GPL(lzo1x_decompress_safe);
|
||||
+
|
||||
+MODULE_LICENSE("GPL");
|
||||
+MODULE_DESCRIPTION("LZO1X Decompressor");
|
||||
+
|
||||
--- /dev/null
|
||||
+++ b/sub-projects/compression/lzo-kmod/lzodefs.h
|
||||
@@ -0,0 +1,43 @@
|
||||
+/*
|
||||
+ * lzodefs.h -- architecture, OS and compiler specific defines
|
||||
+ *
|
||||
+ * Copyright (C) 1996-2005 Markus F.X.J. Oberhumer <markus@oberhumer.com>
|
||||
+ *
|
||||
+ * The full LZO package can be found at:
|
||||
+ * http://www.oberhumer.com/opensource/lzo/
|
||||
+ *
|
||||
+ * Changed for kernel use by:
|
||||
+ * Nitin Gupta <nitingupta910@gmail.com>
|
||||
+ * Richard Purdie <rpurdie@openedhand.com>
|
||||
+ */
|
||||
+
|
||||
+#define LZO_VERSION 0x2020
|
||||
+#define LZO_VERSION_STRING "2.02"
|
||||
+#define LZO_VERSION_DATE "Oct 17 2005"
|
||||
+
|
||||
+#define M1_MAX_OFFSET 0x0400
|
||||
+#define M2_MAX_OFFSET 0x0800
|
||||
+#define M3_MAX_OFFSET 0x4000
|
||||
+#define M4_MAX_OFFSET 0xbfff
|
||||
+
|
||||
+#define M1_MIN_LEN 2
|
||||
+#define M1_MAX_LEN 2
|
||||
+#define M2_MIN_LEN 3
|
||||
+#define M2_MAX_LEN 8
|
||||
+#define M3_MIN_LEN 3
|
||||
+#define M3_MAX_LEN 33
|
||||
+#define M4_MIN_LEN 3
|
||||
+#define M4_MAX_LEN 9
|
||||
+
|
||||
+#define M1_MARKER 0
|
||||
+#define M2_MARKER 64
|
||||
+#define M3_MARKER 32
|
||||
+#define M4_MARKER 16
|
||||
+
|
||||
+#define D_BITS 14
|
||||
+#define D_MASK ((1u << D_BITS) - 1)
|
||||
+#define D_HIGH ((D_MASK >> 1) + 1)
|
||||
+
|
||||
+#define DX2(p, s1, s2) (((((size_t)((p)[2]) << (s2)) ^ (p)[1]) \
|
||||
+ << (s1)) ^ (p)[0])
|
||||
+#define DX3(p, s1, s2, s3) ((DX2((p)+1, s2, s3) << (s1)) ^ (p)[0])
|
||||
--- /dev/null
|
||||
+++ b/sub-projects/compression/lzo-kmod/lzo.h
|
||||
@@ -0,0 +1,44 @@
|
||||
+#ifndef __LZO_H__
|
||||
+#define __LZO_H__
|
||||
+/*
|
||||
+ * LZO Public Kernel Interface
|
||||
+ * A mini subset of the LZO real-time data compression library
|
||||
+ *
|
||||
+ * Copyright (C) 1996-2005 Markus F.X.J. Oberhumer <markus@oberhumer.com>
|
||||
+ *
|
||||
+ * The full LZO package can be found at:
|
||||
+ * http://www.oberhumer.com/opensource/lzo/
|
||||
+ *
|
||||
+ * Changed for kernel use by:
|
||||
+ * Nitin Gupta <nitingupta910@gmail.com>
|
||||
+ * Richard Purdie <rpurdie@openedhand.com>
|
||||
+ */
|
||||
+
|
||||
+#define LZO1X_MEM_COMPRESS (16384 * sizeof(unsigned char *))
|
||||
+#define LZO1X_1_MEM_COMPRESS LZO1X_MEM_COMPRESS
|
||||
+
|
||||
+#define lzo1x_worst_compress(x) ((x) + ((x) / 16) + 64 + 3)
|
||||
+
|
||||
+/* This requires 'workmem' of size LZO1X_1_MEM_COMPRESS */
|
||||
+int lzo1x_1_compress(const unsigned char *src, size_t src_len,
|
||||
+ unsigned char *dst, size_t *dst_len, void *wrkmem);
|
||||
+
|
||||
+/* safe decompression with overrun testing */
|
||||
+int lzo1x_decompress_safe(const unsigned char *src, size_t src_len,
|
||||
+ unsigned char *dst, size_t *dst_len);
|
||||
+
|
||||
+/*
|
||||
+ * Return values (< 0 = Error)
|
||||
+ */
|
||||
+#define LZO_E_OK 0
|
||||
+#define LZO_E_ERROR (-1)
|
||||
+#define LZO_E_OUT_OF_MEMORY (-2)
|
||||
+#define LZO_E_NOT_COMPRESSIBLE (-3)
|
||||
+#define LZO_E_INPUT_OVERRUN (-4)
|
||||
+#define LZO_E_OUTPUT_OVERRUN (-5)
|
||||
+#define LZO_E_LOOKBEHIND_OVERRUN (-6)
|
||||
+#define LZO_E_EOF_NOT_FOUND (-7)
|
||||
+#define LZO_E_INPUT_NOT_CONSUMED (-8)
|
||||
+#define LZO_E_NOT_YET_IMPLEMENTED (-9)
|
||||
+
|
||||
+#endif
|
||||
--- /dev/null
|
||||
+++ b/sub-projects/compression/lzo-kmod/Makefile
|
||||
@@ -0,0 +1,8 @@
|
||||
+obj-m += lzo1x_compress.o lzo1x_decompress.o
|
||||
+
|
||||
+all:
|
||||
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
|
||||
+
|
||||
+clean:
|
||||
+ make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
|
||||
+
|
||||
181
compcache/patches/001-lzo-speed.patch
Normal file
181
compcache/patches/001-lzo-speed.patch
Normal file
|
|
@ -0,0 +1,181 @@
|
|||
--- a/sub-projects/compression/lzo-kmod/lzo1x_compress.c
|
||||
+++ b/sub-projects/compression/lzo-kmod/lzo1x_compress.c
|
||||
@@ -62,8 +62,12 @@ _lzo1x_1_do_compress(const unsigned char
|
||||
goto literal;
|
||||
|
||||
try_match:
|
||||
+#ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
|
||||
if (get_unaligned((const unsigned short *)m_pos)
|
||||
== get_unaligned((const unsigned short *)ip)) {
|
||||
+#else
|
||||
+ if (m_pos[0] == ip[0] && m_pos[1] == ip[1]) {
|
||||
+#endif
|
||||
if (likely(m_pos[2] == ip[2]))
|
||||
goto match;
|
||||
}
|
||||
@@ -94,9 +98,14 @@ match:
|
||||
}
|
||||
*op++ = tt;
|
||||
}
|
||||
- do {
|
||||
- *op++ = *ii++;
|
||||
- } while (--t > 0);
|
||||
+ if (t >= 2 * 4) {
|
||||
+ memcpy(op, ii, t);
|
||||
+ op += t;
|
||||
+ ii += t;
|
||||
+ } else
|
||||
+ do {
|
||||
+ *op++ = *ii++;
|
||||
+ } while (--t > 0);
|
||||
}
|
||||
|
||||
ip += 3;
|
||||
@@ -208,9 +217,14 @@ int lzo1x_1_compress(const unsigned char
|
||||
|
||||
*op++ = tt;
|
||||
}
|
||||
- do {
|
||||
- *op++ = *ii++;
|
||||
- } while (--t > 0);
|
||||
+ if (t >= 2 * 4) {
|
||||
+ memcpy(op, ii, t);
|
||||
+ op += t;
|
||||
+ ii += t;
|
||||
+ } else
|
||||
+ do {
|
||||
+ *op++ = *ii++;
|
||||
+ } while (--t > 0);
|
||||
}
|
||||
|
||||
*op++ = M4_MARKER | 1;
|
||||
@@ -224,4 +238,3 @@ EXPORT_SYMBOL_GPL(lzo1x_1_compress);
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_DESCRIPTION("LZO1X-1 Compressor");
|
||||
-
|
||||
--- a/sub-projects/compression/lzo-kmod/lzo1x_decompress.c
|
||||
+++ b/sub-projects/compression/lzo-kmod/lzo1x_decompress.c
|
||||
@@ -45,10 +45,7 @@ int lzo1x_decompress_safe(const unsigned
|
||||
goto output_overrun;
|
||||
if (HAVE_IP(t + 1, ip_end, ip))
|
||||
goto input_overrun;
|
||||
- do {
|
||||
- *op++ = *ip++;
|
||||
- } while (--t > 0);
|
||||
- goto first_literal_run;
|
||||
+ goto prep_first_literal_run;
|
||||
}
|
||||
|
||||
while ((ip < ip_end)) {
|
||||
@@ -71,30 +68,27 @@ int lzo1x_decompress_safe(const unsigned
|
||||
if (HAVE_IP(t + 4, ip_end, ip))
|
||||
goto input_overrun;
|
||||
|
||||
- COPY4(op, ip);
|
||||
- op += 4;
|
||||
- ip += 4;
|
||||
- if (--t > 0) {
|
||||
- if (t >= 4) {
|
||||
- do {
|
||||
- COPY4(op, ip);
|
||||
- op += 4;
|
||||
- ip += 4;
|
||||
- t -= 4;
|
||||
- } while (t >= 4);
|
||||
- if (t > 0) {
|
||||
- do {
|
||||
- *op++ = *ip++;
|
||||
- } while (--t > 0);
|
||||
- }
|
||||
- } else {
|
||||
+ t += (4 - 1);
|
||||
+ if (t >= 2 * 4) {
|
||||
+ memcpy(op, ip, t);
|
||||
+ op += t;
|
||||
+ ip += t;
|
||||
+ } else {
|
||||
+ do {
|
||||
+ COPY4(op, ip);
|
||||
+ op += 4;
|
||||
+ ip += 4;
|
||||
+ t -= 4;
|
||||
+ } while (t >= 4);
|
||||
+ if (t > 0) {
|
||||
+prep_first_literal_run:
|
||||
do {
|
||||
*op++ = *ip++;
|
||||
} while (--t > 0);
|
||||
}
|
||||
}
|
||||
|
||||
-first_literal_run:
|
||||
+//first_literal_run:
|
||||
t = *ip++;
|
||||
if (t >= 16)
|
||||
goto match;
|
||||
@@ -139,8 +133,7 @@ match:
|
||||
t += 31 + *ip++;
|
||||
}
|
||||
m_pos = op - 1;
|
||||
- m_pos -= le16_to_cpu(get_unaligned(
|
||||
- (const unsigned short *)ip)) >> 2;
|
||||
+ m_pos -= get_unaligned_le16(ip) >> 2;
|
||||
ip += 2;
|
||||
} else if (t >= 16) {
|
||||
m_pos = op;
|
||||
@@ -158,8 +151,7 @@ match:
|
||||
}
|
||||
t += 7 + *ip++;
|
||||
}
|
||||
- m_pos -= le16_to_cpu(get_unaligned(
|
||||
- (const unsigned short *)ip)) >> 2;
|
||||
+ m_pos -= get_unaligned_le16(ip) >> 2;
|
||||
ip += 2;
|
||||
if (m_pos == op)
|
||||
goto eof_found;
|
||||
@@ -184,21 +176,33 @@ match:
|
||||
if (HAVE_OP(t + 3 - 1, op_end, op))
|
||||
goto output_overrun;
|
||||
|
||||
- if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4) {
|
||||
- COPY4(op, m_pos);
|
||||
- op += 4;
|
||||
- m_pos += 4;
|
||||
- t -= 4 - (3 - 1);
|
||||
- do {
|
||||
+ if (t >= 2 * 4 - (3 - 1)) {
|
||||
+ /*
|
||||
+ * Assume memcpy don't copy
|
||||
+ * more than 32 bytes at once
|
||||
+ */
|
||||
+ if ((op - m_pos) >= 32) {
|
||||
+ t += (3 - 1);
|
||||
+ memcpy(op, m_pos, t);
|
||||
+ op += t;
|
||||
+ m_pos += t;
|
||||
+ } else if ((op - m_pos) >= 4) {
|
||||
COPY4(op, m_pos);
|
||||
op += 4;
|
||||
m_pos += 4;
|
||||
- t -= 4;
|
||||
- } while (t >= 4);
|
||||
- if (t > 0)
|
||||
+ t -= 4 - (3 - 1);
|
||||
do {
|
||||
- *op++ = *m_pos++;
|
||||
- } while (--t > 0);
|
||||
+ COPY4(op, m_pos);
|
||||
+ op += 4;
|
||||
+ m_pos += 4;
|
||||
+ t -= 4;
|
||||
+ } while (t >= 4);
|
||||
+ if (t > 0)
|
||||
+ do {
|
||||
+ *op++ = *m_pos++;
|
||||
+ } while (--t > 0);
|
||||
+ } else
|
||||
+ goto copy_match;
|
||||
} else {
|
||||
copy_match:
|
||||
*op++ = *m_pos++;
|
||||
10
compcache/patches/002-kernel-2.6.34-compat.patch
Normal file
10
compcache/patches/002-kernel-2.6.34-compat.patch
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
--- a/ramzswap_drv.c
|
||||
+++ b/ramzswap_drv.c
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <linux/device.h>
|
||||
#include <linux/genhd.h>
|
||||
#include <linux/highmem.h>
|
||||
+#include <linux/slab.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/swap.h>
|
||||
#include <linux/swapops.h>
|
||||
31
compcache/patches/003-kernel-3.x-compat.patch
Normal file
31
compcache/patches/003-kernel-3.x-compat.patch
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
Index: compcache-0.6.2/ramzswap_drv.c
|
||||
===================================================================
|
||||
--- compcache-0.6.2.orig/ramzswap_drv.c 2012-07-25 01:02:39.000000000 +0200
|
||||
+++ compcache-0.6.2/ramzswap_drv.c 2012-07-25 01:04:29.270750850 +0200
|
||||
@@ -525,7 +525,7 @@
|
||||
|
||||
if (S_ISBLK(inode->i_mode)) {
|
||||
bdev = I_BDEV(inode);
|
||||
- ret = bd_claim(bdev, setup_backing_swap);
|
||||
+ ret = blkdev_get(bdev, FMODE_READ | FMODE_WRITE | FMODE_EXCL, setup_backing_swap);
|
||||
if (ret < 0) {
|
||||
bdev = NULL;
|
||||
goto bad_param;
|
||||
@@ -557,7 +557,7 @@
|
||||
|
||||
bad_param:
|
||||
if (bdev)
|
||||
- bd_release(bdev);
|
||||
+ blkdev_put(bdev, FMODE_READ | FMODE_WRITE | FMODE_EXCL);
|
||||
filp_close(swap_file, NULL);
|
||||
|
||||
out:
|
||||
@@ -1097,7 +1097,7 @@
|
||||
/* Close backing swap device, if present */
|
||||
if (rzs->backing_swap) {
|
||||
if (is_backing_blkdev)
|
||||
- bd_release(rzs->backing_swap);
|
||||
+ blkdev_put(rzs->backing_swap, FMODE_READ | FMODE_WRITE | FMODE_EXCL);
|
||||
filp_close(rzs->swap_file, NULL);
|
||||
rzs->backing_swap = NULL;
|
||||
memset(rzs->backing_swap_name, 0, MAX_SWAP_NAME_LEN);
|
||||
74
crda/Makefile
Normal file
74
crda/Makefile
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
#
|
||||
# Copyright (C) 2009-2012 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_NAME:=crda
|
||||
PKG_RELEASE:=1
|
||||
PKG_VERSION:=1.1.2
|
||||
PKG_SOURCE_URL:=http://wireless.kernel.org/download/crda
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
|
||||
PKG_MD5SUM:=5226f65aebacf94baaf820f8b4e06df4
|
||||
|
||||
PKG_REGULATORY_NAME:=regulatory
|
||||
PKG_REGULATORY_VERSION:=2011.04.28
|
||||
PKG_REGULATORY_SOURCE_URL:=http://wireless.kernel.org/download/wireless-regdb/regulatory.bins
|
||||
PKG_REGULATORY_SOURCE:=$(PKG_REGULATORY_VERSION)-$(PKG_REGULATORY_NAME).bin
|
||||
PKG_REGULATORY_MD5SUM:=1535e98bcaba732e2f8e8f62dac6f369
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/crda
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=Central Regulatory Domain Agent (CRDA)
|
||||
DEPENDS:=+libnl-tiny
|
||||
URL:=http://wireless.kernel.org/en/developers/Regulatory/CRDA
|
||||
endef
|
||||
|
||||
define Download/wireless-regdb
|
||||
FILE:=$(PKG_REGULATORY_SOURCE)
|
||||
URL:=$(PKG_REGULATORY_SOURCE_URL)
|
||||
VERSION:=$(PKG_REGULATORY_VERSION)
|
||||
MD5SUM:=$(PKG_REGULATORY_MD5SUM)
|
||||
endef
|
||||
$(eval $(call Download,wireless-regdb))
|
||||
|
||||
define Package/crda/description
|
||||
This is the Central Regulatory Domain Agent for Linux. It serves one
|
||||
purpose: tell Linux kernel what to enforce. In essence it is a udev
|
||||
helper for communication between the kernel and userspace. You only
|
||||
need to run this manually for debugging purposes. For manual changing
|
||||
of regulatory domains use iw (iw reg set) or wpa_supplicant (feature
|
||||
yet to be added).
|
||||
endef
|
||||
|
||||
TARGET_CPPFLAGS := \
|
||||
-I$(STAGING_DIR)/usr/include/libnl-tiny \
|
||||
-D_GNU_SOURCE \
|
||||
$(TARGET_CPPFLAGS)
|
||||
|
||||
MAKE_FLAGS += \
|
||||
NL1FOUND="" NL2FOUND=Y \
|
||||
NLLIBNAME="libnl-tiny" \
|
||||
NLLIBS="-lnl-tiny -lm" \
|
||||
REG_BIN="$(DL_DIR)/$(PKG_REGULATORY_SOURCE)" \
|
||||
crda
|
||||
|
||||
define Package/crda/install
|
||||
$(INSTALL_DIR) $(1)/sbin
|
||||
$(INSTALL_DIR) $(1)/etc/hotplug.d
|
||||
$(INSTALL_DIR) $(1)/etc/hotplug.d/platform
|
||||
$(INSTALL_DIR) $(1)/usr/lib/crda
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/crda $(1)/sbin/
|
||||
$(INSTALL_DATA) ./files/hotplug.rule $(1)/etc/hotplug.d/platform/10-regulatory
|
||||
$(INSTALL_DATA) $(DL_DIR)/$(PKG_REGULATORY_SOURCE) $(1)/usr/lib/crda/regulatory.bin
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,crda))
|
||||
|
||||
6
crda/files/hotplug.rule
Normal file
6
crda/files/hotplug.rule
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#!/bin/sh
|
||||
# Copyright (C) 2009 OpenWrt.org
|
||||
|
||||
[ change = "$ACTION" -a regulatory.0 = "$DEVICENAME" ] && {
|
||||
/sbin/crda
|
||||
}
|
||||
13
crda/patches/101-make_crypto_use_optional.patch
Normal file
13
crda/patches/101-make_crypto_use_optional.patch
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -35,7 +35,9 @@ LDLIBS += `pkg-config --libs openssl`
|
||||
|
||||
reglib.o: keys-ssl.c
|
||||
|
||||
-else
|
||||
+endif
|
||||
+
|
||||
+ifeq ($(USE_GCRYPT),1)
|
||||
CFLAGS += -DUSE_GCRYPT
|
||||
LDLIBS += -lgcrypt
|
||||
|
||||
58
dahdi/Makefile
Normal file
58
dahdi/Makefile
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
#
|
||||
# Copyright (C) 2006-2008 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:=dahdi
|
||||
PKG_VERSION:=2.9.1
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=git@iopsys.inteno.se:dahdi
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_VERSION:=HEAD
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(INCLUDE_DIR)/image.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
|
||||
|
||||
BCM_KERNEL_VERSION=`cat $(BUILD_DIR)/bcmkernel/bcm963xx/kernel/linux-*/include/config/kernel.release`
|
||||
|
||||
export BUILD_DIR
|
||||
export BCM_KERNEL_VERSION
|
||||
|
||||
|
||||
define Package/dahdi
|
||||
SECTION:=net
|
||||
CATEGORY:=Base system
|
||||
TITLE:=Kernel timer for Asterisk meetme
|
||||
URL:=
|
||||
DEPENDS:= +bcmkernel
|
||||
endef
|
||||
|
||||
define Package/dahdi/description
|
||||
Kernel timer for Asterisk meetme
|
||||
endef
|
||||
|
||||
|
||||
define Package/dahdi/install
|
||||
|
||||
# install header files
|
||||
$(INSTALL_DIR) $(STAGING_DIR)/usr/include/dahdi
|
||||
$(CP) -r $(PKG_BUILD_DIR)/linux/include/dahdi/* $(STAGING_DIR)/usr/include/dahdi
|
||||
|
||||
mkdir -p $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra/
|
||||
$(CP) $(PKG_BUILD_DIR)/linux/drivers/dahdi/dahdi.ko $(1)/lib/modules/$(BCM_KERNEL_VERSION)/extra/
|
||||
|
||||
mkdir -p $(1)/etc/modules.d/
|
||||
$(CP) etc/modules.d/90-dahdi $(1)/etc/modules.d/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,dahdi))
|
||||
1
dahdi/etc/modules.d/90-dahdi
Normal file
1
dahdi/etc/modules.d/90-dahdi
Normal file
|
|
@ -0,0 +1 @@
|
|||
dahdi
|
||||
70
dectmngr/Makefile
Normal file
70
dectmngr/Makefile
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
#
|
||||
# Copyright (C) 2006-2010 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_RELEASE:=1
|
||||
PKG_VERSION:=1.0.23
|
||||
ifeq ($(CONFIG_PACKAGE_bcmkernel),y)
|
||||
PKG_SOURCE_URL:=git@iopsys.inteno.se:dectmngr.git
|
||||
else
|
||||
PKG_SOURCE_URL:=http://ihgsp.inteno.se/git/dectmngr.git
|
||||
endif
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_VERSION:=5f6f0608b59484d76c6331279cc50104be5d8a95
|
||||
PKG_NAME:=dectmngr
|
||||
|
||||
|
||||
LDFLAGS+= \
|
||||
-Wl,-rpath-link=$(STAGING_DIR)/usr/lib \
|
||||
-Wl,-rpath-link=$(STAGING_DIR)/lib
|
||||
|
||||
RSTRIP:=true
|
||||
export BUILD_DIR
|
||||
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/dectmngr
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=Broadcom endpoint test application
|
||||
URL:=
|
||||
DEPENDS:= +libevent2 +libjson +natalie-dect-h +bcmkernel
|
||||
endef
|
||||
|
||||
define Package/dectmngr/description
|
||||
Dect proxy, manager and tools
|
||||
endef
|
||||
|
||||
|
||||
define Package/dectmngr/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_DIR) $(1)/sbin
|
||||
$(INSTALL_DIR) $(1)/etc/hotplug.d/
|
||||
$(INSTALL_DIR) $(1)/etc/hotplug.d/dect
|
||||
$(INSTALL_DIR) $(1)/etc/init.d/
|
||||
$(INSTALL_DIR) $(1)/etc/dect/
|
||||
$(INSTALL_DIR) $(1)/etc/config/
|
||||
|
||||
cp $(PKG_BUILD_DIR)/dectmngr $(1)/usr/bin/
|
||||
cp $(PKG_BUILD_DIR)/atohx $(1)/usr/bin/
|
||||
cp $(PKG_BUILD_DIR)/dectproxy $(1)/usr/bin/
|
||||
cp $(PKG_BUILD_DIR)/dectdbgd $(1)/usr/bin/
|
||||
cp $(PKG_BUILD_DIR)/dect $(1)/usr/bin/
|
||||
cp $(PKG_BUILD_DIR)/dectcalib $(1)/usr/bin/
|
||||
cp $(PKG_BUILD_DIR)/dect_testmode $(1)/usr/bin/
|
||||
cp files/etc/init.d/* $(1)/etc/init.d/
|
||||
cp files/etc/hotplug.d/dect/* $(1)/etc/hotplug.d/dect/
|
||||
cp files/etc/dect/* $(1)/etc/dect/
|
||||
cp files/etc/config/* $(1)/etc/config/
|
||||
cp files/sbin/dectreg $(1)/sbin/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,dectmngr))
|
||||
BIN
dectmngr/files/etc/dect/nvs_default
Normal file
BIN
dectmngr/files/etc/dect/nvs_default
Normal file
Binary file not shown.
15
dectmngr/files/etc/hotplug.d/dect/00-dectstate
Normal file
15
dectmngr/files/etc/hotplug.d/dect/00-dectstate
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#!/bin/sh
|
||||
|
||||
if [ "$ACTION" == "led_blink" ]; then
|
||||
ubus call led.dect set '{"state":"notice"}'
|
||||
fi
|
||||
|
||||
if [ "$ACTION" == "led_on" ]; then
|
||||
ubus call led.dect set '{"state":"ok"}'
|
||||
fi
|
||||
|
||||
if [ "$ACTION" == "led_off" ]; then
|
||||
ubus call led.dect set '{"state":"off"}'
|
||||
fi
|
||||
|
||||
|
||||
46
dectmngr/files/etc/init.d/dect
Executable file
46
dectmngr/files/etc/init.d/dect
Executable file
|
|
@ -0,0 +1,46 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2008 OpenWrt.org
|
||||
START=97
|
||||
STOP=10
|
||||
|
||||
DEST=
|
||||
DEFAULT=
|
||||
OPTIONS=""
|
||||
|
||||
|
||||
start() {
|
||||
# avoid fp timing problem
|
||||
echo 1 > /proc/sys/kernel/printk_with_interrupt_enabled
|
||||
|
||||
# setup board specific dect parameters
|
||||
cat /proc/nvram/rfpi | tr -d ' ' | atohx > /tmp/rfpi
|
||||
cat /proc/nvram/fixed_emc | tr -d ' ' | atohx > /tmp/fixed_emc
|
||||
cat /proc/nvram/bcm_def_freq | tr -d ' ' | atohx > /tmp/bcm_def_freq
|
||||
|
||||
if [ ! -f /etc/dect/nvs ]; then
|
||||
cp /etc/dect/nvs_default /etc/dect/nvs
|
||||
dd of=/etc/dect/nvs if=/tmp/rfpi conv=notrunc bs=1 seek=0
|
||||
dd of=/etc/dect/nvs if=/tmp/fixed_emc conv=notrunc bs=1 seek=10
|
||||
dd of=/etc/dect/nvs if=/tmp/bcm_def_freq conv=notrunc bs=1 seek=6
|
||||
fi
|
||||
|
||||
# init dectproxy
|
||||
dectproxy > /dev/null 2>&1 &
|
||||
dectmngr > /tmp/dectmngr 2>&1 &
|
||||
}
|
||||
|
||||
stop() {
|
||||
killall -9 dectproxy
|
||||
killall -9 dectmngr
|
||||
}
|
||||
|
||||
restart() {
|
||||
echo "restarting dect"
|
||||
killall dectmngr
|
||||
dectmngr > /tmp/dectmngr 2>&1 &
|
||||
}
|
||||
|
||||
reload() {
|
||||
# reload config
|
||||
dect -c
|
||||
}
|
||||
17
dectmngr/files/sbin/dectreg
Executable file
17
dectmngr/files/sbin/dectreg
Executable file
|
|
@ -0,0 +1,17 @@
|
|||
#!/bin/sh
|
||||
|
||||
# This script is likely not used. Just exit with
|
||||
# an error and see if someone screems... If not,
|
||||
# we can delete this file.
|
||||
exit 1
|
||||
|
||||
|
||||
[ -f /var/dectisregistering ] || {
|
||||
touch /var/dectisregistering 2>/dev/null
|
||||
/usr/bin/dectmngr -r
|
||||
ubus call led.dect set '{"state" : "notice"}'
|
||||
sleep 20
|
||||
rm /var/dectisregistering 2>/dev/null
|
||||
/usr/bin/dectmngr -s
|
||||
ubus call led.dect set '{"state" : "ok"}'
|
||||
}
|
||||
73
endptcfg/Makefile
Normal file
73
endptcfg/Makefile
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
#
|
||||
# Copyright (C) 2006-2010 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=endptcfg
|
||||
PKG_VERSION:=0.1
|
||||
PKG_RELEASE:=1
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=git@iopsys.inteno.se:endptcfg
|
||||
PKG_SOURCE_VERSION:=e6c70fe1284568474019bb4a2526043c49b57ec3
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
|
||||
LDFLAGS+= \
|
||||
-Wl,-rpath-link=$(STAGING_DIR)/usr/lib \
|
||||
-Wl,-rpath-link=$(STAGING_DIR)/lib
|
||||
|
||||
BCMKERNEL_DIR:=$(BUILD_DIR)/bcmkernel/bcm963xx
|
||||
export BCMKERNEL_DIR
|
||||
|
||||
TARGET_LDFLAGS += $(BCMKERNEL_DIR)/userspace/private/apps/vodsl/telephonyProfiles/telephonyProfiles.o \
|
||||
$(BCMKERNEL_DIR)/userspace/private/apps/vodsl/voip/util/log/vodslLog.o \
|
||||
$(BCMKERNEL_DIR)/userspace/private/apps/vodsl/endpoint/endpoint_user.o \
|
||||
$(BCMKERNEL_DIR)/userspace/private/apps/vodsl/bos/bos.o \
|
||||
-lpthread
|
||||
|
||||
RSTRIP:=true
|
||||
export BUILD_DIR
|
||||
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/endptcfg
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=Broadcom endpoint driver configuration application
|
||||
URL:=
|
||||
DEPENDS:=+libpthread +bcmkernel
|
||||
endef
|
||||
|
||||
define Package/endptcfg/description
|
||||
Broadcom endpoint driver configuration application
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
$(MAKE) -C $(PKG_BUILD_DIR) \
|
||||
$(TARGET_CONFIGURE_OPTS) LINUX_DIR=$(LINUX_DIR) LDFLAGS="$(TARGET_LDFLAGS)" CFLAGS="$(TARGET_CFLAGS) \
|
||||
-I$(LINUX_DIR)/include \
|
||||
-I$(STAGING_DIR)/usr/include \
|
||||
-DRS_ENDIAN_TYPE=RS_BIG_ENDIAN \
|
||||
-DBOS_OS_LINUXUSER -DBOS_CFG_TIME \
|
||||
-I$(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/broadcom/include/bcm963xx \
|
||||
-I$(STAGING_DIR)/usr/include/bcm963xx/bcmdrivers/opensource/include/bcm963xx \
|
||||
-I$(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/endpt/inc \
|
||||
-I$(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/inc \
|
||||
-I$(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/codec \
|
||||
-I$(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/publicInc \
|
||||
-I$(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/voice_res_gw/casCtl/inc \
|
||||
-I$(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_drivers/inc \
|
||||
-I$(STAGING_DIR)/usr/include/bcm963xx/userspace/private/apps/vodsl/voip/inc \
|
||||
-I$(STAGING_DIR)/usr/include/bcm963xx/xChange/dslx_common/xchg_common/bos/LinuxUser"
|
||||
endef
|
||||
|
||||
define Package/endptcfg/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
cp $(PKG_BUILD_DIR)/endptcfg $(1)/usr/bin/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,endptcfg))
|
||||
49
endptctl/Makefile
Normal file
49
endptctl/Makefile
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
#
|
||||
# Copyright (C) 2006-2010 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_RELEASE:=1
|
||||
PKG_VERSION:=benjamin
|
||||
PKG_SOURCE_URL:=ssh://inteno@ihgsp.inteno.se/home/inteno/private/git/$(PKG_VERSION)/endptctl.git
|
||||
|
||||
PKG_NAME:=endptctl
|
||||
PKG_VERSION:=0.1
|
||||
|
||||
LDFLAGS+= \
|
||||
-Wl,-rpath-link=$(STAGING_DIR)/usr/lib \
|
||||
-Wl,-rpath-link=$(STAGING_DIR)/lib
|
||||
|
||||
RSTRIP:=true
|
||||
export BUILD_DIR
|
||||
|
||||
BCMKERNEL_DIR:=$(BUILD_DIR)/bcmkernel-3.4-4.14/bcm963xx
|
||||
export BCMKERNEL_DIR
|
||||
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/endptctl
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=Broadcom endpoint test application
|
||||
URL:=
|
||||
endef
|
||||
|
||||
define Package/endptctl/description
|
||||
Broadcom endpoint test application
|
||||
endef
|
||||
|
||||
|
||||
define Package/endptctl/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
cp $(PKG_BUILD_DIR)/endptctl $(1)/usr/bin/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,endptctl))
|
||||
26
freecwmp/Config.in
Normal file
26
freecwmp/Config.in
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
if PACKAGE_cwmp-curl || PACKAGE_cwmp-zstream
|
||||
|
||||
config CWMP_SCRIPTS_FULL
|
||||
bool "Install all cwmp scripts"
|
||||
default y
|
||||
|
||||
choice
|
||||
prompt "Select ACS sever"
|
||||
default CWMP_ACS_MULTI
|
||||
|
||||
config CWMP_ACS_MULTI
|
||||
bool "No specific ACS, follow standard"
|
||||
|
||||
config CWMP_ACS_HDM
|
||||
bool "HDM"
|
||||
endchoice
|
||||
|
||||
config CWMP_DEBUG
|
||||
bool "Compile with debug options"
|
||||
default y
|
||||
|
||||
config CWMP_DEVEL_DEBUG
|
||||
bool "Compile with development debug options"
|
||||
default n
|
||||
|
||||
endif
|
||||
169
freecwmp/Makefile
Normal file
169
freecwmp/Makefile
Normal file
|
|
@ -0,0 +1,169 @@
|
|||
#
|
||||
# Copyright (C) 2012 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=cwmp
|
||||
PKG_VERSION:=2.3-2015-06-05
|
||||
PKG_FIXUP:=autoreconf
|
||||
ifeq ($(CONFIG_PACKAGE_bcmkernel),y)
|
||||
PKG_SOURCE_URL:=ssh://git@iopsys.inteno.se/freecwmp.git
|
||||
else
|
||||
PKG_SOURCE_URL:=http://ihgsp.inteno.se/git/freecwmp.git
|
||||
endif
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_VERSION:=ec1e8dbf6b2e90b014ece01bc371baff602a0a6f
|
||||
PKG_RELEASE=$(PKG_SOURCE_VERSION)
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
|
||||
PKG_CONFIG_DEPENDS:= \
|
||||
CONFIG_CWMP_ACS_MULTI \
|
||||
CONFIG_CWMP_ACS_HDM \
|
||||
CONFIG_CWMP_DEBUG \
|
||||
CONFIG_CWMP_DEVEL_DEBUG
|
||||
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
CWMP_REVISION=$(shell svnversion ./src/ -n|cut -f2 -d:)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/cwmp/Default
|
||||
SECTION:=utils
|
||||
CATEGORY:=Utilities
|
||||
TITLE:=CWMP client
|
||||
DEPENDS:=+libuci +libmicroxml +libubox +libjson +jshn +libubus +libblobmsg-json +ubusd +shflags +getopt
|
||||
endef
|
||||
|
||||
define Package/cwmp/description
|
||||
A free client implementation of CWMP (TR-069) protocol
|
||||
endef
|
||||
|
||||
define Package/cwmp-curl
|
||||
$(call Package/cwmp/Default)
|
||||
TITLE+= (using libcurl)
|
||||
DEPENDS+= +libcurl
|
||||
VARIANT:=curl
|
||||
endef
|
||||
|
||||
define Package/cwmp-zstream
|
||||
$(call Package/cwmp/Default)
|
||||
TITLE+= (using libzstream)
|
||||
DEPENDS+= +libzstream
|
||||
VARIANT:=zstream
|
||||
endef
|
||||
|
||||
define Package/cwmp-zstream/config
|
||||
source "$(SOURCE)/Config.in"
|
||||
endef
|
||||
|
||||
USE_LOCAL=$(shell ls ./src/ 2>/dev/null >/dev/null && echo 1)
|
||||
ifneq ($(USE_LOCAL),)
|
||||
define Build/Prepare
|
||||
$(CP) ./src/* $(PKG_BUILD_DIR)/
|
||||
endef
|
||||
endif
|
||||
|
||||
TARGET_CFLAGS += \
|
||||
-D_GNU_SOURCE -D_AADJ
|
||||
|
||||
ifneq ($(CWMP_REVISION)_,_)
|
||||
ifneq ($(CWMP_REVISION),exported)
|
||||
ifneq ($(CWMP_REVISION),Unversioned directory)
|
||||
TARGET_CFLAGS += "-DCWMP_REVISION=\\\"$(CWMP_REVISION)\\\""
|
||||
TARGET_LDFLAGS += "-DCWMP_REVISION=\\\"$(CWMP_REVISION)\\\""
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
TARGET_LDFLAGS += \
|
||||
-Wl,-rpath-link=$(STAGING_DIR)/usr/lib
|
||||
|
||||
CONFIGURE_ARGS += \
|
||||
--with-uci-include-path=$(STAGING_DIR)/usr/include \
|
||||
--with-libubox-include-path=$(STAGING_DIR)/usr/include \
|
||||
--with-libubus-include-path=$(STAGING_DIR)/usr/include
|
||||
|
||||
ifeq ($(BUILD_VARIANT),zstream)
|
||||
CONFIGURE_ARGS += \
|
||||
--enable-http=zstream \
|
||||
--with-zstream-include-path=$(STAGING_DIR)/usr/include
|
||||
endif
|
||||
|
||||
ifeq ($(BUILD_VARIANT),curl)
|
||||
CONFIGURE_ARGS += \
|
||||
--enable-http=curl
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_CWMP_ACS_MULTI),y)
|
||||
CONFIGURE_ARGS += \
|
||||
--enable-acs=multi
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_CWMP_ACS_HDM),y)
|
||||
CONFIGURE_ARGS += \
|
||||
--enable-acs=hdm
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_CWMP_DEBUG),y)
|
||||
CONFIGURE_ARGS += \
|
||||
--enable-debug
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_CWMP_DEVEL_DEBUG),y)
|
||||
CONFIGURE_ARGS += \
|
||||
--enable-devel
|
||||
endif
|
||||
|
||||
define Package/cwmp-$(BUILD_VARIANT)/install
|
||||
$(INSTALL_DIR) $(1)/etc/cwmpd
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(CP) $(PKG_BUILD_DIR)/bin/cwmpd $(1)/usr/sbin
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_CONF) $(PKG_BUILD_DIR)/config/cwmp $(1)/etc/config
|
||||
$(INSTALL_CONF) $(PKG_BUILD_DIR)/config/dmmap $(1)/etc/config
|
||||
$(INSTALL_CONF) $(PKG_BUILD_DIR)/config/firewall.cwmp $(1)/etc/firewall.cwmp
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_DIR) $(1)/etc/uci-defaults
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/init/cwmpd.init $(1)/etc/init.d/cwmpd
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/uci-defaults/90-cwmpfirewall $(1)/etc/uci-defaults/90-cwmpfirewall
|
||||
ifeq ($(CONFIG_CWMP_SCRIPTS_FULL),y)
|
||||
$(INSTALL_DIR) $(1)/usr/share/freecwmp
|
||||
$(CP) $(PKG_BUILD_DIR)/scripts/defaults $(1)/usr/share/freecwmp
|
||||
$(CP) $(PKG_BUILD_DIR)/scripts/functions $(1)/usr/share/freecwmp
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/scripts/cwmpcache.sh $(1)/usr/sbin/cwmpcache
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/scripts/freecwmp.sh $(1)/usr/sbin/freecwmp
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/scripts/wepkeygen $(1)/usr/sbin/wepkeygen
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/scripts/watchcwmpd.sh $(1)/usr/sbin/watchcwmpd
|
||||
endif
|
||||
endef
|
||||
|
||||
define Package/cwmp-$(BUILD_VARIANT)/postinst
|
||||
#!/bin/sh
|
||||
echo "$(CWMP_BKP_FILE)" >> $${IPKG_INSTROOT}/etc/sysupgrade.conf
|
||||
if [ -z "$${IPKG_INSTROOT}" ]; then
|
||||
echo "Enabling rc.d symlink for cwmpd"
|
||||
/etc/init.d/cwmpd enable
|
||||
fi
|
||||
exit 0
|
||||
endef
|
||||
|
||||
define Package/cwmp-$(BUILD_VARIANT)/prerm
|
||||
#!/bin/sh
|
||||
if [ -z "$${IPKG_INSTROOT}" ]; then
|
||||
echo "Disabling rc.d symlink for cwmpd"
|
||||
/etc/init.d/cwmpd disable
|
||||
fi
|
||||
exit 0
|
||||
endef
|
||||
|
||||
|
||||
$(eval $(call BuildPackage,cwmp-curl))
|
||||
$(eval $(call BuildPackage,cwmp-zstream))
|
||||
136
freecwmp/README
Normal file
136
freecwmp/README
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
1)Build
|
||||
Requirements :
|
||||
librairies:
|
||||
- libuci.so
|
||||
- libexpat.so
|
||||
- libcurl.so
|
||||
- libpthread.so
|
||||
- libopenssl.so
|
||||
- libz.so
|
||||
- libcrypto.so
|
||||
the librairies should be present in the "staging_dir/target-i386_uClibc-0.9.30.1/usr/lib/" or "staging_dir/toolchain-mips_gcc-4.3.3+cs_uClibc-0.9.30.1/usr/lib"
|
||||
|
||||
header files and folders:
|
||||
- expat.h
|
||||
- expat_external.h
|
||||
- uci.h
|
||||
- uci_config.h
|
||||
- zlib.h
|
||||
- curl folder
|
||||
- openssl folder
|
||||
the header files and folders should be present in the staging_dir/target-i386_uClibc-0.9.30.1/usr/include/ or staging_dir/toolchain-i386_gcc-4.1.2_uClibc-0.9.30.1/usr/include/
|
||||
|
||||
|
||||
if a librairie doesn't exist:
|
||||
a- run make menuconfig and select the librarie
|
||||
b- build the librarie package
|
||||
|
||||
2) Build
|
||||
|
||||
this software is composed of 3 packages:
|
||||
- cwmpd package: contains cwmpd daemon
|
||||
- cwmp lib package: contains cwmplib and contains cwmp_value_change binary. They could be used by other user space applications in order to notify the cwmp daemon when paramter changes
|
||||
- cwmp kernel package: contains cwmp kernel module. This module could be used by other kernel modules to notify the cwmpd daemon when kernel parameter changes
|
||||
|
||||
The three packages should be selected in the make menu config in order to get the three packages compiled.
|
||||
To compile the three packages: $ make package/cwmpd/compile
|
||||
|
||||
3) OpenWRT settings
|
||||
in the OpenWRT, Add the following lines in the /usr/share/udhcpc/default.script file:
|
||||
uci_set_state provisioning iup tr069url "$url"
|
||||
uci_set_state provisioning iup provisioningcode "$provisioningcode"
|
||||
|
||||
4) Run
|
||||
Requirements:
|
||||
- libuci package should be installed
|
||||
- libexpat package should be installed
|
||||
- libcurl package should be installed
|
||||
- libpthread package should be installed
|
||||
- libopenssl package should be installed
|
||||
- libz package should be installed
|
||||
- libcrypto package should be installed
|
||||
|
||||
Configure the acs url in the /etc/config/cwmp
|
||||
and then start the cwmpd service: /etc/init.d/cwmpd start
|
||||
for the help: /etc/init.d/cwmpd
|
||||
|
||||
5) Value Change
|
||||
|
||||
5.1) value change for user space applications (using the libcwmp)
|
||||
|
||||
Before using the libcwmp, we should check that the libcwmp package is selected in "make menu config". and we should check that the package is compiled.
|
||||
The libcwmp should be installed uin the OpenWRT firmware
|
||||
|
||||
example of using libcwmp
|
||||
in myapplication.c
|
||||
|
||||
#...
|
||||
#include <cwmp_lib.h>
|
||||
#...
|
||||
|
||||
int anyfunction ()
|
||||
{
|
||||
.....
|
||||
/* parameter change here */
|
||||
/* so we inform the cwmp: */
|
||||
lib_api_cwmp_value_change_call (3, "InternetGatewayDevice.LANDevice.{i}.LANHostConfigManagement.IPInterface.{i}.IPInterfaceIPAddress","lan2","3");
|
||||
.....
|
||||
/*
|
||||
Description of lib_api_cwmp_value_change_call input parameters
|
||||
parameter 1 : is the number of input string in the function lib_api_cwmp_value_change_call
|
||||
parameter 2 : is the parameter path
|
||||
parameter 3 : is the first correspondence related to the first indice
|
||||
parameter 4 : is the second correspondence related to the second indice
|
||||
.
|
||||
.
|
||||
.
|
||||
parameter n : is the (n-2) correspondence related to the (n-2) indice
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
5.2) value change for user space applications (using the cwmp_value_change CLI)
|
||||
|
||||
Before using the libcwmp, we should check that the libcwmp package is selected in "make menu config". and we should check that the package is compiled.
|
||||
The libcwmp should be installed uin the OpenWRT firmware
|
||||
|
||||
in OpenWRT:
|
||||
|
||||
root@OpenWrt:~# cwmp_value_change InternetGatewayDevice.LANDevice.{i}.LANHostConfigManagement.IPInterface.{i}.IPInterfaceIPAddress "lan2" "3"
|
||||
|
||||
in this case the command will force cwmp client to send a notification to the ACS (if and only if the parameter path as configured as active or as passive parameter using the setAttributeParameter method)
|
||||
|
||||
5.3) value change for kernel space modules
|
||||
Before using the cwmp kernel module for value change, we should check that the kernel module package is selected in "make menu config". and we should check that the package is compiled.
|
||||
The kernel module should be installed uin the OpenWRT firmware and should be insert before all other kernel modules
|
||||
|
||||
example of using cwmp kernel module
|
||||
in mykernelmodule.c
|
||||
|
||||
#...
|
||||
#include <linux/cwmp_kernel.h>
|
||||
#...
|
||||
|
||||
int anykernelfunction ()
|
||||
{
|
||||
.....
|
||||
/* parameter change here */
|
||||
/* so we inform the cwmp: */
|
||||
kernel_api_cwmp_value_change_call (3, "InternetGatewayDevice.LANDevice.{i}.LANHostConfigManagement.IPInterface.{i}.IPInterfaceIPAddress","lan2","3");
|
||||
.....
|
||||
/*
|
||||
Description of lib_api_cwmp_value_change_call input parameters
|
||||
parameter 1 : is the number of input string in the function lib_api_cwmp_value_change_call
|
||||
parameter 2 : is the parameter path
|
||||
parameter 3 : is the first correspondence related to the first indice
|
||||
parameter 4 : is the second correspondence related to the second indice
|
||||
.
|
||||
.
|
||||
.
|
||||
parameter n : is the (n-2) correspondence related to the (n-2) indice
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
BIN
freecwmp/docs/README.doc
Normal file
BIN
freecwmp/docs/README.doc
Normal file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue