Merge pull request #1 from openwrt-routing/master
Merge to latest openwrt-routing/packages
This commit is contained in:
commit
f649d7cba8
160 changed files with 6879 additions and 2438 deletions
10
MAINTAINERS
10
MAINTAINERS
|
@ -8,18 +8,18 @@
|
|||
# use alphabetical order when updating the list.
|
||||
|
||||
Axel "axn" Neumann <neumann@cgws.de>
|
||||
Baptiste Jonglez <bjonglez@illyse.org>
|
||||
Bastian Bittorf <bittorf@bluebottle.com>
|
||||
Baptiste Jonglez <openwrt-pkg@bitsofnetworks.org>
|
||||
Bastian Bittorf <bb@npl.de>
|
||||
Corinna "Elektra" Aichele <onelektra@gmx.net>
|
||||
Gabriel Kerneis <gabriel@kerneis.info>
|
||||
Gui Iribarren <gui@altermundi.net>
|
||||
Jo-Philipp Wich <jow@openwrt.org>
|
||||
Jo-Philipp Wich <jo@mein.io>
|
||||
Luka Perkov <luka@openwrt.org>
|
||||
Marek Lindner <mareklindner@neomailbox.ch>
|
||||
Moritz Warning <moritzwarning@web.de>
|
||||
Nicolás Echániz <nicoechaniz@altermundi.net>
|
||||
Pau Escrich <pau@dabax.net>
|
||||
Saverio Proto <zioproto@gmail.com>
|
||||
Simon Wunderlich <simon.wunderlich@s2003.tu-chemnitz.de>
|
||||
Steven Barth <cyrus@openwrt.org>
|
||||
Simon Wunderlich <sw@simonwunderlich.de>
|
||||
Steven Barth <steven@midlink.org>
|
||||
Vasilis "acinonyx" Tsiligiannis <acinonyx@openwrt.gr>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#
|
||||
#
|
||||
# Copyright (C) 2007-2011 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
|
@ -14,6 +14,7 @@ PKG_RELEASE:=2
|
|||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=http://www.pps.univ-paris-diderot.fr/~jch/software/files/
|
||||
PKG_MD5SUM:=a1a610bf20965aa522cd766bf3d5829a
|
||||
PKG_LICENSE:=MIT
|
||||
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
@ -24,7 +25,7 @@ define Package/ahcpd
|
|||
TITLE:=Ad-Hoc Configuration Protocol daemon
|
||||
URL:=http://www.pps.univ-paris-diderot.fr/~jch/software/ahcp/
|
||||
MAINTAINER:=Gabriel Kerneis <gabriel@kerneis.info>
|
||||
DEPENDS:=+kmod-ipv6 +ip +librt
|
||||
DEPENDS:=@IPV6 +ip +librt
|
||||
endef
|
||||
|
||||
define Package/ahcpd/description
|
||||
|
|
|
@ -8,26 +8,28 @@
|
|||
include $(TOPDIR)/rules.mk
|
||||
|
||||
#
|
||||
# The latest alfred git hash in PKG_REV can be obtained from http://git.open-mesh.org/alfred.git
|
||||
# The latest alfred git hash in PKG_REV can be obtained from https://git.open-mesh.org/alfred.git
|
||||
#
|
||||
PKG_NAME:=alfred
|
||||
PKG_VERSION:=2014.3.0
|
||||
PKG_VERSION:=2017.0
|
||||
PKG_RELEASE:=0
|
||||
PKG_MD5SUM:=b8ab5677ed73d817b02b0e4fae10357a
|
||||
PKG_MD5SUM:=2e9ae897b1d477f14d06389eb7c1f97b
|
||||
PKG_HASH:=f8d6d83d2ce30b2238354ce12073285387c0f4ca1a28060390ff50b411b50fa8
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=http://downloads.open-mesh.org/batman/releases/batman-adv-$(PKG_VERSION)
|
||||
PKG_SOURCE_URL:=https://downloads.open-mesh.org/batman/releases/batman-adv-$(PKG_VERSION)
|
||||
PKG_LICENSE:=GPL-2.0
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
init-y := alfred
|
||||
|
||||
define Package/alfred
|
||||
URL:=http://www.open-mesh.org/
|
||||
URL:=https://www.open-mesh.org/
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=A.L.F.R.E.D. - Almighty Lightweight Fact Remote Exchange Daemon
|
||||
DEPENDS:= +libc +IPV6:kmod-ipv6 +librt \
|
||||
DEPENDS:= +libc @IPV6 +libnl-tiny +librt \
|
||||
+ALFRED_NEEDS_lua:lua \
|
||||
+ALFRED_NEEDS_libgps:libgps
|
||||
endef
|
||||
|
@ -58,7 +60,10 @@ endef
|
|||
|
||||
MAKE_ALFRED_FLAGS=\
|
||||
CONFIG_ALFRED_VIS=$(if $(CONFIG_PACKAGE_ALFRED_VIS),y,n) \
|
||||
CONFIG_ALFRED_GPSD=$(if $(CONFIG_PACKAGE_ALFRED_GPSD),y,n)
|
||||
CONFIG_ALFRED_GPSD=$(if $(CONFIG_PACKAGE_ALFRED_GPSD),y,n) \
|
||||
CONFIG_ALFRED_CAPABILITIES=n \
|
||||
LIBNL_NAME="libnl-tiny" \
|
||||
LIBNL_GENL_NAME="libnl-tiny"
|
||||
|
||||
TARGET_CFLAGS += -ffunction-sections -fdata-sections -flto
|
||||
TARGET_LDFLAGS += -Wl,--gc-sections -fuse-linker-plugin
|
||||
|
@ -73,7 +78,7 @@ define Package/alfred/install
|
|||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
cp -fpR $(PKG_BUILD_DIR)/alfred $(1)/usr/sbin/
|
||||
[ "x$(CONFIG_PACKAGE_ALFRED_VIS)" == "xy" ] && cp -fpR $(PKG_BUILD_DIR)/vis/batadv-vis $(1)/usr/sbin/ ; true
|
||||
[ "x$(CONFIG_PACKAGE_ALFRED_GPSD)" == "xy" ] && cp -fpR $(PKG_BUILD_DIR)/vis/alfred-gpsd $(1)/usr/sbin/ ; true
|
||||
[ "x$(CONFIG_PACKAGE_ALFRED_GPSD)" == "xy" ] && cp -fpR $(PKG_BUILD_DIR)/gpsd/alfred-gpsd $(1)/usr/sbin/ ; true
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/alfred.init $(1)/etc/init.d/alfred
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
|
|
|
@ -16,10 +16,52 @@ pid_file_alfred="/var/run/alfred.pid"
|
|||
pid_file_vis="/var/run/batadv-vis.pid"
|
||||
enable=0
|
||||
vis_enable=0
|
||||
batmanif=""
|
||||
SERVICE_DAEMONIZE=1
|
||||
SERVICE_WRITE_PID=1
|
||||
|
||||
wait_for_dir()
|
||||
{
|
||||
local ifce="$1" dir="$2"
|
||||
|
||||
if ! [ -d "$dir" ] ; then
|
||||
timeout=30
|
||||
echo "${initscript}: waiting $timeout secs for $ifce interface..."
|
||||
for i in $(seq $timeout); do
|
||||
sleep 1
|
||||
[ -d "$dir" ] && break
|
||||
if [ $i == $timeout ] ; then
|
||||
echo "${initscript}: $ifce not detected, alfred not starting."
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
wait_for_ll_address()
|
||||
{
|
||||
local iface="$1"
|
||||
local timeout=30
|
||||
|
||||
echo "${initscript}: waiting $timeout secs for $iface address..."
|
||||
for i in $(seq $timeout); do
|
||||
# We look for
|
||||
# - the link-local address (starts with fe80)
|
||||
# - without tentative flag (bit 0x40 in the flags field; the first char of the flags field begins 38 columns after the fe80 prefix
|
||||
# - on interface $iface
|
||||
if awk '
|
||||
BEGIN { RET=1 }
|
||||
/^fe80.{37} [012389ab]/ { if ($6 == "'"$iface"'") RET=0 }
|
||||
END { exit RET }
|
||||
' /proc/net/if_inet6; then
|
||||
return
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
echo "${initscript}: $iface address not detected, alfred not starting."
|
||||
exit 1
|
||||
}
|
||||
|
||||
alfred_start()
|
||||
{
|
||||
local args=""
|
||||
|
@ -41,14 +83,20 @@ alfred_start()
|
|||
config_get batmanif "$section" batmanif
|
||||
append args "-b $batmanif"
|
||||
|
||||
if [ "$batmanif" != "none" ]; then
|
||||
wait_for_dir "$batmanif" "/sys/class/net/$batmanif/mesh"
|
||||
fi
|
||||
|
||||
wait_for_ll_address "$interface"
|
||||
|
||||
append alfred_args "$args"
|
||||
enable=1
|
||||
|
||||
config_get_bool start_vis "$section" start_vis 0
|
||||
if [ "$start_vis" = 1 ] && [ -x /usr/sbin/batadv-vis ]; then
|
||||
vis_enable=1
|
||||
append vis_args "-i $batmanif -s"
|
||||
fi
|
||||
config_get_bool start_vis "$section" start_vis 0
|
||||
if [ "$start_vis" = 1 ] && [ -x /usr/sbin/batadv-vis ]; then
|
||||
vis_enable=1
|
||||
append vis_args "-i $batmanif -s"
|
||||
fi
|
||||
|
||||
config_get_bool run_facters "$section" run_facters 0
|
||||
|
||||
|
@ -64,20 +112,6 @@ start()
|
|||
exit 0
|
||||
fi
|
||||
|
||||
mesh_dir="/sys/class/net/$batmanif/mesh/"
|
||||
if ! [ -d "$mesh_dir" ] ; then
|
||||
timeout=30
|
||||
echo "${initscript}: waiting $timeout secs for $batmanif interface..."
|
||||
for i in $(seq $timeout); do
|
||||
sleep 1
|
||||
[ -d "$mesh_dir" ] && break
|
||||
if [ $i == $timeout ] ; then
|
||||
echo "${initscript}: $batmanif not detected, alfred not starting."
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
echo "${initscript}: starting alfred"
|
||||
SERVICE_PID_FILE="$pid_file_alfred"
|
||||
service_start /usr/sbin/alfred ${alfred_args}
|
||||
|
|
41
babel-pinger/Makefile
Normal file
41
babel-pinger/Makefile
Normal file
|
@ -0,0 +1,41 @@
|
|||
# Copyright (C) 2012-2014 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=babel-pinger
|
||||
PKG_VERSION:=0.1
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=http://www.pps.univ-paris-diderot.fr/~jch/software/files/
|
||||
PKG_MD5SUM:=40d4931986913f5f8d9b5b70abf6fda5
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/babel-pinger
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
SUBMENU:=Routing and Redirection
|
||||
TITLE:=Babel-pinger
|
||||
URL:=http://www.pps.univ-paris-diderot.fr/~jch/software/babel/
|
||||
MAINTAINER:=Gabriel Kerneis <gabriel@kerneis.info>
|
||||
DEPENDS:=+librt
|
||||
endef
|
||||
|
||||
define Package/babel-pinger/description
|
||||
Babel-pinger is a hack to export a default route into Babel for people
|
||||
using DHCP to configure their routers rather than speaking to their
|
||||
upstream provider with a proper routing protocol.
|
||||
endef
|
||||
|
||||
MAKE_FLAGS+= \
|
||||
CFLAGS="$(TARGET_CFLAGS)" \
|
||||
|
||||
define Package/babel-pinger/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/babel-pinger $(1)/usr/sbin/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,babel-pinger))
|
|
@ -8,12 +8,13 @@
|
|||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=babeld
|
||||
PKG_VERSION:=1.5.1
|
||||
PKG_RELEASE:=1
|
||||
PKG_VERSION:=1.8.0
|
||||
PKG_RELEASE:=3
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=http://www.pps.univ-paris-diderot.fr/~jch/software/files/
|
||||
PKG_MD5SUM:=20e3284d5ad291d7ba2ad91d5b47de10
|
||||
PKG_SOURCE_URL:=https://www.irif.fr/~jch/software/files/
|
||||
PKG_MD5SUM:=eb1c66c382e9181c418ebd84e52b5af2
|
||||
PKG_LICENSE:=MIT
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
|
@ -22,9 +23,10 @@ define Package/babeld
|
|||
CATEGORY:=Network
|
||||
SUBMENU:=Routing and Redirection
|
||||
TITLE:=A loop-free distance-vector routing protocol
|
||||
URL:=http://www.pps.univ-paris-diderot.fr/~jch/software/babel/
|
||||
MAINTAINER:=Gabriel Kerneis <gabriel@kerneis.info>
|
||||
DEPENDS:=+kmod-ipv6 +librt
|
||||
URL:=https://www.irif.fr/~jch/software/babel/
|
||||
MAINTAINER:=Gabriel Kerneis <gabriel@kerneis.info>, \
|
||||
Baptiste Jonglez <openwrt-pkg@bitsofnetworks.org>
|
||||
DEPENDS:=@IPV6
|
||||
endef
|
||||
|
||||
define Package/babeld/description
|
||||
|
@ -44,6 +46,7 @@ endef
|
|||
|
||||
MAKE_FLAGS+= \
|
||||
CFLAGS="$(TARGET_CFLAGS)" \
|
||||
LDLIBS="" \
|
||||
|
||||
define Package/babeld/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package babeld
|
||||
|
||||
# Configuration set in this file ends up in /var/etc/babeld.conf.
|
||||
# Babeld is told to use both /etc/babeld.conf and /var/etc/babeld.conf, so
|
||||
# you can use one or the other, or even both at the same time. If an
|
||||
# option is defined in both files, the version in /var/etc/babeld.conf
|
||||
# takes precedence.
|
||||
# Babeld reads options from the following files (the last one takes precedence
|
||||
# if an option is defined in several places):
|
||||
# - the file defined by the option conf_file (default: /etc/babeld.conf),
|
||||
# - *.conf files in the directory defined by conf_dir (default: /tmp/babel.d/),
|
||||
# - this UCI configuration file.
|
||||
|
||||
# See "man babeld" for all available options ("Global options").
|
||||
# Important: remember to use '_' instead of '-' in option names.
|
||||
|
@ -13,10 +13,15 @@ config general
|
|||
# option 'debug' '1'
|
||||
# option 'local_port' '33123'
|
||||
# option 'log_file' '/var/log/babeld.log'
|
||||
## This seems somewhat buggy on BB. If you need only one
|
||||
## import-table statement, "option import_table 42" should work.
|
||||
## Enable ipv6-subtrees by default since OpenWrt should ship with a
|
||||
## recent enough kernel for it to work.
|
||||
option 'ipv6_subtrees' 'true'
|
||||
# list 'import_table' '42'
|
||||
# list 'import_table' '100'
|
||||
## Alternative configuration file and directory.
|
||||
## See comment at the top of this file for more details.
|
||||
# option 'conf_file' '/etc/babeld.conf'
|
||||
# option 'conf_dir' '/tmp/babel.d/'
|
||||
|
||||
config interface
|
||||
## Remove this line to enable babeld on this interface
|
||||
|
@ -54,11 +59,12 @@ config filter
|
|||
option 'ignore' 'true'
|
||||
# Type
|
||||
option 'type' 'redistribute'
|
||||
# Selectors: ip, eq, le, ge, neigh, id, proto, local, if
|
||||
# Selectors: ip, eq, le, ge, src_ip, src_eq, src_le, src_ge, neigh, id,
|
||||
# proto, local, if.
|
||||
option 'ip' '0.0.0.0/0'
|
||||
option 'eq' '0'
|
||||
option 'proto' '3'
|
||||
# Action
|
||||
# Action (one of: allow, deny, metric XXX, src-prefix XXX).
|
||||
option 'action' 'metric 128'
|
||||
|
||||
# Notice that the 'local' selector is a boolean.
|
||||
|
|
|
@ -1,23 +1,20 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
|
||||
. /lib/functions/network.sh
|
||||
. $IPKG_INSTROOT/lib/functions/network.sh
|
||||
|
||||
USE_PROCD=1
|
||||
START=70
|
||||
|
||||
pidfile='/var/run/babeld.pid'
|
||||
CONFIGFILE='/var/etc/babeld.conf'
|
||||
OTHERCONFIGFILE="/etc/babeld.conf"
|
||||
OTHERCONFIGDIR="/tmp/babeld.d/"
|
||||
EXTRA_COMMANDS="status"
|
||||
EXTRA_HELP=" status Dump Babel's table to the log file."
|
||||
|
||||
# Options to ignore for the global section (old options that are translated
|
||||
# for backward compatibility with old configuration files)
|
||||
ignored_options="carrier_sense assume_wireless no_split_horizon random_router_id multicast_address port hello_interval wired_hello_interval smoothing_half_time duplication_priority local_server conf_file"
|
||||
|
||||
# Append a line to the configuration file
|
||||
cfg_append() {
|
||||
local value="$1"
|
||||
echo "$value" >> $CONFIGFILE
|
||||
echo "$value" >> "$CONFIGFILE"
|
||||
}
|
||||
|
||||
cfg_append_option() {
|
||||
|
@ -60,56 +57,6 @@ append_parm() {
|
|||
append buffer "$switch $_loctmp"
|
||||
}
|
||||
|
||||
|
||||
# Provides backward compatibility for old option names in the global section.
|
||||
translate_option() {
|
||||
local section="$1"
|
||||
local old_option="$2"
|
||||
local new_option="$3"
|
||||
local _value
|
||||
config_get _value "$section" "$old_option"
|
||||
[ -z "$_value" ] && return
|
||||
cfg_append "${new_option//_/-} $_value"
|
||||
}
|
||||
|
||||
translate_bool() {
|
||||
local section="$1"
|
||||
local old_option="$2"
|
||||
local new_option="$3"
|
||||
local _bool
|
||||
local _value
|
||||
config_get_bool _bool "$section" "$old_option" 0
|
||||
[ "$_bool" -eq 0 ] && return
|
||||
cfg_append "${new_option//_/-} true"
|
||||
}
|
||||
|
||||
# Adds a new interface section for setting default interface options.
|
||||
add_default_option() {
|
||||
local option="$1"
|
||||
local value="$2"
|
||||
cfg_append "default ${option//_/-} $value"
|
||||
}
|
||||
|
||||
# Global 'hello_interval' and 'wired_hello_interval' options are ignored,
|
||||
# because they have no direct equivalent: you should use
|
||||
# interface-specific settings.
|
||||
parse_old_global_options() {
|
||||
local section="$1"
|
||||
translate_bool "$section" 'carrier_sense' 'link_detect'
|
||||
translate_bool "$section" 'random_router_id' 'random_id'
|
||||
translate_option "$section" 'multicast_address' 'protocol_group'
|
||||
translate_option "$section" 'port' 'protocol_port'
|
||||
translate_option "$section" 'local_server' 'local_port'
|
||||
translate_option "$section" 'smoothing_half_time' 'smoothing_half_life'
|
||||
translate_option "$section" 'duplication_priority' 'allow_duplicates'
|
||||
# These two global options are turned into default interface options.
|
||||
local _bool
|
||||
config_get_bool _bool "$section" 'assume_wireless' 0
|
||||
[ "$_bool" -eq 1 ] && add_default_option "wired" "false"
|
||||
config_get_bool _bool "$section" 'no_split_horizon' 0
|
||||
[ "$_bool" -eq 1 ] && add_default_option "split_horizon" "false"
|
||||
}
|
||||
|
||||
babel_filter() {
|
||||
local cfg="$1"
|
||||
local _loctmp
|
||||
|
@ -127,6 +74,10 @@ babel_filter() {
|
|||
append_parm "$cfg" 'eq' 'eq'
|
||||
append_parm "$cfg" 'le' 'le'
|
||||
append_parm "$cfg" 'ge' 'ge'
|
||||
append_parm "$cfg" 'src_ip' 'src-ip'
|
||||
append_parm "$cfg" 'src_eq' 'src-eq'
|
||||
append_parm "$cfg" 'src_le' 'src-le'
|
||||
append_parm "$cfg" 'src_ge' 'src-ge'
|
||||
append_parm "$cfg" 'neigh' 'neigh'
|
||||
append_parm "$cfg" 'id' 'id'
|
||||
append_parm "$cfg" 'proto' 'proto'
|
||||
|
@ -152,17 +103,18 @@ babel_config_cb() {
|
|||
option_cb() {
|
||||
local option="$1"
|
||||
local value="$2"
|
||||
# Ignore old options
|
||||
list_contains ignored_options "$option" && return
|
||||
# Ignore options that are not supposed to be given to babeld
|
||||
[ "$option" = "conf_file" ] && return
|
||||
[ "$option" = "conf_dir" ] && return
|
||||
# Skip lists. They will be taken care of by list_cb
|
||||
test "${option#*_ITEM}" != "$option" && return
|
||||
test "${option#*_LENGTH}" != "$option" && return
|
||||
cfg_append "${option//_/-} $value"
|
||||
}
|
||||
;;
|
||||
"interface")
|
||||
local _ifname
|
||||
config_get _ifname "$section" 'ifname'
|
||||
# Backward compatibility: try to use the section name
|
||||
# if no "option ifname" was used.
|
||||
[ -z "$_ifname" -a "${section:0:3}" != "cfg" ] && _ifname="$section"
|
||||
# Try to resolve the logical interface name
|
||||
unset interface
|
||||
network_get_device interface "$_ifname" || interface="$_ifname"
|
||||
|
@ -197,43 +149,58 @@ babel_config_cb() {
|
|||
esac
|
||||
}
|
||||
|
||||
start() {
|
||||
# Support for conf_file and conf_dir
|
||||
babel_configpaths() {
|
||||
local cfg="$1"
|
||||
local conf_file
|
||||
config_get conf_file "$cfg" "conf_file"
|
||||
[ -n "$conf_file" ] && OTHERCONFIGFILE="$conf_file"
|
||||
local conf_dir
|
||||
config_get conf_dir "$cfg" "conf_dir"
|
||||
[ -n "$conf_dir" ] && OTHERCONFIGDIR="$conf_dir"
|
||||
}
|
||||
|
||||
start_service() {
|
||||
mkdir -p /var/lib
|
||||
mkdir -p /var/etc
|
||||
|
||||
# First load the whole config file, without callbacks, so that we are
|
||||
# aware of all "ignore" options in the second pass. This also allows
|
||||
# to load the configuration paths (conf_file and conf_dir).
|
||||
config_load babeld
|
||||
|
||||
# Configure alternative configuration file and directory
|
||||
config_foreach babel_configpaths "general"
|
||||
|
||||
# Start by emptying the generated config file
|
||||
>"$CONFIGFILE"
|
||||
# First load the whole config file, without callbacks, so that we are
|
||||
# aware of all "ignore" options in the second pass.
|
||||
config_load babeld
|
||||
# Import dynamic config files
|
||||
mkdir -p "$OTHERCONFIGDIR"
|
||||
for f in "$OTHERCONFIGDIR"/*.conf; do
|
||||
[ -f "$f" ] && cat "$f" >> "$CONFIGFILE"
|
||||
done
|
||||
|
||||
# Parse general and interface sections thanks to the "config_cb()"
|
||||
# callback. This allows to loop over all options without having to
|
||||
# know their name in advance.
|
||||
config_cb() { babel_config_cb "$@"; }
|
||||
config_load babeld
|
||||
# Backward compatibility
|
||||
config_foreach parse_old_global_options general
|
||||
# Parse filters separately, since we know which options we expect
|
||||
config_foreach babel_filter filter
|
||||
procd_open_instance
|
||||
# Using multiple config files is supported since babeld 1.5.1
|
||||
/usr/sbin/babeld -D -I "$pidfile" -c "$OTHERCONFIGFILE" -c "$CONFIGFILE"
|
||||
# Wait for the pidfile to appear
|
||||
for i in 1 2
|
||||
do
|
||||
[ -f "$pidfile" ] || sleep 1
|
||||
done
|
||||
[ -f "$pidfile" ] || (echo "Failed to start babeld"; exit 42)
|
||||
procd_set_param command /usr/sbin/babeld -I "" -c "$OTHERCONFIGFILE" -c "$CONFIGFILE"
|
||||
procd_set_param stdout 1
|
||||
procd_set_param stderr 1
|
||||
procd_set_param file "$OTHERCONFIGFILE" "$OTHERCONFIGDIR"/*.conf "$CONFIGFILE"
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
stop() {
|
||||
[ -f "$pidfile" ] && kill $(cat $pidfile)
|
||||
# avoid race-condition on restart: wait for
|
||||
# babeld to die for real.
|
||||
[ -f "$pidfile" ] && sleep 1
|
||||
[ -f "$pidfile" ] && sleep 1
|
||||
[ -f "$pidfile" ] && sleep 1
|
||||
[ -f "$pidfile" ] && exit 42
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger babeld
|
||||
}
|
||||
|
||||
status() {
|
||||
[ -f "$pidfile" ] && kill -USR1 $(cat $pidfile)
|
||||
kill -USR1 $(pgrep -P 1 babeld)
|
||||
}
|
||||
|
|
|
@ -1,68 +0,0 @@
|
|||
#
|
||||
# Copyright (C) 2007-2009 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:=babels
|
||||
PKG_SOURCE_VERSION:=2598774f6bd7d9225483c48d72733eab5745d14e
|
||||
PKG_VERSION:=2014-08-09-$(PKG_SOURCE_VERSION)
|
||||
PKG_RELEASE:=1
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://github.com/boutier/babeld.git
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/babels
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
SUBMENU:=Routing and Redirection
|
||||
TITLE:=A loop-free distance-vector routing protocol (source-specific)
|
||||
URL:=http://www.pps.univ-paris-diderot.fr/~jch/software/babel/
|
||||
MAINTAINER:=Steven Barth <cyrus@openwrt.org>
|
||||
DEPENDS:=+kmod-ipv6
|
||||
endef
|
||||
|
||||
define Package/babels/description
|
||||
Babel is a loop-avoiding distance-vector routing protocol roughly based
|
||||
on DSDV and AODV, but with provisions for link cost estimation and
|
||||
redistribution of routes from other routing protocols.
|
||||
While it is optimised for wireless mesh networks, Babel will also work
|
||||
efficiently on wired networks. It will generate between 1.2 and 2.4 times
|
||||
the amount of routing traffic that RIPng would generate, while
|
||||
never counting to infinity.
|
||||
This is experimental source routing branch, and should be only used if you
|
||||
know what you are doing.
|
||||
endef
|
||||
|
||||
define Package/babels/conffiles
|
||||
/etc/babeld.conf
|
||||
/etc/config/babeld
|
||||
endef
|
||||
|
||||
MAKE_FLAGS+= \
|
||||
CFLAGS="$(TARGET_CFLAGS) -DIPV6_SUBTREES" \
|
||||
LDLIBS="" \
|
||||
|
||||
define Package/babels/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/babeld $(1)/usr/sbin/
|
||||
$(INSTALL_DIR) $(1)/etc
|
||||
$(INSTALL_CONF) ./files/babeld.conf $(1)/etc/
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_CONF) ./files/babeld.config $(1)/etc/config/babeld
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/babeld.init $(1)/etc/init.d/babeld
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
echo "#define BABEL_VERSION \"$(PKG_SOURCE_SUBDIR)\"" > $(PKG_BUILD_DIR)/version.h
|
||||
$(call Build/Compile/Default)
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,babels))
|
|
@ -1,38 +0,0 @@
|
|||
# babel config file
|
||||
#
|
||||
# This config file simply documents sample entries.
|
||||
# "redistribute" means: redistribute routes from other routing protocols
|
||||
# into babel. "local" means addresses assigned to local interfaces.
|
||||
#
|
||||
# You do not need to edit this file: you can use /etc/config/babeld
|
||||
# instead (sections "interface" and "filter"). Both files can be used
|
||||
# simultaneously (the rules of this file are executed first).
|
||||
|
||||
# the default rules are:
|
||||
#
|
||||
## redistribute local
|
||||
## redistribute deny
|
||||
#
|
||||
# this says, redistribute local addresses but no other routes
|
||||
|
||||
|
||||
# redistribute IPv4 default route into babel
|
||||
## redistribute local ip 0.0.0.0/0 le 0 metric 128
|
||||
|
||||
# same but for IPv6
|
||||
## redistribute local ip ::/0 le 0 metric 128
|
||||
|
||||
|
||||
# don't redistribute all local addresses, only selected ones
|
||||
# after the first line, the "deny" rules kicks in. After the "deny"
|
||||
# no redistribute local rules are going to match
|
||||
## redistribute local ip 192.160.4.0/24
|
||||
## redistribute local deny
|
||||
|
||||
|
||||
# Babel refuses to redistribute routes with a protocol number of "boot";
|
||||
# this is standard practice, and means that you cannot easily
|
||||
# redistribute the default route installed by dhcp. It is however
|
||||
# possible to redistribute such route by explicitly specifying "proto 3"
|
||||
# on the redistribute line.
|
||||
## redistribute ip 0.0.0.0/0 le 0 proto 3 metric 128
|
|
@ -1,72 +0,0 @@
|
|||
package babeld
|
||||
|
||||
config general
|
||||
# option 'multicast_address' 'ff02:0:0:0:0:0:1:6'
|
||||
# option 'port' '6696'
|
||||
# option 'state_file' '/var/lib/babel-state'
|
||||
# option 'hello_interval' '4'
|
||||
# option 'wired_hello_interval' '20'
|
||||
# option 'diversity' '0,128'
|
||||
# option 'smoothing_half_time' '4'
|
||||
# option 'kernel_priority' '0'
|
||||
# Do not use this option unless you know what you are doing, as it can
|
||||
# cause persistent route flapping.
|
||||
## option 'duplication_priority' '0'
|
||||
# option 'carrier_sense' 'false'
|
||||
# option 'assume_wireless' 'false'
|
||||
# option 'no_split_horizon' 'false'
|
||||
# option 'debug' '0'
|
||||
# Listen for connections from a front-end, e.g. on port 33123.
|
||||
## option 'local_server' '33123'
|
||||
# option 'random_router_id' 'false'
|
||||
# Keep unfeasible routes
|
||||
## option 'keep_unfeasible' 'false'
|
||||
# Use the given kernel routing table for routes inserted by babeld.
|
||||
## option 'export_table' '0'
|
||||
# Export routes from the given kernel routing tables.
|
||||
## list 'import_table' '0'
|
||||
## list 'import_table' '42'
|
||||
# The configuration file is not necessary since you can do everything
|
||||
# from this file.
|
||||
# option 'conf_file' '/etc/babeld.conf'
|
||||
# option 'log_file' '/var/log/babeld.log'
|
||||
|
||||
# You can use aliases (like lan, wlan) or real names (like eth0.0).
|
||||
# If you use an alias, it must be already defined when babeld starts.
|
||||
# Otherwise, the name is taken literally and the interface can be
|
||||
# brought up later (useful for tunnels for instance).
|
||||
config interface wlan
|
||||
# Remove this line to enable babeld on this interface
|
||||
option 'ignore' 'true'
|
||||
# option 'wired' 'auto'
|
||||
# option 'link_quality' 'auto'
|
||||
# option 'split_horizon' 'auto'
|
||||
# The default is 96 for wired interfaces, and 256 for wireless ones
|
||||
## option 'rxcost' '256'
|
||||
# The default is specified with the -h and -H command-line flags.
|
||||
## option 'hello_interval' '4'
|
||||
# This can be set to a fairly large value, unless significant
|
||||
# packet loss is expected. The default is four times the hello
|
||||
# interval.
|
||||
## option 'update_interval' '16'
|
||||
|
||||
config interface lan
|
||||
option 'ignore' 'true'
|
||||
|
||||
# A filter consists in a type ('in', 'out' or 'redistribute'), an action
|
||||
# ('allow', 'deny' or 'metric xxx') and a set of selectors ('ip', 'eq',
|
||||
# etc.). See /etc/babeld.conf for more details.
|
||||
# Here is a sample filter wich redistributes the default route if its
|
||||
# protocol number is "boot", e.g. when it installed by dhcp. It is
|
||||
# disabled by default.
|
||||
config filter
|
||||
option 'ignore' 'true'
|
||||
# Type
|
||||
option 'type' 'redistribute'
|
||||
# Selectors: ip, eq, le, ge, neigh, id, proto, local, if
|
||||
option 'ip' '0.0.0.0/0'
|
||||
option 'le' '0'
|
||||
option 'proto' '3'
|
||||
# Action
|
||||
option 'action' 'metric 128'
|
||||
|
|
@ -1,154 +0,0 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=70
|
||||
|
||||
pidfile='/var/run/babeld.pid'
|
||||
EXTRA_COMMANDS="status"
|
||||
EXTRA_HELP=" status Dump Babel's table to the log file."
|
||||
|
||||
listen_ifname() {
|
||||
local ifname=$(uci_get_state network "$1" ifname "$1")
|
||||
local switch="$2"
|
||||
append args "$switch $ifname"
|
||||
append interfaces "$ifname"
|
||||
}
|
||||
|
||||
append_ifname() {
|
||||
local section="$1"
|
||||
local option="$2"
|
||||
local switch="$3"
|
||||
local _name
|
||||
config_get _name "$section" "$option"
|
||||
[ -z "$_name" ] && return 0
|
||||
local ifname=$(uci_get_state network "$_name" ifname "$_name")
|
||||
append args "$switch $ifname"
|
||||
}
|
||||
|
||||
append_bool() {
|
||||
local section="$1"
|
||||
local option="$2"
|
||||
local value="$3"
|
||||
local _loctmp
|
||||
config_get_bool _loctmp "$section" "$option" 0
|
||||
[ "$_loctmp" -gt 0 ] && append args "$value"
|
||||
}
|
||||
|
||||
append_switch() {
|
||||
local value="$1"
|
||||
local switch="$2"
|
||||
append args "$switch $value"
|
||||
}
|
||||
|
||||
append_parm() {
|
||||
local section="$1"
|
||||
local option="$2"
|
||||
local switch="$3"
|
||||
local _loctmp
|
||||
config_get _loctmp "$section" "$option"
|
||||
[ -z "$_loctmp" ] && return 0
|
||||
append args "$switch $_loctmp"
|
||||
}
|
||||
|
||||
babel_filter() {
|
||||
local cfg="$1"
|
||||
local _loctmp
|
||||
|
||||
local _ignored
|
||||
config_get_bool _ignored "$cfg" 'ignore' 0
|
||||
[ "$_ignored" -eq 1 ] && return 0
|
||||
|
||||
append args "-C '"
|
||||
|
||||
append_parm "$cfg" 'type' ''
|
||||
|
||||
append_bool "$cfg" 'local' 'local'
|
||||
|
||||
append_parm "$cfg" 'ip' 'ip'
|
||||
append_parm "$cfg" 'eq' 'eq'
|
||||
append_parm "$cfg" 'le' 'le'
|
||||
append_parm "$cfg" 'ge' 'ge'
|
||||
append_parm "$cfg" 'src_ip' 'src-ip'
|
||||
append_parm "$cfg" 'src_eq' 'src-eq'
|
||||
append_parm "$cfg" 'src_le' 'src-le'
|
||||
append_parm "$cfg" 'src_ge' 'src-ge'
|
||||
append_parm "$cfg" 'neigh' 'neigh'
|
||||
append_parm "$cfg" 'id' 'id'
|
||||
append_parm "$cfg" 'proto' 'proto'
|
||||
|
||||
append_ifname "$cfg" 'if' 'if'
|
||||
|
||||
append_parm "$cfg" 'action' ''
|
||||
|
||||
append args ' ' "'"
|
||||
}
|
||||
|
||||
babel_addif() {
|
||||
local cfg="$1"
|
||||
|
||||
local _ignored
|
||||
config_get_bool _ignored "$cfg" 'ignore' 0
|
||||
[ "$_ignored" -eq 1 ] && return 0
|
||||
|
||||
listen_ifname "$cfg" "-C 'interface"
|
||||
|
||||
append_parm "$cfg" 'wired' 'wired'
|
||||
append_parm "$cfg" 'link_quality' 'link-quality'
|
||||
append_parm "$cfg" 'split_horizon' 'split-horizon'
|
||||
append_parm "$cfg" 'rxcost' 'rxcost'
|
||||
append_parm "$cfg" 'hello_interval' 'hello-interval'
|
||||
append_parm "$cfg" 'update_interval' 'update-interval'
|
||||
|
||||
append args ' ' "'"
|
||||
}
|
||||
|
||||
babel_config() {
|
||||
local cfg="$1"
|
||||
|
||||
append_bool "$cfg" 'carrier_sense' '-l'
|
||||
append_bool "$cfg" 'assume_wireless' '-w'
|
||||
append_bool "$cfg" 'no_split_horizon' '-s'
|
||||
append_bool "$cfg" 'keep_unfeasible' '-u'
|
||||
append_bool "$cfg" 'random_router_id' '-r'
|
||||
|
||||
append_parm "$cfg" 'multicast_address' '-m'
|
||||
append_parm "$cfg" 'port' '-p'
|
||||
append_parm "$cfg" 'state_file' '-S'
|
||||
append_parm "$cfg" 'hello_interval' '-h'
|
||||
append_parm "$cfg" 'wired_hello_interval' '-H'
|
||||
append_parm "$cfg" 'diversity' '-z'
|
||||
append_parm "$cfg" 'smoothing_half_time' '-M'
|
||||
append_parm "$cfg" 'kernel_priority' '-k'
|
||||
append_parm "$cfg" 'duplication_priority' '-A'
|
||||
append_parm "$cfg" 'debug' '-d'
|
||||
append_parm "$cfg" 'local_server' '-g'
|
||||
append_parm "$cfg" 'export_table' '-t'
|
||||
config_list_foreach "$cfg" 'import_table' append_switch '-T'
|
||||
append_parm "$cfg" 'conf_file' '-c'
|
||||
append_parm "$cfg" 'log_file' '-L'
|
||||
}
|
||||
|
||||
start() {
|
||||
mkdir -p /var/lib
|
||||
config_load babeld
|
||||
unset args
|
||||
unset interfaces
|
||||
config_foreach babel_config general
|
||||
config_foreach babel_addif interface
|
||||
config_foreach babel_filter filter
|
||||
[ -z "$interfaces" ] && return 0
|
||||
eval "/usr/sbin/babeld -D -I $pidfile $args $interfaces"
|
||||
}
|
||||
|
||||
stop() {
|
||||
[ -f "$pidfile" ] && kill $(cat $pidfile)
|
||||
# avoid race-condition on restart: wait for
|
||||
# babeld to die for real.
|
||||
[ -f "$pidfile" ] && sleep 1
|
||||
[ -f "$pidfile" ] && sleep 1
|
||||
[ -f "$pidfile" ] && sleep 1
|
||||
[ -f "$pidfile" ] && exit 42
|
||||
}
|
||||
|
||||
status() {
|
||||
[ -f "$pidfile" ] && kill -USR1 $(cat $pidfile)
|
||||
}
|
|
@ -1,103 +0,0 @@
|
|||
From 3fdbb1f797ee9fe9260af92f5d7ea760684cd271 Mon Sep 17 00:00:00 2001
|
||||
From: Steven Barth <steven@midlink.org>
|
||||
Date: Tue, 18 Feb 2014 13:18:32 +0100
|
||||
Subject: [PATCH] Allow routes with source ::/128 for SAS on Linux
|
||||
|
||||
Linux uses the source-address :: (unspecified) to lookup routes in the
|
||||
routing table for connections that are not bound to a specific source
|
||||
address (e.g. ping6 2001:db8::1). If all default routes are
|
||||
source-restricted a command like above will result in a "Permission
|
||||
denied" error and no packets are being sent. Adding a default route with
|
||||
source ::/128 avoids this issue.
|
||||
|
||||
This patch excludes ::/128 from the "martian_prefix" check for source
|
||||
prefixes and thus allows such auxiliary routes to be distributed.
|
||||
|
||||
Signed-off-by: Steven Barth <cyrus@openwrt.org>
|
||||
---
|
||||
kernel_netlink.c | 4 ++--
|
||||
route.c | 4 ++--
|
||||
util.c | 4 ++--
|
||||
util.h | 2 +-
|
||||
xroute.c | 2 +-
|
||||
5 files changed, 8 insertions(+), 8 deletions(-)
|
||||
|
||||
--- a/kernel_netlink.c
|
||||
+++ b/kernel_netlink.c
|
||||
@@ -1242,8 +1242,8 @@ filter_kernel_routes(struct nlmsghdr *nh
|
||||
if(rc < 0)
|
||||
return 0;
|
||||
|
||||
- if(martian_prefix(current_route->prefix, current_route->plen) ||
|
||||
- martian_prefix(current_route->src_prefix, current_route->src_plen))
|
||||
+ if(martian_prefix(current_route->prefix, current_route->plen, 0) ||
|
||||
+ martian_prefix(current_route->src_prefix, current_route->src_plen, 1))
|
||||
return 0;
|
||||
|
||||
/* Ignore default unreachable routes; no idea where they come from. */
|
||||
@@ -1944,7 +1944,7 @@ filter_kernel_rules(struct nlmsghdr *nh,
|
||||
kdebugf("filter_rules: from %s prio %d table %d\n",
|
||||
format_prefix(src, src_plen), priority, table);
|
||||
|
||||
- if(martian_prefix(src, src_plen) || !has_priority)
|
||||
+ if(martian_prefix(src, src_plen, 1) || !has_priority)
|
||||
return 0;
|
||||
|
||||
i = priority - src_table_prio;
|
||||
--- a/route.c
|
||||
+++ b/route.c
|
||||
@@ -901,12 +901,12 @@ update_route(const unsigned char *id,
|
||||
if(memcmp(id, myid, 8) == 0)
|
||||
return NULL;
|
||||
|
||||
- if(martian_prefix(prefix, plen)) {
|
||||
+ if(martian_prefix(prefix, plen, 0)) {
|
||||
fprintf(stderr, "Rejecting martian route to %s through %s.\n",
|
||||
format_prefix(prefix, plen), format_address(nexthop));
|
||||
return NULL;
|
||||
}
|
||||
- if(src_plen != 0 && martian_prefix(src_prefix, src_plen)) {
|
||||
+ if(src_plen != 0 && martian_prefix(src_prefix, src_plen, 1)) {
|
||||
fprintf(stderr, "Rejecting martian route to %s from %s through %s.\n",
|
||||
format_prefix(prefix, plen),
|
||||
format_prefix(src_prefix, src_plen), format_eui64(id));
|
||||
--- a/util.c
|
||||
+++ b/util.c
|
||||
@@ -437,13 +437,13 @@ wait_for_fd(int direction, int fd, int m
|
||||
}
|
||||
|
||||
int
|
||||
-martian_prefix(const unsigned char *prefix, int plen)
|
||||
+martian_prefix(const unsigned char *prefix, int plen, int is_source)
|
||||
{
|
||||
return
|
||||
(plen >= 8 && prefix[0] == 0xFF) ||
|
||||
(plen >= 10 && prefix[0] == 0xFE && (prefix[1] & 0xC0) == 0x80) ||
|
||||
(plen >= 128 && memcmp(prefix, zeroes, 15) == 0 &&
|
||||
- (prefix[15] == 0 || prefix[15] == 1)) ||
|
||||
+ ((prefix[15] == 0 && !is_source) || prefix[15] == 1)) ||
|
||||
(plen >= 96 && v4mapped(prefix) &&
|
||||
((plen >= 104 && (prefix[12] == 127 || prefix[12] == 0)) ||
|
||||
(plen >= 100 && (prefix[12] & 0xE0) == 0xE0)));
|
||||
--- a/util.h
|
||||
+++ b/util.h
|
||||
@@ -106,7 +106,7 @@ int parse_net(const char *net, unsigned
|
||||
int *af_r);
|
||||
int parse_eui64(const char *eui, unsigned char *eui_r);
|
||||
int wait_for_fd(int direction, int fd, int msecs);
|
||||
-int martian_prefix(const unsigned char *prefix, int plen) ATTRIBUTE ((pure));
|
||||
+int martian_prefix(const unsigned char *prefix, int plen, int is_source) ATTRIBUTE ((pure));
|
||||
int linklocal(const unsigned char *address) ATTRIBUTE ((pure));
|
||||
int v4mapped(const unsigned char *address) ATTRIBUTE ((pure));
|
||||
void v4tov6(unsigned char *dst, const unsigned char *src);
|
||||
--- a/xroute.c
|
||||
+++ b/xroute.c
|
||||
@@ -266,7 +266,7 @@ check_xroutes(int send_updates)
|
||||
/* Add any new routes */
|
||||
|
||||
for(i = 0; i < numroutes; i++) {
|
||||
- if(martian_prefix(routes[i].prefix, routes[i].plen))
|
||||
+ if(martian_prefix(routes[i].prefix, routes[i].plen, 0))
|
||||
continue;
|
||||
metric = redistribute_filter(routes[i].prefix, routes[i].plen,
|
||||
routes[i].src_prefix, routes[i].src_plen,
|
|
@ -9,24 +9,26 @@ include $(TOPDIR)/rules.mk
|
|||
|
||||
PKG_NAME:=batctl
|
||||
|
||||
PKG_VERSION:=2014.2.0
|
||||
PKG_RELEASE:=1
|
||||
PKG_MD5SUM:=c196cf95b7324d9123b701a56b06b31d
|
||||
PKG_VERSION:=2017.0
|
||||
PKG_RELEASE:=0
|
||||
PKG_MD5SUM:=17c0ac0746f1994ddacc88ebf48e5aec
|
||||
PKG_HASH:=c0bb1127d6070b46abeb8d6a63d1150d71fa85f87f9a846873b649a21934c686
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=http://downloads.open-mesh.org/batman/releases/batman-adv-$(PKG_VERSION)
|
||||
PKG_SOURCE_URL:=https://downloads.open-mesh.org/batman/releases/batman-adv-$(PKG_VERSION)
|
||||
PKG_LICENSE:=GPL-2.0
|
||||
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/batctl
|
||||
URL:=http://www.open-mesh.org/
|
||||
URL:=https://www.open-mesh.org/
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
DEPENDS:=+kmod-batman-adv +libnl-tiny +libc
|
||||
DEPENDS:=+kmod-batman-adv +libnl-tiny +libc +librt
|
||||
TITLE:=B.A.T.M.A.N. Advanced user space configuration tool batctl
|
||||
MAINTAINER:=Marek Lindner <mareklindner@neomailbox.ch>
|
||||
MAINTAINER:=Simon Wunderlich <sw@simonwunderlich.de>
|
||||
endef
|
||||
|
||||
define Package/batctl/description
|
||||
|
@ -54,7 +56,8 @@ MAKE_BATCTL_ENV += \
|
|||
CPPFLAGS="$(TARGET_CPPFLAGS)" \
|
||||
CFLAGS="$(TARGET_CFLAGS)" \
|
||||
LDFLAGS="$(TARGET_LDFLAGS)" \
|
||||
LIBNL_NAME="libnl-tiny"
|
||||
LIBNL_NAME="libnl-tiny" \
|
||||
LIBNL_GENL_NAME="libnl-tiny"
|
||||
|
||||
MAKE_BATCTL_ARGS += \
|
||||
REVISION="$(PKG_BATCTL_SHORTREV)" \
|
||||
|
|
|
@ -14,6 +14,11 @@ config KMOD_BATMAN_ADV_DAT
|
|||
depends on PACKAGE_kmod-batman-adv
|
||||
default y
|
||||
|
||||
config KMOD_BATMAN_ADV_DEBUGFS
|
||||
bool "enable debugfs support"
|
||||
depends on PACKAGE_kmod-batman-adv
|
||||
default y
|
||||
|
||||
config KMOD_BATMAN_ADV_MCAST
|
||||
bool "enable multicast transmission optimization"
|
||||
depends on PACKAGE_kmod-batman-adv
|
||||
|
@ -24,3 +29,7 @@ config KMOD_BATMAN_ADV_NC
|
|||
depends on PACKAGE_kmod-batman-adv
|
||||
default n
|
||||
|
||||
config KMOD_BATMAN_ADV_BATMAN_V
|
||||
bool "enable batman v routing algorithm"
|
||||
depends on PACKAGE_kmod-batman-adv
|
||||
default y
|
||||
|
|
|
@ -10,26 +10,26 @@ include $(TOPDIR)/rules.mk
|
|||
|
||||
PKG_NAME:=batman-adv
|
||||
|
||||
PKG_VERSION:=2014.2.0
|
||||
PKG_RELEASE:=1
|
||||
PKG_MD5SUM:=1243029b3a3e2f4fa721d1a59c2faaf5
|
||||
PKG_VERSION:=2017.0
|
||||
PKG_RELEASE:=0
|
||||
PKG_MD5SUM:=1b3121f0baa8771ff6d8ad172c95904f
|
||||
PKG_HASH:=65df01222bc51ec788fb1b6dc63feaf69d393f2d0a96e347d55de83b1602c509
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=http://downloads.open-mesh.org/batman/releases/batman-adv-$(PKG_VERSION)
|
||||
PKG_SOURCE_URL:=https://downloads.open-mesh.org/batman/releases/batman-adv-$(PKG_VERSION)
|
||||
PKG_LICENSE:=GPL-2.0
|
||||
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define KernelPackage/batman-adv
|
||||
URL:=http://www.open-mesh.org/
|
||||
MAINTAINER:=Marek Lindner <mareklindner@neomailbox.ch>
|
||||
URL:=https://www.open-mesh.org/
|
||||
MAINTAINER:=Simon Wunderlich <sw@simonwunderlich.de>
|
||||
SUBMENU:=Network Support
|
||||
DEPENDS:=+KMOD_BATMAN_ADV_BLA:kmod-lib-crc16 +kmod-crypto-core +kmod-crypto-crc32c +kmod-lib-crc32c
|
||||
DEPENDS:=+KMOD_BATMAN_ADV_BLA:kmod-lib-crc16 +kmod-crypto-crc32c +kmod-lib-crc32c +kmod-cfg80211
|
||||
TITLE:=B.A.T.M.A.N. Adv
|
||||
FILES:=$(PKG_BUILD_DIR)/batman-adv.$(LINUX_KMOD_SUFFIX)
|
||||
AUTOLOAD:=$(call AutoLoad,50,batman-adv)
|
||||
FILES:=$(PKG_BUILD_DIR)/net/batman-adv/batman-adv.$(LINUX_KMOD_SUFFIX)
|
||||
AUTOLOAD:=$(call AutoLoad,50,cfg80211 batman-adv)
|
||||
endef
|
||||
|
||||
define KernelPackage/batman-adv/description
|
||||
|
@ -42,29 +42,54 @@ define KernelPackage/batman-adv/config
|
|||
source "$(SOURCE)/Config.in"
|
||||
endef
|
||||
|
||||
MAKE_BATMAN_ADV_ARGS += \
|
||||
CROSS_COMPILE="$(TARGET_CROSS)" \
|
||||
KERNELPATH="$(LINUX_DIR)" \
|
||||
ARCH="$(LINUX_KARCH)" \
|
||||
PATH="$(TARGET_PATH)" \
|
||||
SUBDIRS="$(PKG_BUILD_DIR)" \
|
||||
PWD="$(PKG_BUILD_DIR)" \
|
||||
LINUX_VERSION="$(LINUX_VERSION)" \
|
||||
define Package/kmod-batman-adv/conffiles
|
||||
/etc/config/batman-adv
|
||||
endef
|
||||
|
||||
PKG_EXTRA_KCONFIG:= \
|
||||
CONFIG_BATMAN_ADV=m \
|
||||
CONFIG_BATMAN_ADV_DEBUG=$(if $(CONFIG_KMOD_BATMAN_ADV_DEBUG_LOG),y,n) \
|
||||
CONFIG_BATMAN_ADV_DEBUGFS=$(if $(CONFIG_KMOD_BATMAN_ADV_DEBUGFS),y,n) \
|
||||
CONFIG_BATMAN_ADV_BLA=$(if $(CONFIG_KMOD_BATMAN_ADV_BLA),y,n) \
|
||||
CONFIG_BATMAN_ADV_DAT=$(if $(CONFIG_KMOD_BATMAN_ADV_DAT),y,n) \
|
||||
CONFIG_BATMAN_ADV_MCAST=$(if $(CONFIG_KMOD_BATMAN_ADV_MCAST),y,n) \
|
||||
CONFIG_BATMAN_ADV_NC=$(if $(CONFIG_KMOD_BATMAN_ADV_NC),y,n) \
|
||||
REVISION="" all
|
||||
CONFIG_BATMAN_ADV_BATMAN_V=$(if $(CONFIG_KMOD_BATMAN_ADV_BATMAN_V),y,n) \
|
||||
|
||||
PKG_EXTRA_CFLAGS:= \
|
||||
$(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=m,%,$(filter %=m,$(PKG_EXTRA_KCONFIG)))) \
|
||||
$(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=y,%,$(filter %=y,$(PKG_EXTRA_KCONFIG)))) \
|
||||
|
||||
NOSTDINC_FLAGS = \
|
||||
-I$(PKG_BUILD_DIR)/net/batman-adv \
|
||||
-I$(STAGING_DIR)/usr/include/mac80211-backport \
|
||||
-I$(STAGING_DIR)/usr/include/mac80211-backport/uapi \
|
||||
-I$(STAGING_DIR)/usr/include/mac80211 \
|
||||
-I$(STAGING_DIR)/usr/include/mac80211/uapi \
|
||||
-I$(PKG_BUILD_DIR)/include/ \
|
||||
-include backport/backport.h \
|
||||
-include $(PKG_BUILD_DIR)/compat-hacks.h
|
||||
|
||||
COMPAT_SOURCES = \
|
||||
$(if $(CONFIG_KMOD_BATMAN_ADV_MCAST),../../compat-sources/net/core/skbuff.o,) \
|
||||
$(if $(CONFIG_KMOD_BATMAN_ADV_MCAST),../../compat-sources/net/ipv4/igmp.o,) \
|
||||
$(if $(CONFIG_KMOD_BATMAN_ADV_MCAST),../../compat-sources/net/ipv6/mcast_snoop.o,) \
|
||||
|
||||
define Build/Compile
|
||||
+env "batman-adv-y=$(COMPAT_SOURCES)" \
|
||||
$(MAKE) $(PKG_JOBS) -C "$(LINUX_DIR)" \
|
||||
ARCH="$(LINUX_KARCH)" \
|
||||
CROSS_COMPILE="$(TARGET_CROSS)" \
|
||||
SUBDIRS="$(PKG_BUILD_DIR)/net/batman-adv" \
|
||||
$(PKG_EXTRA_KCONFIG) \
|
||||
EXTRA_CFLAGS="$(PKG_EXTRA_CFLAGS)" \
|
||||
NOSTDINC_FLAGS="$(NOSTDINC_FLAGS)" \
|
||||
modules
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
$(call Build/Prepare/Default)
|
||||
$(SED) '/#define _NET_BATMAN_ADV_MAIN_H_/a\#undef CONFIG_MODULE_STRIPPED' \
|
||||
$(PKG_BUILD_DIR)/main.h
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
$(MAKE) -C "$(PKG_BUILD_DIR)" $(MAKE_BATMAN_ADV_ARGS)
|
||||
$(CP) ./files/compat-hacks.h $(PKG_BUILD_DIR)/
|
||||
endef
|
||||
|
||||
define Build/Clean
|
||||
|
|
290
batman-adv/files/compat-hacks.h
Normal file
290
batman-adv/files/compat-hacks.h
Normal file
|
@ -0,0 +1,290 @@
|
|||
/* Please avoid adding hacks here - instead add it to mac80211/backports.git */
|
||||
|
||||
#undef CONFIG_MODULE_STRIPPED
|
||||
|
||||
#include <linux/version.h> /* LINUX_VERSION_CODE */
|
||||
#include <linux/types.h>
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)
|
||||
|
||||
#define dev_get_iflink(_net_dev) ((_net_dev)->iflink)
|
||||
|
||||
#endif /* < KERNEL_VERSION(4, 1, 0) */
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0)
|
||||
|
||||
#include <linux/netdevice.h>
|
||||
|
||||
#define netdev_master_upper_dev_link(dev, upper_dev, upper_priv, upper_info) ({\
|
||||
BUILD_BUG_ON(upper_priv != NULL); \
|
||||
BUILD_BUG_ON(upper_info != NULL); \
|
||||
netdev_set_master(dev, upper_dev); \
|
||||
})
|
||||
|
||||
#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0)
|
||||
|
||||
#include <linux/netdevice.h>
|
||||
|
||||
#define netdev_master_upper_dev_link(dev, upper_dev, upper_priv, upper_info) ({\
|
||||
BUILD_BUG_ON(upper_priv != NULL); \
|
||||
BUILD_BUG_ON(upper_info != NULL); \
|
||||
netdev_master_upper_dev_link(dev, upper_dev); \
|
||||
})
|
||||
|
||||
#endif /* < KERNEL_VERSION(4, 5, 0) */
|
||||
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)
|
||||
|
||||
/* wild hack for batadv_getlink_net only */
|
||||
#define get_link_net get_xstats_size || 1 ? fallback_net : (struct net*)netdev->rtnl_link_ops->get_xstats_size
|
||||
|
||||
#endif /* < KERNEL_VERSION(4, 0, 0) */
|
||||
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 0)
|
||||
|
||||
struct sk_buff *skb_checksum_trimmed(struct sk_buff *skb,
|
||||
unsigned int transport_len,
|
||||
__sum16(*skb_chkf)(struct sk_buff *skb));
|
||||
|
||||
int ip_mc_check_igmp(struct sk_buff *skb, struct sk_buff **skb_trimmed);
|
||||
|
||||
int ipv6_mc_check_mld(struct sk_buff *skb, struct sk_buff **skb_trimmed);
|
||||
|
||||
#endif /* < KERNEL_VERSION(4, 2, 0) */
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0)
|
||||
|
||||
#define IFF_NO_QUEUE 0; dev->tx_queue_len = 0
|
||||
|
||||
static inline bool hlist_fake(struct hlist_node *h)
|
||||
{
|
||||
return h->pprev == &h->next;
|
||||
}
|
||||
|
||||
#endif /* < KERNEL_VERSION(4, 3, 0) */
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0)
|
||||
|
||||
#include <linux/ethtool.h>
|
||||
|
||||
#define ethtool_link_ksettings batadv_ethtool_link_ksettings
|
||||
|
||||
struct batadv_ethtool_link_ksettings {
|
||||
struct {
|
||||
__u32 speed;
|
||||
__u8 duplex;
|
||||
} base;
|
||||
};
|
||||
|
||||
#define __ethtool_get_link_ksettings(__dev, __link_settings) \
|
||||
batadv_ethtool_get_link_ksettings(__dev, __link_settings)
|
||||
|
||||
static inline int
|
||||
batadv_ethtool_get_link_ksettings(struct net_device *dev,
|
||||
struct ethtool_link_ksettings *link_ksettings)
|
||||
{
|
||||
struct ethtool_cmd cmd;
|
||||
int ret;
|
||||
|
||||
memset(&cmd, 0, sizeof(cmd));
|
||||
ret = __ethtool_get_settings(dev, &cmd);
|
||||
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
link_ksettings->base.duplex = cmd.duplex;
|
||||
link_ksettings->base.speed = ethtool_cmd_speed(&cmd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* < KERNEL_VERSION(4, 6, 0) */
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 7, 0)
|
||||
|
||||
#define netif_trans_update batadv_netif_trans_update
|
||||
static inline void batadv_netif_trans_update(struct net_device *dev)
|
||||
{
|
||||
dev->trans_start = jiffies;
|
||||
}
|
||||
|
||||
#endif /* < KERNEL_VERSION(4, 7, 0) */
|
||||
|
||||
|
||||
#include_next <linux/netlink.h>
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 7, 0)
|
||||
|
||||
#include_next <net/netlink.h>
|
||||
|
||||
static inline bool batadv_nla_need_padding_for_64bit(struct sk_buff *skb);
|
||||
|
||||
static inline int batadv_nla_align_64bit(struct sk_buff *skb, int padattr)
|
||||
{
|
||||
if (batadv_nla_need_padding_for_64bit(skb) &&
|
||||
!nla_reserve(skb, padattr, 0))
|
||||
return -EMSGSIZE;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline struct nlattr *batadv__nla_reserve_64bit(struct sk_buff *skb,
|
||||
int attrtype,
|
||||
int attrlen, int padattr)
|
||||
{
|
||||
if (batadv_nla_need_padding_for_64bit(skb))
|
||||
batadv_nla_align_64bit(skb, padattr);
|
||||
|
||||
return __nla_reserve(skb, attrtype, attrlen);
|
||||
}
|
||||
|
||||
static inline void batadv__nla_put_64bit(struct sk_buff *skb, int attrtype,
|
||||
int attrlen, const void *data,
|
||||
int padattr)
|
||||
{
|
||||
struct nlattr *nla;
|
||||
|
||||
nla = batadv__nla_reserve_64bit(skb, attrtype, attrlen, padattr);
|
||||
memcpy(nla_data(nla), data, attrlen);
|
||||
}
|
||||
|
||||
static inline bool batadv_nla_need_padding_for_64bit(struct sk_buff *skb)
|
||||
{
|
||||
#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
|
||||
/* The nlattr header is 4 bytes in size, that's why we test
|
||||
* if the skb->data _is_ aligned. A NOP attribute, plus
|
||||
* nlattr header for next attribute, will make nla_data()
|
||||
* 8-byte aligned.
|
||||
*/
|
||||
if (IS_ALIGNED((unsigned long)skb_tail_pointer(skb), 8))
|
||||
return true;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline int batadv_nla_total_size_64bit(int payload)
|
||||
{
|
||||
return NLA_ALIGN(nla_attr_size(payload))
|
||||
#ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
|
||||
+ NLA_ALIGN(nla_attr_size(0))
|
||||
#endif
|
||||
;
|
||||
}
|
||||
|
||||
static inline int batadv_nla_put_64bit(struct sk_buff *skb, int attrtype,
|
||||
int attrlen, const void *data,
|
||||
int padattr)
|
||||
{
|
||||
size_t len;
|
||||
|
||||
if (batadv_nla_need_padding_for_64bit(skb))
|
||||
len = batadv_nla_total_size_64bit(attrlen);
|
||||
else
|
||||
len = nla_total_size(attrlen);
|
||||
if (unlikely(skb_tailroom(skb) < len))
|
||||
return -EMSGSIZE;
|
||||
|
||||
batadv__nla_put_64bit(skb, attrtype, attrlen, data, padattr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define nla_put_u64_64bit(_skb, _attrtype, _value, _padattr) \
|
||||
batadv_nla_put_u64_64bit(_skb, _attrtype, _value, _padattr)
|
||||
static inline int batadv_nla_put_u64_64bit(struct sk_buff *skb, int attrtype,
|
||||
u64 value, int padattr)
|
||||
{
|
||||
return batadv_nla_put_64bit(skb, attrtype, sizeof(u64), &value,
|
||||
padattr);
|
||||
}
|
||||
|
||||
#endif /* < KERNEL_VERSION(4, 7, 0) */
|
||||
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0)
|
||||
|
||||
#include_next <linux/cache.h>
|
||||
|
||||
/* hack for netlink.c which marked the family ops as ro */
|
||||
#ifdef __ro_after_init
|
||||
#undef __ro_after_init
|
||||
#endif
|
||||
#define __ro_after_init
|
||||
|
||||
#endif /* < KERNEL_VERSION(4, 10, 0) */
|
||||
|
||||
/* <DECLARE_EWMA> */
|
||||
|
||||
#include <linux/version.h>
|
||||
#include_next <linux/average.h>
|
||||
|
||||
#include <linux/bug.h>
|
||||
|
||||
#ifdef DECLARE_EWMA
|
||||
#undef DECLARE_EWMA
|
||||
#endif /* DECLARE_EWMA */
|
||||
|
||||
/*
|
||||
* Exponentially weighted moving average (EWMA)
|
||||
*
|
||||
* This implements a fixed-precision EWMA algorithm, with both the
|
||||
* precision and fall-off coefficient determined at compile-time
|
||||
* and built into the generated helper funtions.
|
||||
*
|
||||
* The first argument to the macro is the name that will be used
|
||||
* for the struct and helper functions.
|
||||
*
|
||||
* The second argument, the precision, expresses how many bits are
|
||||
* used for the fractional part of the fixed-precision values.
|
||||
*
|
||||
* The third argument, the weight reciprocal, determines how the
|
||||
* new values will be weighed vs. the old state, new values will
|
||||
* get weight 1/weight_rcp and old values 1-1/weight_rcp. Note
|
||||
* that this parameter must be a power of two for efficiency.
|
||||
*/
|
||||
|
||||
#define DECLARE_EWMA(name, _precision, _weight_rcp) \
|
||||
struct ewma_##name { \
|
||||
unsigned long internal; \
|
||||
}; \
|
||||
static inline void ewma_##name##_init(struct ewma_##name *e) \
|
||||
{ \
|
||||
BUILD_BUG_ON(!__builtin_constant_p(_precision)); \
|
||||
BUILD_BUG_ON(!__builtin_constant_p(_weight_rcp)); \
|
||||
/* \
|
||||
* Even if you want to feed it just 0/1 you should have \
|
||||
* some bits for the non-fractional part... \
|
||||
*/ \
|
||||
BUILD_BUG_ON((_precision) > 30); \
|
||||
BUILD_BUG_ON_NOT_POWER_OF_2(_weight_rcp); \
|
||||
e->internal = 0; \
|
||||
} \
|
||||
static inline unsigned long \
|
||||
ewma_##name##_read(struct ewma_##name *e) \
|
||||
{ \
|
||||
BUILD_BUG_ON(!__builtin_constant_p(_precision)); \
|
||||
BUILD_BUG_ON(!__builtin_constant_p(_weight_rcp)); \
|
||||
BUILD_BUG_ON((_precision) > 30); \
|
||||
BUILD_BUG_ON_NOT_POWER_OF_2(_weight_rcp); \
|
||||
return e->internal >> (_precision); \
|
||||
} \
|
||||
static inline void ewma_##name##_add(struct ewma_##name *e, \
|
||||
unsigned long val) \
|
||||
{ \
|
||||
unsigned long internal = ACCESS_ONCE(e->internal); \
|
||||
unsigned long weight_rcp = ilog2(_weight_rcp); \
|
||||
unsigned long precision = _precision; \
|
||||
\
|
||||
BUILD_BUG_ON(!__builtin_constant_p(_precision)); \
|
||||
BUILD_BUG_ON(!__builtin_constant_p(_weight_rcp)); \
|
||||
BUILD_BUG_ON((_precision) > 30); \
|
||||
BUILD_BUG_ON_NOT_POWER_OF_2(_weight_rcp); \
|
||||
\
|
||||
ACCESS_ONCE(e->internal) = internal ? \
|
||||
(((internal << weight_rcp) - internal) + \
|
||||
(val << precision)) >> weight_rcp : \
|
||||
(val << precision); \
|
||||
}
|
||||
|
||||
/* </DECLARE_EWMA> */
|
|
@ -9,7 +9,6 @@ config 'mesh' 'bat0'
|
|||
option 'gw_sel_class'
|
||||
option 'log_level'
|
||||
option 'orig_interval'
|
||||
option 'vis_mode'
|
||||
option 'bridge_loop_avoidance'
|
||||
option 'distributed_arp_table'
|
||||
option 'multicast_mode'
|
||||
|
|
|
@ -13,7 +13,7 @@ bat_config()
|
|||
local mesh="$1"
|
||||
local aggregated_ogms ap_isolation bonding bridge_loop_avoidance distributed_arp_table fragmentation
|
||||
local gw_bandwidth gw_mode gw_sel_class isolation_mark hop_penalty multicast_mode network_coding log_level
|
||||
local orig_interval vis_mode
|
||||
local orig_interval
|
||||
|
||||
config_get aggregated_ogms "$mesh" aggregated_ogms
|
||||
config_get ap_isolation "$mesh" ap_isolation
|
||||
|
@ -30,11 +30,10 @@ bat_config()
|
|||
config_get network_coding "$mesh" network_coding
|
||||
config_get log_level "$mesh" log_level
|
||||
config_get orig_interval "$mesh" orig_interval
|
||||
config_get vis_mode "$mesh" vis_mode
|
||||
|
||||
[ ! -f "/sys/class/net/$mesh/mesh/orig_interval" ] && echo "batman-adv mesh $mesh does not exist - check your interface configuration" && return 1
|
||||
|
||||
[ -n "$aggregate_ogms" ] && echo $aggregate_ogms > /sys/class/net/$mesh/mesh/aggregate_ogms
|
||||
[ -n "$aggregated_ogms" ] && echo $aggregated_ogms > /sys/class/net/$mesh/mesh/aggregated_ogms
|
||||
[ -n "$ap_isolation" ] && echo $ap_isolation > /sys/class/net/$mesh/mesh/ap_isolation
|
||||
[ -n "$bonding" ] && echo $bonding > /sys/class/net/$mesh/mesh/bonding
|
||||
[ -n "$bridge_loop_avoidance" ] && echo $bridge_loop_avoidance > /sys/class/net/$mesh/mesh/bridge_loop_avoidance 2>&-
|
||||
|
@ -49,5 +48,4 @@ bat_config()
|
|||
[ -n "$network_coding" ] && echo $network_coding > /sys/class/net/$mesh/mesh/network_coding 2>&-
|
||||
[ -n "$log_level" ] && echo $log_level > /sys/class/net/$mesh/mesh/log_level 2>&-
|
||||
[ -n "$orig_interval" ] && echo $orig_interval > /sys/class/net/$mesh/mesh/orig_interval
|
||||
[ -n "$vis_mode" ] && echo $vis_mode > /sys/class/net/$mesh/mesh/vis_mode
|
||||
}
|
||||
|
|
|
@ -6,14 +6,18 @@ init_proto "$@"
|
|||
|
||||
proto_batadv_init_config() {
|
||||
proto_config_add_string "mesh"
|
||||
proto_config_add_string "routing_algo"
|
||||
}
|
||||
|
||||
proto_batadv_setup() {
|
||||
local config="$1"
|
||||
local iface="$2"
|
||||
|
||||
local mesh
|
||||
json_get_vars mesh
|
||||
local mesh routing_algo
|
||||
json_get_vars mesh routing_algo
|
||||
|
||||
[ -n "$routing_algo" ] || routing_algo="BATMAN_IV"
|
||||
echo "$routing_algo" > "/sys/module/batman_adv/parameters/routing_algo"
|
||||
|
||||
echo "$mesh" > "/sys/class/net/$iface/batman_adv/mesh_iface"
|
||||
proto_init_update "$iface" 1
|
||||
|
|
|
@ -0,0 +1,132 @@
|
|||
From: Johannes Berg <johannes.berg@intel.com>
|
||||
Date: Wed, 15 Feb 2017 09:49:26 +0100
|
||||
Subject: [PATCH] batman-adv: average: change to declare precision, not factor
|
||||
|
||||
Declaring the factor is counter-intuitive, and people are prone
|
||||
to using small(-ish) values even when that makes no sense.
|
||||
|
||||
Change the DECLARE_EWMA() macro to take the fractional precision,
|
||||
in bits, rather than a factor, and update all users.
|
||||
|
||||
While at it, add some more documentation.
|
||||
|
||||
Acked-by: David S. Miller <davem@davemloft.net>
|
||||
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
|
||||
[sven@narfation.org: Added compatibility code]
|
||||
Signed-off-by: Sven Eckelmann <sven@narfation.org>
|
||||
---
|
||||
compat-include/linux/average.h | 67 +++++++++++++++++++++++++++---------------
|
||||
net/batman-adv/types.h | 2 +-
|
||||
2 files changed, 45 insertions(+), 24 deletions(-)
|
||||
|
||||
diff --git a/compat-include/linux/average.h b/compat-include/linux/average.h
|
||||
index ec022cb6..a1e3c254 100644
|
||||
--- a/compat-include/linux/average.h
|
||||
+++ b/compat-include/linux/average.h
|
||||
@@ -26,49 +26,70 @@
|
||||
|
||||
#include <linux/bug.h>
|
||||
|
||||
-#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0)
|
||||
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 3, 0)
|
||||
+#undef DECLARE_EWMA
|
||||
+#endif /* < KERNEL_VERSION(4, 3, 0) */
|
||||
|
||||
-/* Exponentially weighted moving average (EWMA) */
|
||||
+/*
|
||||
+ * Exponentially weighted moving average (EWMA)
|
||||
+ *
|
||||
+ * This implements a fixed-precision EWMA algorithm, with both the
|
||||
+ * precision and fall-off coefficient determined at compile-time
|
||||
+ * and built into the generated helper funtions.
|
||||
+ *
|
||||
+ * The first argument to the macro is the name that will be used
|
||||
+ * for the struct and helper functions.
|
||||
+ *
|
||||
+ * The second argument, the precision, expresses how many bits are
|
||||
+ * used for the fractional part of the fixed-precision values.
|
||||
+ *
|
||||
+ * The third argument, the weight reciprocal, determines how the
|
||||
+ * new values will be weighed vs. the old state, new values will
|
||||
+ * get weight 1/weight_rcp and old values 1-1/weight_rcp. Note
|
||||
+ * that this parameter must be a power of two for efficiency.
|
||||
+ */
|
||||
|
||||
-#define DECLARE_EWMA(name, _factor, _weight) \
|
||||
+#define DECLARE_EWMA(name, _precision, _weight_rcp) \
|
||||
struct ewma_##name { \
|
||||
unsigned long internal; \
|
||||
}; \
|
||||
static inline void ewma_##name##_init(struct ewma_##name *e) \
|
||||
{ \
|
||||
- BUILD_BUG_ON(!__builtin_constant_p(_factor)); \
|
||||
- BUILD_BUG_ON(!__builtin_constant_p(_weight)); \
|
||||
- BUILD_BUG_ON_NOT_POWER_OF_2(_factor); \
|
||||
- BUILD_BUG_ON_NOT_POWER_OF_2(_weight); \
|
||||
+ BUILD_BUG_ON(!__builtin_constant_p(_precision)); \
|
||||
+ BUILD_BUG_ON(!__builtin_constant_p(_weight_rcp)); \
|
||||
+ /* \
|
||||
+ * Even if you want to feed it just 0/1 you should have \
|
||||
+ * some bits for the non-fractional part... \
|
||||
+ */ \
|
||||
+ BUILD_BUG_ON((_precision) > 30); \
|
||||
+ BUILD_BUG_ON_NOT_POWER_OF_2(_weight_rcp); \
|
||||
e->internal = 0; \
|
||||
} \
|
||||
static inline unsigned long \
|
||||
ewma_##name##_read(struct ewma_##name *e) \
|
||||
{ \
|
||||
- BUILD_BUG_ON(!__builtin_constant_p(_factor)); \
|
||||
- BUILD_BUG_ON(!__builtin_constant_p(_weight)); \
|
||||
- BUILD_BUG_ON_NOT_POWER_OF_2(_factor); \
|
||||
- BUILD_BUG_ON_NOT_POWER_OF_2(_weight); \
|
||||
- return e->internal >> ilog2(_factor); \
|
||||
+ BUILD_BUG_ON(!__builtin_constant_p(_precision)); \
|
||||
+ BUILD_BUG_ON(!__builtin_constant_p(_weight_rcp)); \
|
||||
+ BUILD_BUG_ON((_precision) > 30); \
|
||||
+ BUILD_BUG_ON_NOT_POWER_OF_2(_weight_rcp); \
|
||||
+ return e->internal >> (_precision); \
|
||||
} \
|
||||
static inline void ewma_##name##_add(struct ewma_##name *e, \
|
||||
unsigned long val) \
|
||||
{ \
|
||||
unsigned long internal = ACCESS_ONCE(e->internal); \
|
||||
- unsigned long weight = ilog2(_weight); \
|
||||
- unsigned long factor = ilog2(_factor); \
|
||||
+ unsigned long weight_rcp = ilog2(_weight_rcp); \
|
||||
+ unsigned long precision = _precision; \
|
||||
\
|
||||
- BUILD_BUG_ON(!__builtin_constant_p(_factor)); \
|
||||
- BUILD_BUG_ON(!__builtin_constant_p(_weight)); \
|
||||
- BUILD_BUG_ON_NOT_POWER_OF_2(_factor); \
|
||||
- BUILD_BUG_ON_NOT_POWER_OF_2(_weight); \
|
||||
+ BUILD_BUG_ON(!__builtin_constant_p(_precision)); \
|
||||
+ BUILD_BUG_ON(!__builtin_constant_p(_weight_rcp)); \
|
||||
+ BUILD_BUG_ON((_precision) > 30); \
|
||||
+ BUILD_BUG_ON_NOT_POWER_OF_2(_weight_rcp); \
|
||||
\
|
||||
ACCESS_ONCE(e->internal) = internal ? \
|
||||
- (((internal << weight) - internal) + \
|
||||
- (val << factor)) >> weight : \
|
||||
- (val << factor); \
|
||||
+ (((internal << weight_rcp) - internal) + \
|
||||
+ (val << precision)) >> weight_rcp : \
|
||||
+ (val << precision); \
|
||||
}
|
||||
|
||||
-#endif /* < KERNEL_VERSION(4, 3, 0) */
|
||||
-
|
||||
#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_AVERAGE_H */
|
||||
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
|
||||
index 8f64a5c0..66b25e41 100644
|
||||
--- a/net/batman-adv/types.h
|
||||
+++ b/net/batman-adv/types.h
|
||||
@@ -402,7 +402,7 @@ struct batadv_gw_node {
|
||||
struct rcu_head rcu;
|
||||
};
|
||||
|
||||
-DECLARE_EWMA(throughput, 1024, 8)
|
||||
+DECLARE_EWMA(throughput, 10, 8)
|
||||
|
||||
/**
|
||||
* struct batadv_hardif_neigh_node_bat_v - B.A.T.M.A.N. V private neighbor
|
|
@ -0,0 +1,103 @@
|
|||
From: Sven Eckelmann <sven@narfation.org>
|
||||
Date: Wed, 22 Feb 2017 17:25:42 +0100
|
||||
Subject: [PATCH] batman-adv: Keep fragments equally sized
|
||||
|
||||
The batman-adv fragmentation packets have the design problem that they
|
||||
cannot be refragmented and cannot handle padding by the underlying link.
|
||||
The latter often leads to problems when networks are incorrectly configured
|
||||
and don't use a common MTU.
|
||||
|
||||
The sender could for example fragment a 1271 byte frame (plus external
|
||||
ethernet header (14) and batadv unicast header (10)) to fit in a 1280 bytes
|
||||
large MTU of the underlying link (max. 1294 byte frames). This would create
|
||||
a 1294 bytes large frame (fragment 2) and a 55 bytes large frame
|
||||
(fragment 1). The extra 54 bytes are the fragment header (20) added to each
|
||||
fragment and the external ethernet header (14) for the second fragment.
|
||||
|
||||
Let us assume that the next hop is then not able to transport 1294 bytes to
|
||||
its next hop. The 1294 byte large frame will be dropped but the 55 bytes
|
||||
large fragment will still be forwarded to its destination.
|
||||
|
||||
Or let us assume that the underlying hardware requires that each frame has
|
||||
a minimum size (e.g. 60 bytes). Then it will pad the 55 bytes frame to 60
|
||||
bytes. The receiver of the 60 bytes frame will no longer be able to
|
||||
correctly assemble the two frames together because it is not aware that 5
|
||||
bytes of the 60 bytes frame are padding and don't belong to the reassembled
|
||||
frame.
|
||||
|
||||
This can partly be avoided by splitting frames more equally. In this
|
||||
example, the 675 and 674 bytes large fragment frames could both potentially
|
||||
reach its destination without being too large or too small.
|
||||
|
||||
Reported-by: Martin Weinelt <martin@darmstadt.freifunk.net>
|
||||
Fixes: db56e4ecf5c2 ("batman-adv: Fragment and send skbs larger than mtu")
|
||||
Signed-off-by: Sven Eckelmann <sven@narfation.org>
|
||||
Acked-by: Linus Lüssing <linus.luessing@c0d3.blue>
|
||||
---
|
||||
net/batman-adv/fragmentation.c | 20 +++++++++++++-------
|
||||
1 file changed, 13 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/net/batman-adv/fragmentation.c b/net/batman-adv/fragmentation.c
|
||||
index 11a23fd6..8f964bea 100644
|
||||
--- a/net/batman-adv/fragmentation.c
|
||||
+++ b/net/batman-adv/fragmentation.c
|
||||
@@ -404,7 +404,7 @@ bool batadv_frag_skb_fwd(struct sk_buff *skb,
|
||||
* batadv_frag_create - create a fragment from skb
|
||||
* @skb: skb to create fragment from
|
||||
* @frag_head: header to use in new fragment
|
||||
- * @mtu: size of new fragment
|
||||
+ * @fragment_size: size of new fragment
|
||||
*
|
||||
* Split the passed skb into two fragments: A new one with size matching the
|
||||
* passed mtu and the old one with the rest. The new skb contains data from the
|
||||
@@ -414,11 +414,11 @@ bool batadv_frag_skb_fwd(struct sk_buff *skb,
|
||||
*/
|
||||
static struct sk_buff *batadv_frag_create(struct sk_buff *skb,
|
||||
struct batadv_frag_packet *frag_head,
|
||||
- unsigned int mtu)
|
||||
+ unsigned int fragment_size)
|
||||
{
|
||||
struct sk_buff *skb_fragment;
|
||||
unsigned int header_size = sizeof(*frag_head);
|
||||
- unsigned int fragment_size = mtu - header_size;
|
||||
+ unsigned int mtu = fragment_size + header_size;
|
||||
|
||||
skb_fragment = netdev_alloc_skb(NULL, mtu + ETH_HLEN);
|
||||
if (!skb_fragment)
|
||||
@@ -456,7 +456,7 @@ int batadv_frag_send_packet(struct sk_buff *skb,
|
||||
struct sk_buff *skb_fragment;
|
||||
unsigned int mtu = neigh_node->if_incoming->net_dev->mtu;
|
||||
unsigned int header_size = sizeof(frag_header);
|
||||
- unsigned int max_fragment_size, max_packet_size;
|
||||
+ unsigned int max_fragment_size, num_fragments;
|
||||
int ret;
|
||||
|
||||
/* To avoid merge and refragmentation at next-hops we never send
|
||||
@@ -464,10 +464,15 @@ int batadv_frag_send_packet(struct sk_buff *skb,
|
||||
*/
|
||||
mtu = min_t(unsigned int, mtu, BATADV_FRAG_MAX_FRAG_SIZE);
|
||||
max_fragment_size = mtu - header_size;
|
||||
- max_packet_size = max_fragment_size * BATADV_FRAG_MAX_FRAGMENTS;
|
||||
+
|
||||
+ if (skb->len == 0 || max_fragment_size == 0)
|
||||
+ return -EINVAL;
|
||||
+
|
||||
+ num_fragments = (skb->len - 1) / max_fragment_size + 1;
|
||||
+ max_fragment_size = (skb->len - 1) / num_fragments + 1;
|
||||
|
||||
/* Don't even try to fragment, if we need more than 16 fragments */
|
||||
- if (skb->len > max_packet_size) {
|
||||
+ if (num_fragments > BATADV_FRAG_MAX_FRAGMENTS) {
|
||||
ret = -EAGAIN;
|
||||
goto free_skb;
|
||||
}
|
||||
@@ -507,7 +512,8 @@ int batadv_frag_send_packet(struct sk_buff *skb,
|
||||
goto put_primary_if;
|
||||
}
|
||||
|
||||
- skb_fragment = batadv_frag_create(skb, &frag_header, mtu);
|
||||
+ skb_fragment = batadv_frag_create(skb, &frag_header,
|
||||
+ max_fragment_size);
|
||||
if (!skb_fragment) {
|
||||
ret = -ENOMEM;
|
||||
goto put_primary_if;
|
|
@ -0,0 +1,141 @@
|
|||
From: Sven Eckelmann <sven@narfation.org>
|
||||
Date: Sat, 4 Mar 2017 15:48:50 +0100
|
||||
Subject: [PATCH] batman-adv: Initialize gw sel_class via batadv_algo
|
||||
|
||||
The gateway selection class variable is shared between different algorithm
|
||||
versions. But the interpretation of the content is algorithm specific. The
|
||||
initialization is therefore also algorithm specific.
|
||||
|
||||
But this was implemented incorrectly and the initialization for BATMAN_V
|
||||
always overwrote the value previously written for BATMAN_IV. This could
|
||||
only be avoided when BATMAN_V was disabled during compile time.
|
||||
|
||||
Using a special batadv_algo hook for this initialization avoids this
|
||||
problem.
|
||||
|
||||
Fixes: 80b2d47be2c7 ("batman-adv: B.A.T.M.A.N. V - implement GW selection logic")
|
||||
Signed-off-by: Sven Eckelmann <sven@narfation.org>
|
||||
---
|
||||
net/batman-adv/bat_iv_ogm.c | 11 +++++++++++
|
||||
net/batman-adv/bat_v.c | 14 +++++++++++---
|
||||
net/batman-adv/gateway_common.c | 5 +++++
|
||||
net/batman-adv/soft-interface.c | 1 -
|
||||
net/batman-adv/types.h | 2 ++
|
||||
5 files changed, 29 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
|
||||
index 7c3d994e..71343d0f 100644
|
||||
--- a/net/batman-adv/bat_iv_ogm.c
|
||||
+++ b/net/batman-adv/bat_iv_ogm.c
|
||||
@@ -2477,6 +2477,16 @@ static void batadv_iv_iface_activate(struct batadv_hard_iface *hard_iface)
|
||||
batadv_iv_ogm_schedule(hard_iface);
|
||||
}
|
||||
|
||||
+/**
|
||||
+ * batadv_iv_init_sel_class - initialize GW selection class
|
||||
+ * @bat_priv: the bat priv with all the soft interface information
|
||||
+ */
|
||||
+static void batadv_iv_init_sel_class(struct batadv_priv *bat_priv)
|
||||
+{
|
||||
+ /* set default TQ difference threshold to 20 */
|
||||
+ atomic_set(&bat_priv->gw.sel_class, 20);
|
||||
+}
|
||||
+
|
||||
static struct batadv_gw_node *
|
||||
batadv_iv_gw_get_best_gw_node(struct batadv_priv *bat_priv)
|
||||
{
|
||||
@@ -2823,6 +2833,7 @@ static struct batadv_algo_ops batadv_batman_iv __read_mostly = {
|
||||
.del_if = batadv_iv_ogm_orig_del_if,
|
||||
},
|
||||
.gw = {
|
||||
+ .init_sel_class = batadv_iv_init_sel_class,
|
||||
.get_best_gw_node = batadv_iv_gw_get_best_gw_node,
|
||||
.is_eligible = batadv_iv_gw_is_eligible,
|
||||
#ifdef CONFIG_BATMAN_ADV_DEBUGFS
|
||||
diff --git a/net/batman-adv/bat_v.c b/net/batman-adv/bat_v.c
|
||||
index 0acd081d..a36c8e72 100644
|
||||
--- a/net/batman-adv/bat_v.c
|
||||
+++ b/net/batman-adv/bat_v.c
|
||||
@@ -668,6 +668,16 @@ static bool batadv_v_neigh_is_sob(struct batadv_neigh_node *neigh1,
|
||||
return ret;
|
||||
}
|
||||
|
||||
+/**
|
||||
+ * batadv_v_init_sel_class - initialize GW selection class
|
||||
+ * @bat_priv: the bat priv with all the soft interface information
|
||||
+ */
|
||||
+static void batadv_v_init_sel_class(struct batadv_priv *bat_priv)
|
||||
+{
|
||||
+ /* set default throughput difference threshold to 5Mbps */
|
||||
+ atomic_set(&bat_priv->gw.sel_class, 50);
|
||||
+}
|
||||
+
|
||||
static ssize_t batadv_v_store_sel_class(struct batadv_priv *bat_priv,
|
||||
char *buff, size_t count)
|
||||
{
|
||||
@@ -1052,6 +1062,7 @@ static struct batadv_algo_ops batadv_batman_v __read_mostly = {
|
||||
.dump = batadv_v_orig_dump,
|
||||
},
|
||||
.gw = {
|
||||
+ .init_sel_class = batadv_v_init_sel_class,
|
||||
.store_sel_class = batadv_v_store_sel_class,
|
||||
.show_sel_class = batadv_v_show_sel_class,
|
||||
.get_best_gw_node = batadv_v_gw_get_best_gw_node,
|
||||
@@ -1092,9 +1103,6 @@ int batadv_v_mesh_init(struct batadv_priv *bat_priv)
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
- /* set default throughput difference threshold to 5Mbps */
|
||||
- atomic_set(&bat_priv->gw.sel_class, 50);
|
||||
-
|
||||
return 0;
|
||||
}
|
||||
|
||||
diff --git a/net/batman-adv/gateway_common.c b/net/batman-adv/gateway_common.c
|
||||
index 5db2e43e..33940c5c 100644
|
||||
--- a/net/batman-adv/gateway_common.c
|
||||
+++ b/net/batman-adv/gateway_common.c
|
||||
@@ -253,6 +253,11 @@ static void batadv_gw_tvlv_ogm_handler_v1(struct batadv_priv *bat_priv,
|
||||
*/
|
||||
void batadv_gw_init(struct batadv_priv *bat_priv)
|
||||
{
|
||||
+ if (bat_priv->algo_ops->gw.init_sel_class)
|
||||
+ bat_priv->algo_ops->gw.init_sel_class(bat_priv);
|
||||
+ else
|
||||
+ atomic_set(&bat_priv->gw.sel_class, 1);
|
||||
+
|
||||
batadv_tvlv_handler_register(bat_priv, batadv_gw_tvlv_ogm_handler_v1,
|
||||
NULL, BATADV_TVLV_GW, 1,
|
||||
BATADV_TVLV_HANDLER_OGM_CIFNOTFND);
|
||||
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
|
||||
index 5d099b2e..d042c99a 100644
|
||||
--- a/net/batman-adv/soft-interface.c
|
||||
+++ b/net/batman-adv/soft-interface.c
|
||||
@@ -819,7 +819,6 @@ static int batadv_softif_init_late(struct net_device *dev)
|
||||
atomic_set(&bat_priv->mcast.num_want_all_ipv6, 0);
|
||||
#endif
|
||||
atomic_set(&bat_priv->gw.mode, BATADV_GW_MODE_OFF);
|
||||
- atomic_set(&bat_priv->gw.sel_class, 20);
|
||||
atomic_set(&bat_priv->gw.bandwidth_down, 100);
|
||||
atomic_set(&bat_priv->gw.bandwidth_up, 20);
|
||||
atomic_set(&bat_priv->orig_interval, 1000);
|
||||
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
|
||||
index 66b25e41..246f21b4 100644
|
||||
--- a/net/batman-adv/types.h
|
||||
+++ b/net/batman-adv/types.h
|
||||
@@ -1489,6 +1489,7 @@ struct batadv_algo_orig_ops {
|
||||
|
||||
/**
|
||||
* struct batadv_algo_gw_ops - mesh algorithm callbacks (GW specific)
|
||||
+ * @init_sel_class: initialize GW selection class (optional)
|
||||
* @store_sel_class: parse and stores a new GW selection class (optional)
|
||||
* @show_sel_class: prints the current GW selection class (optional)
|
||||
* @get_best_gw_node: select the best GW from the list of available nodes
|
||||
@@ -1499,6 +1500,7 @@ struct batadv_algo_orig_ops {
|
||||
* @dump: dump gateways to a netlink socket (optional)
|
||||
*/
|
||||
struct batadv_algo_gw_ops {
|
||||
+ void (*init_sel_class)(struct batadv_priv *bat_priv);
|
||||
ssize_t (*store_sel_class)(struct batadv_priv *bat_priv, char *buff,
|
||||
size_t count);
|
||||
ssize_t (*show_sel_class)(struct batadv_priv *bat_priv, char *buff);
|
|
@ -9,25 +9,29 @@ include $(TOPDIR)/rules.mk
|
|||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_NAME:=batmand
|
||||
PKG_REV:=1439
|
||||
PKG_VERSION:=r$(PKG_REV)
|
||||
PKG_RELEASE:=2
|
||||
PKG_EXTRA_CFLAGS=-DDEBUG_MALLOC -DMEMORY_USAGE -DPROFILE_DATA -DREVISION_VERSION=\"\ rv$(PKG_REV)\"
|
||||
|
||||
PKG_SOURCE_PROTO:=svn
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=git://git.open-mesh.org/batmand.git
|
||||
PKG_REV:=b67a7087b51d7a5e90d27ac39116d1f57257c86e
|
||||
PKG_VERSION:=1440
|
||||
PKG_RELEASE:=0
|
||||
PKG_LICENSE:=GPL-2.0
|
||||
|
||||
PKG_SOURCE_VERSION:=$(PKG_REV)
|
||||
PKG_SOURCE_SUBDIR:=$(if $(PKG_BRANCH),$(PKG_BRANCH),$(PKG_NAME))-$(PKG_VERSION)
|
||||
PKG_SOURCE_URL:=http://downloads.open-mesh.org/svn/batman/trunk/
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
PKG_SOURCE:=$(PKG_SOURCE_SUBDIR).tar.gz
|
||||
PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_SOURCE_SUBDIR)
|
||||
PKG_MIRROR_HASH:=ceb8e0e399f79b1b663594fcf9642e1efc40e696a7604daf709c77da9b6ec52f
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_SOURCE_SUBDIR)
|
||||
|
||||
PKG_KMOD_BUILD_DIR:=$(PKG_BUILD_DIR)/batman/linux/modules
|
||||
PKG_EXTRA_CFLAGS=-DDEBUG_MALLOC -DMEMORY_USAGE -DPROFILE_DATA -DREVISION_VERSION=\"\ rv$(PKG_REV)\" -D_GNU_SOURCE
|
||||
|
||||
PKG_KMOD_BUILD_DIR:=$(PKG_BUILD_DIR)/linux/modules
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/batmand/Default
|
||||
URL:=http://www.open-mesh.org/
|
||||
MAINTAINER:=Marek Lindner <lindner_marek@yahoo.de>
|
||||
URL:=https://www.open-mesh.org/
|
||||
MAINTAINER:=Corinna "Elektra" Aichele <onelektra@gmx.net>
|
||||
endef
|
||||
|
||||
define Package/batmand
|
||||
|
@ -43,19 +47,6 @@ define Package/batmand/description
|
|||
B.A.T.M.A.N. layer 3 routing daemon
|
||||
endef
|
||||
|
||||
define Package/vis
|
||||
$(call Package/batmand/Default)
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
SUBMENU:=Routing and Redirection
|
||||
DEPENDS:=+libpthread
|
||||
TITLE:=visualization server for B.A.T.M.A.N. layer 3
|
||||
endef
|
||||
|
||||
define Package/vis/description
|
||||
visualization server for B.A.T.M.A.N. layer 3
|
||||
endef
|
||||
|
||||
define KernelPackage/batgat
|
||||
$(call Package/batmand/Default)
|
||||
SUBMENU:=Network Support
|
||||
|
@ -81,18 +72,6 @@ MAKE_BATMAND_ARGS += \
|
|||
INSTALL_PREFIX="$(PKG_INSTALL_DIR)" \
|
||||
STRIP="/bin/true" \
|
||||
batmand install
|
||||
|
||||
MAKE_VIS_ARGS += \
|
||||
EXTRA_CFLAGS='$(TARGET_CFLAGS) $(PKG_EXTRA_CFLAGS)' \
|
||||
CCFLAGS="$(TARGET_CFLAGS)" \
|
||||
OFLAGS="$(TARGET_CFLAGS)" \
|
||||
REVISION="$(PKG_REV)" \
|
||||
CC="$(TARGET_CC)" \
|
||||
NODEBUG=1 \
|
||||
UNAME="Linux" \
|
||||
INSTALL_PREFIX="$(PKG_INSTALL_DIR)" \
|
||||
STRIP="/bin/true" \
|
||||
vis install
|
||||
|
||||
MAKE_BATGAT_ARGS += \
|
||||
CROSS_COMPILE="$(TARGET_CROSS)" \
|
||||
|
@ -107,11 +86,7 @@ define Build/Configure
|
|||
endef
|
||||
|
||||
ifneq ($(DEVELOPER)$(CONFIG_PACKAGE_batmand),)
|
||||
BUILD_BATMAND := $(MAKE) -C $(PKG_BUILD_DIR)/batman $(MAKE_BATMAND_ARGS)
|
||||
endif
|
||||
|
||||
ifneq ($(DEVELOPER)$(CONFIG_PACKAGE_vis),)
|
||||
BUILD_VIS := $(MAKE) -C $(PKG_BUILD_DIR)/vis $(MAKE_VIS_ARGS)
|
||||
BUILD_BATMAND := $(MAKE) -C $(PKG_BUILD_DIR) $(MAKE_BATMAND_ARGS)
|
||||
endif
|
||||
|
||||
ifneq ($(DEVELOPER)$(CONFIG_PACKAGE_kmod-batgat),)
|
||||
|
@ -120,7 +95,6 @@ endif
|
|||
|
||||
define Build/Compile
|
||||
$(BUILD_BATMAND)
|
||||
$(BUILD_VIS)
|
||||
cp $(PKG_KMOD_BUILD_DIR)/Makefile.kbuild $(PKG_KMOD_BUILD_DIR)/Makefile
|
||||
$(BUILD_BATGAT)
|
||||
endef
|
||||
|
@ -136,17 +110,5 @@ define Package/batmand/conffiles
|
|||
/etc/config/batmand
|
||||
endef
|
||||
|
||||
define Package/vis/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/config $(1)/etc/init.d
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/vis $(1)/usr/sbin/
|
||||
$(INSTALL_BIN) ./files/etc/init.d/vis $(1)/etc/init.d
|
||||
$(INSTALL_DATA) ./files/etc/config/vis $(1)/etc/config
|
||||
endef
|
||||
|
||||
define Package/vis/conffiles
|
||||
/etc/config/vis
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,batmand))
|
||||
$(eval $(call BuildPackage,vis))
|
||||
$(eval $(call KernelPackage,batgat))
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
batman/linux/modules/gateway.c | 19 +++++++++++++++++++
|
||||
1 file changed, 19 insertions(+)
|
||||
|
||||
--- batmand-r1439.orig/batman/linux/modules/gateway.c
|
||||
+++ batmand-r1439/batman/linux/modules/gateway.c
|
||||
--- batmand-r1439.orig/linux/modules/gateway.c
|
||||
+++ batmand-r1439/linux/modules/gateway.c
|
||||
@@ -29,6 +29,7 @@ static struct class *batman_class;
|
||||
static int batgat_open(struct inode *inode, struct file *filp);
|
||||
static int batgat_release(struct inode *inode, struct file *file);
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
#
|
||||
# Copyright (C) 2014 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
# Please note this is not an officially released version of bcp38
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=bcp38
|
||||
PKG_VERSION:=4
|
||||
PKG_RELEASE:=1
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/bcp38
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
SUBMENU:=Routing and Redirection
|
||||
TITLE:=BCP38 compliance
|
||||
URL:=http://www.github.com/dtaht/bcp38
|
||||
MAINTAINER:=Dave Taht <d+bcp38@taht.net>
|
||||
DEPENDS:=+ipset
|
||||
endef
|
||||
|
||||
define Package/bcp38/description
|
||||
bcp38 implements rfc bcp 38 for home routers.
|
||||
endef
|
||||
|
||||
define Package/bcp38/conffiles
|
||||
/etc/config/bcp38
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
endef
|
||||
|
||||
define Build/Configure
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
define Package/bcp38/install
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_CONF) ./files/bcp38.config $(1)/etc/config/bcp38
|
||||
$(INSTALL_DIR) $(1)/usr/lib/bcp38
|
||||
$(INSTALL_BIN) ./files/run.sh $(1)/usr/lib/bcp38/run.sh
|
||||
$(INSTALL_DIR) $(1)/etc/uci-defaults
|
||||
$(INSTALL_BIN) ./files/bcp38.defaults $(1)/etc/uci-defaults/bcp38
|
||||
endef
|
||||
|
||||
define Package/bcp38/postinst
|
||||
#!/bin/sh
|
||||
[ -x /etc/uci-defaults/bcp38 ] && /etc/uci-defaults/bcp38 || exit 0
|
||||
endef
|
||||
|
||||
define Package/bcp38/postrm
|
||||
#!/bin/sh
|
||||
uci delete firewall.bcp38
|
||||
uci commit
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,bcp38))
|
|
@ -1,22 +0,0 @@
|
|||
config bcp38
|
||||
option enabled 1
|
||||
option interface 'ge00'
|
||||
option detect_upstream 1
|
||||
list match '127.0.0.0/8'
|
||||
list match '0.0.0.0/8' # RFC 1700
|
||||
list match '240.0.0.0/4' # RFC 5745
|
||||
list match '192.0.2.0/24' # RFC 5737
|
||||
list match '198.51.100.0/24' # RFC 5737
|
||||
list match '203.0.113.0/24' # RFC 5737
|
||||
list match '192.168.0.0/16' # RFC 1918
|
||||
list match '10.0.0.0/8' # RFC 1918
|
||||
list match '172.16.0.0/12' # RFC 1918
|
||||
list match '169.254.0.0/16' # RFC 3927
|
||||
|
||||
# list nomatch '172.26.0.0/21' # Example of something not to match
|
||||
# There is a dhcp trigger to do this for the netmask of a
|
||||
# double natted connection needed
|
||||
|
||||
# I will argue that this level of indirection doesn't scale
|
||||
# very well - see how to block china as an example
|
||||
# http://www.okean.com/china.txt
|
|
@ -1,13 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
uci -q batch <<-EOT
|
||||
delete firewall.bcp38
|
||||
set firewall.bcp38=include
|
||||
set firewall.bcp38.type=script
|
||||
set firewall.bcp38.path=/usr/lib/bcp38/run.sh
|
||||
set firewall.bcp38.family=IPv4
|
||||
set firewall.bcp38.reload=1
|
||||
commit firewall
|
||||
EOT
|
||||
|
||||
exit 0
|
|
@ -1,96 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
STOP=$1
|
||||
IPSET_NAME=bcp38-ipv4
|
||||
IPTABLES_CHAIN=BCP38
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
config_load bcp38
|
||||
|
||||
add_bcp38_rule()
|
||||
{
|
||||
local subnet="$1"
|
||||
local action="$2"
|
||||
|
||||
if [ "$action" == "nomatch" ]; then
|
||||
ipset add "$IPSET_NAME" "$subnet" nomatch
|
||||
else
|
||||
ipset add "$IPSET_NAME" "$subnet"
|
||||
fi
|
||||
}
|
||||
|
||||
detect_upstream()
|
||||
{
|
||||
local interface="$1"
|
||||
|
||||
subnets=$(ip route show dev "$interface" | grep 'scope link' | awk '{print $1}')
|
||||
for subnet in $subnets; do
|
||||
# ipset test doesn't work for subnets, so strip out the subnet part
|
||||
# and test for that; add as exception if there's a match
|
||||
addr=$(echo $subnet | sed 's|/[0-9]\+$||')
|
||||
ipset test "$IPSET_NAME" $addr 2>/dev/null && add_bcp38_rule $subnet nomatch
|
||||
done
|
||||
}
|
||||
|
||||
run() {
|
||||
local section="$1"
|
||||
local enabled
|
||||
local interface
|
||||
local detect_upstream
|
||||
config_get_bool enabled "$section" enabled 0
|
||||
config_get interface "$section" interface
|
||||
config_get detect_upstream "$section" detect_upstream
|
||||
|
||||
if [ "$enabled" -eq "1" -a -n "$interface" -a -z "$STOP" ] ; then
|
||||
setup_ipset
|
||||
setup_iptables "$interface"
|
||||
config_list_foreach "$section" match add_bcp38_rule match
|
||||
config_list_foreach "$section" nomatch add_bcp38_rule nomatch
|
||||
[ "$detect_upstream" -eq "1" ] && detect_upstream "$interface"
|
||||
fi
|
||||
exit 0
|
||||
}
|
||||
|
||||
setup_ipset()
|
||||
{
|
||||
ipset create "$IPSET_NAME" hash:net family ipv4
|
||||
ipset flush "$IPSET_NAME"
|
||||
}
|
||||
|
||||
setup_iptables()
|
||||
{
|
||||
local interface="$1"
|
||||
iptables -N "$IPTABLES_CHAIN" 2>/dev/null
|
||||
iptables -F "$IPTABLES_CHAIN" 2>/dev/null
|
||||
|
||||
iptables -I output_rule -j "$IPTABLES_CHAIN"
|
||||
iptables -I input_rule -j "$IPTABLES_CHAIN"
|
||||
iptables -I forwarding_rule -j "$IPTABLES_CHAIN"
|
||||
|
||||
# always accept DHCP traffic
|
||||
iptables -A "$IPTABLES_CHAIN" -p udp --dport 67:68 --sport 67:68 -j RETURN
|
||||
iptables -A "$IPTABLES_CHAIN" -o "$interface" -m set --match-set "$IPSET_NAME" dst -j REJECT --reject-with icmp-net-unreachable
|
||||
iptables -A "$IPTABLES_CHAIN" -i "$interface" -m set --match-set "$IPSET_NAME" src -j DROP
|
||||
}
|
||||
|
||||
destroy_ipset()
|
||||
{
|
||||
ipset flush "$IPSET_NAME" 2>/dev/null
|
||||
ipset destroy "$IPSET_NAME" 2>/dev/null
|
||||
}
|
||||
|
||||
destroy_iptables()
|
||||
{
|
||||
iptables -D output_rule -j "$IPTABLES_CHAIN" 2>/dev/null
|
||||
iptables -D input_rule -j "$IPTABLES_CHAIN" 2>/dev/null
|
||||
iptables -D forwarding_rule -j "$IPTABLES_CHAIN" 2>/dev/null
|
||||
iptables -F "$IPTABLES_CHAIN" 2>/dev/null
|
||||
iptables -X "$IPTABLES_CHAIN" 2>/dev/null
|
||||
}
|
||||
|
||||
destroy_iptables
|
||||
destroy_ipset
|
||||
config_foreach run bcp38
|
||||
|
||||
exit 0
|
531
bird-openwrt/DOCUMENTATION
Normal file
531
bird-openwrt/DOCUMENTATION
Normal file
|
@ -0,0 +1,531 @@
|
|||
---------------------------------------------------------------------
|
||||
|
||||
Copyright (C) 2014 - Eloi Carbó Solé (GSoC2014)
|
||||
BGP/Bird integration with OpenWRT
|
||||
|
||||
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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
---------------------------------------------------------------------
|
||||
|
||||
*** Original documentation for BIRD Daemon can be found here: http://bird.network.cz/?get_doc
|
||||
*** Some interesting examples are placed in BIRD daemon Gitlab page: https://gitlab.labs.nic.cz/labs/bird/wikis/home
|
||||
*** If you want to add new options to bird*-openwrt packages,
|
||||
*** feel free to make a pull request it in: https://github.com/openwrt-routing/packages/bird-openwrt
|
||||
*** or email me and ask for it: eloicaso@openmailbox.org
|
||||
|
||||
- Options used in /etc/config/birdX -
|
||||
|
||||
---------------------------------------------------------------------
|
||||
CONFIGURATION SECTION 1: 'bird'
|
||||
---------------------------------------------------------------------
|
||||
|
||||
Example
|
||||
--
|
||||
config bird 'bird'
|
||||
option use_UCI_config '1'
|
||||
option UCI_config_file '/tmp/bird4.conf'
|
||||
--
|
||||
|
||||
* use_UCI_config: Boolean
|
||||
This option allows you to use UCI configuration translation file instead of the original Bird one. If true/1, birdX init.d script will use the translation placed in "UCI_config_file". Otherwise, it will use the default "/etc/birdX.conf" configuration.
|
||||
[Hint] This could be used to allow multiple configurations and swap them easily.
|
||||
Default: 0
|
||||
|
||||
* UCI_config_file: String (File path)
|
||||
This option sets where will be placed the translation of the UCI configuration file.
|
||||
Default: /tmp/birdX.conf
|
||||
|
||||
|
||||
|
||||
---------------------------------------------------------------------
|
||||
CONFIGURATION SECTION 2: 'global NAME'
|
||||
---------------------------------------------------------------------
|
||||
|
||||
Example
|
||||
--
|
||||
config global 'global'
|
||||
option log_file '/tmp/bird4.log'
|
||||
option log 'all'
|
||||
option debug 'off'
|
||||
option router_id '172.16.1.6'
|
||||
--
|
||||
|
||||
* log_file: String (File path)
|
||||
This option sets the path of the file used to save Bird Log and Debug's information.
|
||||
Default: /tmp/birdX.log
|
||||
|
||||
* log: String/Enumeration (all/off, info, warning, error, fatal, debug, trace, remote, auth, bug)
|
||||
This option allows you to set which information you want to save in the
|
||||
[HINT] Use the enumeration like: { info, waning, error }
|
||||
Default: all
|
||||
|
||||
* debug: String/Enumeration ( all/off, states, routes, filters, interfaces, events, packets)
|
||||
This option allows you to set which debug information will be saved in the "log_file" file.
|
||||
[HINT] Use the enumeration like: { info, waning, error }
|
||||
Default: off
|
||||
|
||||
* router_id: IP Address
|
||||
This option sets which will be the Router ID. Usually is the lowest IP address (not loopback) among the existing interfaces.
|
||||
[HINT] In IPv4 this field is optional. In IPv6 is mandatory.
|
||||
|
||||
* listen_bgp_addr: IP Address
|
||||
This option sets the IP address that Bird BGP instances will listen by default.
|
||||
Default: 0.0.0.0
|
||||
|
||||
* listen_bgp_port: Integer (Port)
|
||||
This option sets the port that Bird BGP instances will listen by default.
|
||||
Default: 179
|
||||
|
||||
[IPv6 only]
|
||||
* listen_bgp_dual: Boolean
|
||||
This option sets if Bird6 BGP instances will listen only to IPv6 or IPv4/6 BGP routes.
|
||||
|
||||
|
||||
|
||||
---------------------------------------------------------------------
|
||||
CONFIGURATION SECTION 3: 'table'
|
||||
---------------------------------------------------------------------
|
||||
|
||||
Example
|
||||
--
|
||||
config table
|
||||
option name 'aux'
|
||||
--
|
||||
|
||||
* name: String
|
||||
This option allows you to set the name of the auxiliar kernel tables used for Bird.
|
||||
|
||||
|
||||
|
||||
---------------------------------------------------------------------
|
||||
CONFIGURATION SECTION 4: 'kernel NAME'
|
||||
---------------------------------------------------------------------
|
||||
|
||||
Example
|
||||
--
|
||||
config kernel kernel1
|
||||
option table 'aux'
|
||||
option import 'all'
|
||||
option export 'all'
|
||||
option kernel_table '100'
|
||||
option scan_time '10'
|
||||
option learn '1'
|
||||
option persist '0'
|
||||
option disabled '0'
|
||||
--
|
||||
|
||||
* table: String
|
||||
Set an auxiliary table for the current kernel routing instance. This table MUST exist as a SECTION 3 instance.
|
||||
[HINT] If there is an Kernel protocol instance that uses the "main" kernel table (not using table/kernel_table options), this should be included before the rest of Kernel instances (which will use auxiliary tables).
|
||||
|
||||
* import: String/Filter function
|
||||
This option delimits which routes coming from other protocols will be accepted. This option allows filters in different manners:
|
||||
1. All/none: allows to import all the routes or none of them.
|
||||
2. Filter name: [import 'bgp_filter_in'] the protocol will use the filter with the Filter name. (Needs an existing filter declared in the UCI configuration file)
|
||||
|
||||
* export: String/Filter function
|
||||
This option delimits which routes going out from the protocol. This option allows filters in different manners:
|
||||
1. All/none: allows to export all the routes or none of them.
|
||||
2. Filter name: [export 'bgp_filter_out'] the protocol will use the filter with the 'Filter name'. (Needs an existing filter declared in the UCI configuration file)
|
||||
|
||||
* kernel_table: Integer
|
||||
This option sets the identification number of the Kernel table that will be used instead of the main one.
|
||||
Default: main table (254)
|
||||
|
||||
* scan_time: Integer
|
||||
This option sets the time between checks to the selected kernel table.
|
||||
|
||||
* learn: Boolean
|
||||
Set if the kernel table will add the routes from other routing protocols or the system administrator.
|
||||
|
||||
* persist: Boolean
|
||||
Set if Bird Daemon will save the known routes when exiting or if it will clean the routing table.
|
||||
|
||||
* disable: Boolean
|
||||
This option sets if the protocol will be used or dismissed.
|
||||
Default: 0
|
||||
|
||||
|
||||
|
||||
---------------------------------------------------------------------
|
||||
CONFIGURATION SECTION 5: 'device NAME'
|
||||
---------------------------------------------------------------------
|
||||
|
||||
Example
|
||||
--
|
||||
config device device1
|
||||
option scan_time '10'
|
||||
option disabled '0'
|
||||
--
|
||||
|
||||
* scan_time: Integer
|
||||
This option sets the time between checks to the selected kernel table.
|
||||
|
||||
* disable: Boolean
|
||||
This option sets if the protocol will be used or dismissed.
|
||||
Default: 0
|
||||
|
||||
|
||||
|
||||
CONFIGURATION SECTION 6: 'static NAME'
|
||||
|
||||
Example
|
||||
--
|
||||
config static static1
|
||||
option table 'aux'
|
||||
option disabled '0'
|
||||
--
|
||||
|
||||
* table: String
|
||||
Set an auxiliary table for the current static instance. This table MUST exist as a SECTION 3 instance.
|
||||
[HINT] If there is an static instance that uses the "main" kernel table (not using table/kernel_table options), this should be included before the rest of static instances (which will use auxiliary tables).
|
||||
|
||||
* disable: Boolean
|
||||
This option sets if the protocol will be used or dismissed.
|
||||
Default: 0
|
||||
|
||||
|
||||
|
||||
---------------------------------------------------------------------
|
||||
CONFIGURATION SECTION 7 & 8: 'bgp NAME' & 'bgp_template NAME'
|
||||
---------------------------------------------------------------------
|
||||
|
||||
This section merges two different configuration sections: bgp instances and templates. The first one is the basic bgp configuration part and the second one is the template used to minimize the number of options written in the configuration file. Both configuration sections has the same options, but when Bird found duplicities, the bgp instance has priority over the template.
|
||||
|
||||
Examples
|
||||
|
||||
-- instance --
|
||||
config bgp bgp1
|
||||
option template 'bgp_common'
|
||||
option description 'Description of the BGP instance'
|
||||
option neighbor_address '172.16.1.5'
|
||||
option neighbor_as '65530'
|
||||
option source_address '172.16.1.6'
|
||||
option next_hop_self '0'
|
||||
option next_hop_keep '0'
|
||||
option rr_client '1'
|
||||
option rr_cluster_id '172.16.1.6'
|
||||
--
|
||||
-- template --
|
||||
config bgp_template bgp_common
|
||||
option table 'aux'
|
||||
option import 'all'
|
||||
option export 'all'
|
||||
option local_address '172.16.1.6'
|
||||
option local_as '65001'
|
||||
option import_limit '100'
|
||||
option import_limit_action 'warn'
|
||||
option export_limit '100'
|
||||
option export_limit_action 'warn'
|
||||
option receive_limit '100'
|
||||
option receive_limit_action 'warn'
|
||||
option disabled '0'
|
||||
--
|
||||
|
||||
* template: String
|
||||
This option states the template used for current BGP instance. This template MUST exist as a SECTION 8 instance.
|
||||
|
||||
* description: String
|
||||
This option allows to add a description of the bgp instance and its function
|
||||
|
||||
* local_addr: IP address
|
||||
This optional option allows to set the IP source of our Autonomous System (AS).
|
||||
|
||||
* local_as: Integer
|
||||
This option allows to set the identification number of our AS number. This option is mandatory for each BGP instance.
|
||||
|
||||
* neighbor_addr: IP address
|
||||
Each BGP instance has a neighbor connected to. This option allows to set its IP address
|
||||
|
||||
* neighbor_as: Integer
|
||||
Each BGP instance has a neighbor connected to. This option allows to set its AS ID.
|
||||
|
||||
* next_hop_self: Boolean
|
||||
If this option is true, BGP protocol will avoid to calculate the next hop and always advertise own "Router id" IP .
|
||||
Default: 0
|
||||
|
||||
* next_hop_keep: Boolean
|
||||
If this option is true, BGP will always use the received next_hop information to redirect the route.
|
||||
Default: 0
|
||||
|
||||
* rr_client: Boolean
|
||||
IF this option is true, the router will be set as Route Reflector and will treat the rest of the routers as RR clients.
|
||||
Default: 0
|
||||
|
||||
* rr_cluster_id: Integer
|
||||
This option sets the identification number of the RR cluster. All the nodes in a cluster needs this option and share the same number.
|
||||
Default: Router id
|
||||
|
||||
* import_limit: Integer
|
||||
This option sets the limit of routes that a protocol can import until take the action indicated in the import_limit_action.
|
||||
import_limit also counts filtered routes (even dropped).
|
||||
Default: 0 (no limit)
|
||||
|
||||
* import_limit_action: String
|
||||
This option allows to decide the action to take when reached the limit of imported routes.
|
||||
Actions are: warn, block, restart, disable
|
||||
|
||||
* export_limit: Integer
|
||||
This option sets the limit of routes that a protocol can export until take the action indicated in the export_limit_action.
|
||||
Default: 0 (no limit)
|
||||
|
||||
* export_limit_action: String
|
||||
This option allows to decide the action to take when reached the limit of exported routes.
|
||||
Actions are: warn, block, restart, disable
|
||||
|
||||
* receive_limit: Integer
|
||||
This option sets the limit of routes that a protocol can receive until take the action indicated in the receive_limit_action. receive_limit only counts accepted routes from the protocol.
|
||||
Default: 0 (no limit)
|
||||
|
||||
* receive_limit_action: String
|
||||
This option allows to decide the action to take when reached the limit of received routes.
|
||||
Actions are: warn, block, restart, disable
|
||||
|
||||
* disable: Boolean
|
||||
This option sets if the protocol will be used or dismissed.
|
||||
Default: 0
|
||||
|
||||
|
||||
|
||||
---------------------------------------------------------------------
|
||||
CONFIGURATION SECTION 9: 'route'
|
||||
---------------------------------------------------------------------
|
||||
|
||||
Example
|
||||
--
|
||||
config route
|
||||
option instance 'static1'
|
||||
option type 'router'
|
||||
option prefix '192.168.9.0/24'
|
||||
option via '10.99.105.159'
|
||||
|
||||
config route
|
||||
option instance 'static1'
|
||||
option type 'special'
|
||||
option prefix '192.168.2.0/24'
|
||||
option attribute 'unreachable'
|
||||
|
||||
config route
|
||||
option instance 'static1'
|
||||
option type 'iface'
|
||||
option prefix '192.168.3.0/24'
|
||||
option iface 'mgmt0'
|
||||
|
||||
config route
|
||||
option instance 'static1'
|
||||
option type 'recursive'
|
||||
option prefix '192.168.4.0/24'
|
||||
option ip '192.168.1.1'
|
||||
|
||||
config route
|
||||
option instance 'static1'
|
||||
option type 'multipath'
|
||||
option prefix '192.168.30.0/24'
|
||||
list l_via '172.16.1.5'
|
||||
list l_via '172.16.1.6'
|
||||
--
|
||||
|
||||
* instance: String
|
||||
This option indicates the route that the static protocol instance will apply.
|
||||
|
||||
* type: String
|
||||
This option states the type of route that will be applied. Also defines the options available for it.
|
||||
Types are: 'router', 'special', 'iface', 'recursive' or 'multipath'.
|
||||
|
||||
* prefix: IP address/network
|
||||
This option allows to define the network that you want to define.
|
||||
|
||||
[router only]
|
||||
* via: IP Address
|
||||
This option indicates the IP address of the neighbor router where the routes will pass through.
|
||||
|
||||
[special only]
|
||||
* attribute: String
|
||||
This option will mark the behaviour of the route.
|
||||
Attribures are: 'blackhole', 'unreachable' or 'prohibit'.
|
||||
|
||||
[iface only]
|
||||
* iface: String
|
||||
This option indicates the interface used to redirect the BGP routes. Careful, the interface MUST exist, or Bird will fail to start.
|
||||
|
||||
[recursive only]
|
||||
* ip: IP address
|
||||
This option states the IP address which the next hop will depend on.
|
||||
|
||||
[multipath only][This is a list, not an option. Use it as in the example, or check the UCI configuration documentation.]
|
||||
* l_via: IP address
|
||||
This list of IPs specifies the list (following the sequence) of routers that the route will follow as next hops.
|
||||
|
||||
|
||||
|
||||
---------------------------------------------------------------------
|
||||
CONFIGURATION SECTION 10: 'filter NAME'
|
||||
---------------------------------------------------------------------
|
||||
|
||||
Filters are written in separated files. Its syntax can be found in http://bird.network.cz/?get_doc&f=bird-5.html
|
||||
The content of each filter file is copied in the birdX.conf file without checking its syntax.
|
||||
|
||||
Example
|
||||
--
|
||||
config filter 'firstFilter'
|
||||
option type 'bgp'
|
||||
option instance 'bgp1'
|
||||
option file_path '/var/filters/f1'
|
||||
--
|
||||
|
||||
* type: String
|
||||
The type indicates to which routing protocol is the filter directed to. Currently only BGP is available.
|
||||
|
||||
* instance: String
|
||||
This option indicates the filter that the routing protocol instance will apply.
|
||||
|
||||
* file_path: String (File path)
|
||||
This option specifies the path to the filter file to be used in the routing protocol.
|
||||
|
||||
|
||||
|
||||
---------------------------------------------------------------------
|
||||
COMPLETE CONFIGURATION EXAMPLE:
|
||||
---------------------------------------------------------------------
|
||||
|
||||
config bird 'bird'
|
||||
option use_UCI_config '1'
|
||||
#Caution! Enabling this option, Bird will translate this
|
||||
#UCI file and use it instead of /etc/bird4.conf
|
||||
option UCI_config_file '/tmp/bird4.conf'
|
||||
#If you enable useUCIconfig, UCIconfigFile will be Bird's
|
||||
#configuration file location.
|
||||
|
||||
config global 'global'
|
||||
option log_file '/tmp/bird4.log'
|
||||
option log 'all'
|
||||
option debug 'off'
|
||||
option router_id '172.16.1.6'
|
||||
|
||||
config table
|
||||
option name 'aux'
|
||||
|
||||
config kernel kernel1
|
||||
option table 'aux'
|
||||
option import 'all'
|
||||
option export 'all'
|
||||
option kernel_table '100'
|
||||
option scan_time '10'
|
||||
option learn '1'
|
||||
option persist '0'
|
||||
option disabled '0'
|
||||
|
||||
config device device1
|
||||
option scan_time '10'
|
||||
option disabled '0'
|
||||
|
||||
config static static1
|
||||
option table 'aux'
|
||||
option disabled '0'
|
||||
|
||||
config bgp bgp1
|
||||
option template 'bgp_common'
|
||||
option description 'Description of the BGP instance'
|
||||
option neighbor_address '172.16.1.5'
|
||||
option neighbor_as '65530'
|
||||
option source_address '172.16.1.6'
|
||||
option next_hop_self '0'
|
||||
option next_hop_keep '0'
|
||||
option rr_client '1'
|
||||
option rr_cluster_id '172.16.1.6'
|
||||
|
||||
config bgp_template bgp_common
|
||||
option table 'aux'
|
||||
option import 'all'
|
||||
option export 'all'
|
||||
option local_address '172.16.1.6'
|
||||
option local_as '65001'
|
||||
option import_limit '100'
|
||||
option import_limit_action 'warn'
|
||||
option export_limit '100'
|
||||
option export_limit_action 'warn'
|
||||
option receive_limit '100'
|
||||
option receive_limit_action 'warn'
|
||||
option disabled '0'
|
||||
|
||||
#config ospf ospf1
|
||||
# option cfg1583compat '1'
|
||||
#
|
||||
#config ospf_area '0.0.0.0'
|
||||
# option instance 'ospf1'
|
||||
# option stub '0'
|
||||
#
|
||||
#config ospf_interface '*'
|
||||
# option area '0.0.0.0'
|
||||
# option cost '100'
|
||||
# option type 'broadcast'
|
||||
# option hello '5'
|
||||
# option password '1'
|
||||
#
|
||||
#config ospf_password '1'
|
||||
# option authentication 'cryptographic'
|
||||
# option passphrase '1234'
|
||||
#
|
||||
#config ospf_networks
|
||||
# option area '0.0.0.0'
|
||||
# list prefix '10.0.0.0/24'
|
||||
#
|
||||
#config ospf_hidden_networks
|
||||
# option area '0.0.0.0'
|
||||
# option prefix '12.0.0.0/24'
|
||||
#
|
||||
#config ospf_stubnet '11.0.0.0/24'
|
||||
# option area '0.0.0.0'
|
||||
# option hidden '0'
|
||||
# option summary '0'
|
||||
# option cost '101'
|
||||
#
|
||||
|
||||
config route
|
||||
option instance 'static1'
|
||||
option type 'router'
|
||||
option prefix '192.168.9.0/24'
|
||||
option via '10.99.105.159'
|
||||
|
||||
config route
|
||||
option instance 'static1'
|
||||
option type 'special'
|
||||
option prefix '192.168.2.0/24'
|
||||
option attribute 'unreachable'
|
||||
|
||||
config route
|
||||
option instance 'static1'
|
||||
option type 'iface'
|
||||
option prefix '192.168.3.0/24'
|
||||
option iface 'mgmt0'
|
||||
|
||||
config route
|
||||
option instance 'static1'
|
||||
option type 'recursive'
|
||||
option prefix '192.168.4.0/24'
|
||||
option ip '192.168.1.1'
|
||||
|
||||
config route
|
||||
option instance 'static1'
|
||||
option type 'multipath'
|
||||
option prefix '192.168.30.0/24'
|
||||
list l_via '172.16.1.5'
|
||||
list l_via '172.16.1.6'
|
||||
|
||||
config filter 'firstFilter'
|
||||
option type 'bgp'
|
||||
option instance 'bgp1'
|
||||
option file_path '/var/filters/f1'
|
||||
|
||||
|
|
@ -22,6 +22,7 @@ BIRD:=bird4
|
|||
PKG_NAME:=$(BIRD)-openwrt
|
||||
PKG_RELEASE:=0.2
|
||||
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
|
||||
PKG_LICENSE:=GPL-3.0+
|
||||
uci:=$(BIRD)-uci
|
||||
luci:=luci-app-$(BIRD)
|
||||
|
||||
|
|
|
@ -58,72 +58,10 @@ config bgp_template bgp_common
|
|||
option receive_limit_action 'warn'
|
||||
option disabled '0'
|
||||
|
||||
config ospf ospf1
|
||||
option cfg1583compat '1'
|
||||
|
||||
config ospf_area '0.0.0.0'
|
||||
option instance 'ospf1'
|
||||
option stub '0'
|
||||
|
||||
config ospf_interface '*'
|
||||
option area '0.0.0.0'
|
||||
option cost '100'
|
||||
option type 'broadcast'
|
||||
option hello '5'
|
||||
option password '1'
|
||||
|
||||
config ospf_password '1'
|
||||
option authentication 'cryptographic'
|
||||
option passphrase '1234'
|
||||
|
||||
config ospf_networks
|
||||
option area '0.0.0.0'
|
||||
list prefix '10.0.0.0/24'
|
||||
|
||||
config ospf_hidden_networks
|
||||
option area '0.0.0.0'
|
||||
option prefix '12.0.0.0/24'
|
||||
|
||||
config ospf_stubnet '11.0.0.0/24'
|
||||
option area '0.0.0.0'
|
||||
option hidden '0'
|
||||
option summary '0'
|
||||
option cost '101'
|
||||
|
||||
config route
|
||||
option instance 'static1'
|
||||
option type 'router'
|
||||
option prefix '192.168.9.0/24'
|
||||
option via '10.99.105.159'
|
||||
|
||||
config route
|
||||
option instance 'static1'
|
||||
option type 'special'
|
||||
option prefix '192.168.2.0/24'
|
||||
option attribute 'unreachable'
|
||||
|
||||
config route
|
||||
option instance 'static1'
|
||||
option type 'iface'
|
||||
option prefix '192.168.3.0/24'
|
||||
option iface 'mgmt0'
|
||||
|
||||
config route
|
||||
option instance 'static1'
|
||||
option type 'recursive'
|
||||
option prefix '192.168.4.0/24'
|
||||
option ip '192.168.1.1'
|
||||
|
||||
config route
|
||||
option instance 'static1'
|
||||
option type 'multipath'
|
||||
option prefix '192.168.30.0/24'
|
||||
list l_via '172.16.1.5'
|
||||
list l_via '172.16.1.6'
|
||||
|
||||
config filter 'firstFilter'
|
||||
option type 'bgp'
|
||||
option instance 'bgp1'
|
||||
option file_path '/var/filters/f1'
|
||||
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ BIRD:=bird6
|
|||
PKG_NAME:=$(BIRD)-openwrt
|
||||
PKG_RELEASE:=0.2
|
||||
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
|
||||
PKG_LICENSE:=GPL-3.0+
|
||||
uci:=$(BIRD)-uci
|
||||
luci:=luci-app-$(BIRD)
|
||||
|
||||
|
|
|
@ -78,9 +78,3 @@ config route
|
|||
option type 'iface'
|
||||
option prefix '2001:db8:0:f101::1111/128'
|
||||
option iface 'eth0'
|
||||
|
||||
config filter 'firstFilter'
|
||||
option type 'bgp'
|
||||
option instance 'bgp1'
|
||||
option file_path '/var/filters/f1'
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (C) 2009-2014 OpenWrt.org
|
||||
# Copyright (C) 2009-2016 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
|
@ -7,13 +7,16 @@
|
|||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=bird
|
||||
PKG_VERSION:=1.4.3
|
||||
PKG_VERSION:=1.6.3
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE:=bird-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=ftp://bird.network.cz/pub/bird
|
||||
PKG_MD5SUM:=eb7e00b9c1d102ddfcbc19d9cb168511
|
||||
PKG_MD5SUM:=39c51cf57c3ba8b5978b2a657ffa2f647ec7f3ae643e91cf42ee5cb070cf7e7c
|
||||
PKG_BUILD_DEPENDS:=libncurses libreadline
|
||||
PKG_MAINTAINER:=Álvaro Fernández Rojas <noltari@gmail.com>
|
||||
|
||||
PKG_LICENSE:=GPL-2.0
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
|
@ -29,6 +32,11 @@ define Package/birdc/Default
|
|||
DEPENDS:= +libreadline +libncurses
|
||||
endef
|
||||
|
||||
define Package/birdcl/Default
|
||||
TITLE:=The BIRD lightweight command-line client
|
||||
URL:=http://bird.network.cz/
|
||||
endef
|
||||
|
||||
define Package/bird/Default/description1
|
||||
BIRD is an internet routing daemon which manages TCP/IP routing tables
|
||||
with support of modern routing protocols, easy to use configuration
|
||||
|
@ -57,6 +65,14 @@ should install BIRD command-line client together with BIRD.
|
|||
|
||||
endef
|
||||
|
||||
define Package/bird/Default/description4
|
||||
This is a BIRD lightweight command-line client. It is used to send commands to BIRD,
|
||||
commands can perform simple actions such as enabling/disabling of
|
||||
protocols, telling BIRD to show various information, telling it to show
|
||||
a routing table filtered by a filter, or asking BIRD to reconfigure.
|
||||
|
||||
endef
|
||||
|
||||
define Package/bird4
|
||||
$(call Package/bird/Default)
|
||||
SECTION:=net
|
||||
|
@ -74,6 +90,15 @@ $(call Package/birdc/Default)
|
|||
DEPENDS+= +bird4
|
||||
endef
|
||||
|
||||
define Package/birdcl4
|
||||
$(call Package/birdcl/Default)
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
SUBMENU:=Routing and Redirection
|
||||
TITLE+= (IPv4)
|
||||
DEPENDS+= +bird4
|
||||
endef
|
||||
|
||||
define Package/bird6
|
||||
$(call Package/bird/Default)
|
||||
SECTION:=net
|
||||
|
@ -91,6 +116,15 @@ $(call Package/birdc/Default)
|
|||
DEPENDS+= +bird6
|
||||
endef
|
||||
|
||||
define Package/birdcl6
|
||||
$(call Package/birdcl/Default)
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
SUBMENU:=Routing and Redirection
|
||||
TITLE+= (IPv6)
|
||||
DEPENDS+= +bird6
|
||||
endef
|
||||
|
||||
define Package/bird4/description
|
||||
$(call Package/bird/Default/description1)
|
||||
This is IPv4 version of BIRD, it supports OSPFv2, RIPv2 and BGP
|
||||
|
@ -104,6 +138,11 @@ $(call Package/bird/Default/description1)
|
|||
$(call Package/bird/Default/description3)
|
||||
endef
|
||||
|
||||
define Package/birdcl4/description
|
||||
$(call Package/bird/Default/description1)
|
||||
$(call Package/bird/Default/description4)
|
||||
endef
|
||||
|
||||
define Package/bird6/description
|
||||
$(call Package/bird/Default/description1)
|
||||
This is IPv6 version of BIRD, it supports OSPFv3, RIPng and BGP
|
||||
|
@ -117,14 +156,21 @@ $(call Package/bird/Default/description1)
|
|||
$(call Package/bird/Default/description3)
|
||||
endef
|
||||
|
||||
define Package/birdcl6/description
|
||||
$(call Package/bird/Default/description1)
|
||||
$(call Package/bird/Default/description4)
|
||||
endef
|
||||
|
||||
CONFIGURE_ARGS += --with-linux-headers="$(LINUX_DIR)"
|
||||
|
||||
TARGET_CFLAGS+=-std=gnu89
|
||||
|
||||
define Build/Template
|
||||
|
||||
$(STAMP_BUILT)-$(2): $(STAMP_PREPARED)
|
||||
$(call Build/Configure/Default,$(3))
|
||||
$(call Build/Compile/Default,)
|
||||
( cd $(PKG_BUILD_DIR); mv -f bird bird$(2); mv -f birdc birdc$(2) )
|
||||
( cd $(PKG_BUILD_DIR); mv -f bird bird$(2); mv -f birdc birdc$(2); mv -f birdcl birdcl$(2) )
|
||||
-$(MAKE) -C $(PKG_BUILD_DIR) clean
|
||||
touch $$@
|
||||
|
||||
|
@ -149,6 +195,11 @@ define Package/birdc$(2)/install
|
|||
$(INSTALL_BIN) $$(PKG_BUILD_DIR)/birdc$(2) $$(1)/usr/sbin/
|
||||
endef
|
||||
|
||||
define Package/birdcl$(2)/install
|
||||
$(INSTALL_DIR) $$(1)/usr/sbin
|
||||
$(INSTALL_BIN) $$(PKG_BUILD_DIR)/birdcl$(2) $$(1)/usr/sbin/
|
||||
endef
|
||||
|
||||
endef
|
||||
|
||||
|
||||
|
@ -157,5 +208,7 @@ $(eval $(call Build/Template,bird6,6, --enable-ipv6))
|
|||
|
||||
$(eval $(call BuildPackage,bird4))
|
||||
$(eval $(call BuildPackage,birdc4))
|
||||
$(eval $(call BuildPackage,birdcl4))
|
||||
$(eval $(call BuildPackage,bird6))
|
||||
$(eval $(call BuildPackage,birdc6))
|
||||
$(eval $(call BuildPackage,birdcl6))
|
||||
|
|
|
@ -31,9 +31,10 @@ PKG_SOURCE_PROTO:=git
|
|||
#PKG_SOURCE_URL:=git://bmx6.net/bmx6.git
|
||||
PKG_SOURCE_URL:=git://github.com/axn/bmx6.git
|
||||
|
||||
PKG_REV:=8b0585e84ca8a0110bd4587e19192beda1ba3238
|
||||
PKG_VERSION:=r2014052301
|
||||
PKG_REV:=d9b985d8838ad6fe6d5c79f858a588b96abcf306
|
||||
PKG_VERSION:=r2017021601
|
||||
PKG_RELEASE:=4
|
||||
PKG_LICENSE:=GPL-2.0
|
||||
|
||||
PKG_SOURCE_VERSION:=$(PKG_REV)
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
@ -48,7 +49,7 @@ TARGET_CFLAGS += $(FPIC)
|
|||
MAKE_ARGS += \
|
||||
EXTRA_CFLAGS="$(TARGET_CFLAGS) -I. -I$(STAGING_DIR)/usr/include -DNO_DEBUG_ALL -DNO_DEBUG_DUMP" \
|
||||
EXTRA_LDFLAGS="-L$(STAGING_DIR)/usr/lib " \
|
||||
REVISION_VERSION="$(PKG_REV)" \
|
||||
GIT_REV="$(PKG_REV)" \
|
||||
CC="$(TARGET_CC)" \
|
||||
INSTALL_DIR="$(PKG_INSTALL_DIR)" \
|
||||
STRIP="/bin/false" \
|
||||
|
@ -81,8 +82,8 @@ endef
|
|||
|
||||
define Package/bmx6-json
|
||||
$(call Package/bmx6/Default)
|
||||
DEPENDS:=bmx6 +libjson
|
||||
TITLE:=json plugin based on jsonc
|
||||
DEPENDS:=bmx6 +libjson-c
|
||||
TITLE:=json plugin based on json-c
|
||||
endef
|
||||
|
||||
define Package/bmx6-sms
|
||||
|
|
13
bmx6/patches/001-json-c.patch
Normal file
13
bmx6/patches/001-json-c.patch
Normal file
|
@ -0,0 +1,13 @@
|
|||
Index: bmx6-r2014112401/lib/bmx6_json/json.c
|
||||
===================================================================
|
||||
--- bmx6-r2014112401.orig/lib/bmx6_json/json.c
|
||||
+++ bmx6-r2014112401/lib/bmx6_json/json.c
|
||||
@@ -27,7 +27,7 @@
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdint.h>
|
||||
-#include <json/json.h>
|
||||
+#include <json-c/json.h>
|
||||
//#include <dirent.h>
|
||||
//#include <sys/inotify.h>
|
||||
|
193
bmx7/Makefile
Normal file
193
bmx7/Makefile
Normal file
|
@ -0,0 +1,193 @@
|
|||
#
|
||||
# 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.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# The full GNU General Public License is included in this distribution in
|
||||
# the file called "COPYING".
|
||||
#
|
||||
# Contibutors:
|
||||
# Axel Neumann, Simó Albert i Beltran, Pau Escrich
|
||||
#
|
||||
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=bmx7
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
|
||||
#PKG_SOURCE_URL:=git://bmx6.net/bmx6.git
|
||||
PKG_SOURCE_URL:=git://github.com/axn/bmx6.git
|
||||
#PKG_SOURCE_URL:=file:///usr/src/bmx6/bmx6.git
|
||||
|
||||
PKG_REV:=589ee21b49d370056a24d8931d663626608f3c12
|
||||
PKG_VERSION:=r2017011101
|
||||
PKG_RELEASE:=4
|
||||
PKG_LICENSE:=GPL-2.0
|
||||
|
||||
PKG_SOURCE_VERSION:=$(PKG_REV)
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
PKG_SOURCE:=$(PKG_SOURCE_SUBDIR).tar.gz
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_SOURCE_SUBDIR)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
TARGET_CFLAGS += $(FPIC)
|
||||
|
||||
#MAKE_ARGS += EXTRA_CFLAGS="$(TARGET_CFLAGS) -I. -I$(STAGING_DIR)/usr/include -DCRYPTLIB=POLARSSL_1_3_4 -DCORE_LIMIT=20000 -DTRAFFIC_DUMP -DNO_TRACE_FUNCTION_CALLS -DBMX7_LIB_IWINFO"
|
||||
MAKE_ARGS += EXTRA_CFLAGS="$(TARGET_CFLAGS) -I. -I$(STAGING_DIR)/usr/include -DCRYPTLIB=MBEDTLS_2_4_0 -DCORE_LIMIT=20000 -DTRAFFIC_DUMP -DNO_TRACE_FUNCTION_CALLS -DBMX7_LIB_IWINFO"
|
||||
|
||||
MAKE_ARGS += \
|
||||
EXTRA_LDFLAGS="$(TARGET_LDFLAGS) -L$(STAGING_DIR)/usr/lib -liwinfo" \
|
||||
GIT_REV="$(PKG_REV)" \
|
||||
CC="$(TARGET_CC)" \
|
||||
INSTALL_DIR="$(PKG_INSTALL_DIR)" \
|
||||
build_all
|
||||
|
||||
define Package/bmx7/Default
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
SUBMENU:=Routing and Redirection
|
||||
TITLE:=BMX7 layer 3 routing daemon
|
||||
URL:=http://bmx6.net/
|
||||
MAINTAINER:=Axel Neumann <neumann@cgws.de>
|
||||
# DEPENDS:=+zlib +libpolarssl +libiwinfo
|
||||
DEPENDS:=+zlib +libmbedtls +libiwinfo
|
||||
endef
|
||||
|
||||
define Package/bmx7/description
|
||||
BMX7 routing daemon supporting securely-entrusted IPv6 (and IPv4in6) routing
|
||||
endef
|
||||
|
||||
define Package/bmx7
|
||||
$(call Package/bmx7/Default)
|
||||
MENU:=1
|
||||
endef
|
||||
|
||||
define Package/bmx7-uci-config
|
||||
$(call Package/bmx7/Default)
|
||||
DEPENDS:=bmx7 +libuci
|
||||
TITLE:=configuration plugin based on uci (recommended!)
|
||||
endef
|
||||
|
||||
define Package/bmx7-iwinfo
|
||||
$(call Package/bmx7/Default)
|
||||
DEPENDS:=bmx7 +libiwinfo
|
||||
TITLE:=link characteristics plugin based on libiwinfo (recommended!)
|
||||
endef
|
||||
|
||||
define Package/bmx7-topology
|
||||
$(call Package/bmx7/Default)
|
||||
DEPENDS:=bmx7
|
||||
TITLE:=topology plugin
|
||||
endef
|
||||
|
||||
define Package/bmx7-json
|
||||
$(call Package/bmx7/Default)
|
||||
DEPENDS:=bmx7 +libjson-c
|
||||
TITLE:=json plugin based on json-c
|
||||
endef
|
||||
|
||||
define Package/bmx7-sms
|
||||
$(call Package/bmx7/Default)
|
||||
DEPENDS:=bmx7
|
||||
TITLE:=sms plugin
|
||||
endef
|
||||
|
||||
define Package/bmx7-tun
|
||||
$(call Package/bmx7/Default)
|
||||
DEPENDS:=bmx7 +kmod-ip6-tunnel +kmod-iptunnel6 +kmod-tun
|
||||
TITLE:=ipip-based tunnel plugin (recommended!)
|
||||
endef
|
||||
|
||||
define Package/bmx7-table
|
||||
$(call Package/bmx7/Default)
|
||||
DEPENDS:=bmx7 +bmx7-tun
|
||||
TITLE:=plugin to announce routes from tables via tunnels
|
||||
endef
|
||||
|
||||
define Build/Configure
|
||||
mkdir -p $(PKG_INSTALL_DIR)
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
$(MAKE) -C $(PKG_BUILD_DIR) $(MAKE_ARGS)
|
||||
endef
|
||||
|
||||
define Package/bmx7/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/config $(1)/etc/init.d
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bmx7 $(1)/usr/sbin/bmx7
|
||||
endef
|
||||
|
||||
define Package/bmx7/postinst
|
||||
#!/bin/sh
|
||||
# # check if we are on real system
|
||||
if [ -z "$${IPKG_INSTROOT}" ]; then
|
||||
if [ -f /etc/sysupgrade.conf ] && ! grep bmx7 /etc/sysupgrade.conf; then
|
||||
echo /etc/bmx7 >> /etc/sysupgrade.conf
|
||||
fi
|
||||
fi
|
||||
endef
|
||||
|
||||
|
||||
define Package/bmx7-uci-config/conffiles
|
||||
/etc/config/bmx7
|
||||
endef
|
||||
|
||||
define Package/bmx7-uci-config/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib $(1)/etc/config $(1)/etc/init.d
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/bmx7_uci_config/bmx7_config.so $(1)/usr/lib/bmx7_config.so
|
||||
$(INSTALL_BIN) ./files/etc/init.d/bmx7 $(1)/etc/init.d/bmx7
|
||||
$(INSTALL_DATA) ./files/etc/config/bmx7 $(1)/etc/config/bmx7
|
||||
endef
|
||||
|
||||
define Package/bmx7-iwinfo/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/bmx7_iwinfo/bmx7_iwinfo.so $(1)/usr/lib/bmx7_iwinfo.so
|
||||
endef
|
||||
|
||||
define Package/bmx7-topology/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/bmx7_topology/bmx7_topology.so $(1)/usr/lib/bmx7_topology.so
|
||||
endef
|
||||
|
||||
define Package/bmx7-json/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/bmx7_json/bmx7_json.so $(1)/usr/lib/bmx7_json.so
|
||||
endef
|
||||
|
||||
define Package/bmx7-sms/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/bmx7_sms/bmx7_sms.so $(1)/usr/lib/bmx7_sms.so
|
||||
endef
|
||||
|
||||
define Package/bmx7-tun/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/bmx7_tun/bmx7_tun.so $(1)/usr/lib/bmx7_tun.so
|
||||
endef
|
||||
|
||||
define Package/bmx7-table/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/lib/bmx7_table/bmx7_table.so $(1)/usr/lib/bmx7_table.so
|
||||
endef
|
||||
|
||||
|
||||
$(eval $(call BuildPackage,bmx7))
|
||||
$(eval $(call BuildPackage,bmx7-uci-config))
|
||||
$(eval $(call BuildPackage,bmx7-iwinfo))
|
||||
$(eval $(call BuildPackage,bmx7-topology))
|
||||
$(eval $(call BuildPackage,bmx7-json))
|
||||
$(eval $(call BuildPackage,bmx7-sms))
|
||||
$(eval $(call BuildPackage,bmx7-table))
|
||||
$(eval $(call BuildPackage,bmx7-tun))
|
57
bmx7/files/etc/config/bmx7
Normal file
57
bmx7/files/etc/config/bmx7
Normal file
|
@ -0,0 +1,57 @@
|
|||
|
||||
# for more information:
|
||||
# http://bmx6.net/projects/bmx6/wiki
|
||||
# options execute: bmx7 --help
|
||||
|
||||
config 'bmx7' 'general'
|
||||
# option 'runtimeDir' '/var/run/bmx7'
|
||||
# option 'trustedNodesDir' '/etc/bmx7/trustedNodes'
|
||||
|
||||
#config 'plugin'
|
||||
# option 'plugin' 'bmx7_config.so'
|
||||
|
||||
#config 'plugin'
|
||||
# option 'plugin' 'bmx7_json.so'
|
||||
|
||||
#config 'plugin'
|
||||
# option 'plugin' 'bmx7_sms.so'
|
||||
|
||||
#config 'plugin'
|
||||
# option 'plugin' 'bmx7_iwinfo.so'
|
||||
|
||||
|
||||
config 'dev' 'mesh_1'
|
||||
option 'dev' 'br-lan'
|
||||
|
||||
config 'dev' 'mesh_2'
|
||||
option 'dev' 'wlan0'
|
||||
|
||||
|
||||
|
||||
#config 'plugin'
|
||||
# option 'plugin' 'bmx7_tun.so'
|
||||
|
||||
#config 'plugin'
|
||||
# option 'plugin' 'bmx7_table.so'
|
||||
|
||||
|
||||
#config 'tunDev' default
|
||||
# option 'tunDev' 'default'
|
||||
# option 'tun6Address' '2012:0:0:6666::1/64'
|
||||
# option 'tun4Address' '10.66.66.1/24'
|
||||
|
||||
|
||||
#config 'tunOut'
|
||||
# option 'tunOut' 'ip6'
|
||||
# option 'network' '2012::/16'
|
||||
# option 'exportDistance' '0'
|
||||
|
||||
#config 'tunOut'
|
||||
# option 'tunOut' 'ip4'
|
||||
# option 'network' '10.0.0.0/9'
|
||||
# option 'minPrefixLen' '27'
|
||||
|
||||
|
||||
|
||||
|
||||
|
41
bmx7/files/etc/init.d/bmx7
Executable file
41
bmx7/files/etc/init.d/bmx7
Executable file
|
@ -0,0 +1,41 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2011 Fundacio Privada per a la Xarxa Oberta, Lliure i Neutral guifi.net
|
||||
#
|
||||
# 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.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# The full GNU General Public License is included in this distribution in
|
||||
# the file called "COPYING".
|
||||
|
||||
START=91
|
||||
|
||||
BIN=/usr/sbin/bmx7
|
||||
CONF=/etc/config/bmx7
|
||||
PID=/var/run/bmx7/pid
|
||||
|
||||
|
||||
start() {
|
||||
cd /root/
|
||||
while pgrep -f mac80211.sh ; do sleep 1; done
|
||||
ulimit -c 20000
|
||||
$BIN -f $CONF -d0 > /dev/null &
|
||||
}
|
||||
|
||||
stop() {
|
||||
start-stop-daemon -p $PID -K
|
||||
}
|
||||
|
||||
restart() {
|
||||
stop; sleep 3; start
|
||||
}
|
13
bmx7/patches/001-json-c.patch
Normal file
13
bmx7/patches/001-json-c.patch
Normal file
|
@ -0,0 +1,13 @@
|
|||
Index: bmx7-r2014112401/lib/bmx7_json/json.c
|
||||
===================================================================
|
||||
--- bmx7-r2014112401.orig/lib/bmx7_json/json.c
|
||||
+++ bmx7-r2014112401/lib/bmx7_json/json.c
|
||||
@@ -27,7 +27,7 @@
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdint.h>
|
||||
-#include <json/json.h>
|
||||
+#include <json-c/json.h>
|
||||
//#include <dirent.h>
|
||||
//#include <sys/inotify.h>
|
||||
|
148
cjdns/Makefile
Normal file
148
cjdns/Makefile
Normal file
|
@ -0,0 +1,148 @@
|
|||
#
|
||||
# Copyright (C) 2014,2015 Hyperboria.net
|
||||
#
|
||||
# You may redistribute this program and/or modify it under the terms of
|
||||
# the GNU General Public License as published by the Free Software Foundation,
|
||||
# either version 3 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, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=cjdns
|
||||
PKG_VERSION:=0.17
|
||||
PKG_RELEASE:=3
|
||||
|
||||
PKG_SOURCE_URL:=https://github.com/hyperboria/cjdns.git
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_VERSION:=40e87d9419c19063e772e39c7c59a8a8771c5ee8
|
||||
PKG_LICENSE:=GPL-3.0
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_SOURCE_VERSION).tar.bz2
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_SOURCE_VERSION)
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_SOURCE_VERSION)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
|
||||
define Package/cjdns
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
SUBMENU:=Routing and Redirection
|
||||
TITLE:=Encrypted near-zero-conf mesh routing protocol
|
||||
URL:=https://github.com/hyperboria/cjdns
|
||||
MAINTAINER:=Lars Gierth <larsg@systemli.org>
|
||||
DEPENDS:=@IPV6 +kmod-tun +libnl-tiny +libpthread +librt \
|
||||
+libuci-lua +lua-bencode +dkjson +luasocket +lua-sha2
|
||||
endef
|
||||
|
||||
define Package/cjdns/description
|
||||
Cjdns implements an encrypted IPv6 network using public-key cryptography \
|
||||
for address allocation and a distributed hash table for routing. \
|
||||
This provides near-zero-configuration networking, and prevents many \
|
||||
of the security and scalability issues that plague existing networks.
|
||||
endef
|
||||
|
||||
define Package/cjdns-tests
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
SUBMENU:=Routing and Redirection
|
||||
TITLE:=cjdns test cases
|
||||
URL:=https://github.com/hyperboria/cjdns
|
||||
MAINTAINER:=Lars Gierth <larsg@systemli.org>
|
||||
DEPENDS:=+libpthread +librt
|
||||
endef
|
||||
|
||||
define Package/cjdns-test/description
|
||||
cjdns test cases
|
||||
endef
|
||||
|
||||
define Build/Configure
|
||||
endef
|
||||
|
||||
PKG_DO_VARS:=CJDNS_RELEASE_VERSION=$(PKG_SOURCE_VERSION)
|
||||
|
||||
ifneq ($(CONFIG_KERNEL_SECCOMP_FILTER),y)
|
||||
PKG_DO_VARS+= Seccomp_NO=1
|
||||
endif
|
||||
|
||||
ifneq ($(CONFIG_USE_UCLIBC),)
|
||||
PKG_DO_VARS+= UCLIBC=1
|
||||
endif
|
||||
|
||||
define Build/Compile
|
||||
$(INSTALL_DIR) $(PKG_BUILD_DIR)/tmp
|
||||
CROSS="true" \
|
||||
CC="$(TARGET_CC)" \
|
||||
AR="$(TARGET_AR)" \
|
||||
RANLIB="$(TARGET_RANLIB)" \
|
||||
CFLAGS="$(TARGET_CFLAGS)" \
|
||||
LDFLAGS="$(TARGET_LDFLAGS)" \
|
||||
SYSTEM="linux" \
|
||||
TARGET_ARCH="$(CONFIG_ARCH)" \
|
||||
SSP_SUPPORT="$(CONFIG_SSP_SUPPORT)" \
|
||||
GYP_ADDITIONAL_ARGS="-f make-linux" \
|
||||
CJDNS_BUILD_TMPDIR="$(PKG_BUILD_DIR)/tmp" \
|
||||
$(PKG_DO_VARS) \
|
||||
$(PKG_BUILD_DIR)/do
|
||||
endef
|
||||
|
||||
define Package/cjdns/install
|
||||
$(INSTALL_DIR) \
|
||||
$(1)/usr/sbin \
|
||||
$(1)/usr/bin \
|
||||
$(1)/etc/config \
|
||||
$(1)/etc/init.d \
|
||||
$(1)/etc/uci-defaults \
|
||||
$(1)/usr/lib/lua/cjdns
|
||||
|
||||
$(INSTALL_BIN) \
|
||||
./files/cjdrouteconf \
|
||||
$(1)/usr/bin
|
||||
|
||||
$(INSTALL_BIN) \
|
||||
$(PKG_BUILD_DIR)/cjdroute \
|
||||
$(1)/usr/sbin
|
||||
|
||||
$(INSTALL_BIN) \
|
||||
$(PKG_BUILD_DIR)/publictoip6 \
|
||||
$(1)/usr/bin
|
||||
|
||||
$(INSTALL_BIN) \
|
||||
./files/cjdns.init \
|
||||
$(1)/etc/init.d/cjdns
|
||||
|
||||
$(INSTALL_BIN) \
|
||||
./files/cjdns.defaults \
|
||||
$(1)/etc/uci-defaults/cjdns
|
||||
|
||||
$(CP) \
|
||||
./lua/cjdns/* \
|
||||
$(1)/usr/lib/lua/cjdns
|
||||
endef
|
||||
|
||||
define Package/cjdns/postinst
|
||||
#!/bin/sh
|
||||
if [ -z $${IPKG_INSTROOT} ] ; then
|
||||
( . /etc/uci-defaults/cjdns ) && rm -f /etc/uci-defaults/cjdns
|
||||
# TODO: we should have an 'Enable' button instead
|
||||
/etc/init.d/cjdns enabled || /etc/init.d/cjdns enable
|
||||
exit 0
|
||||
fi
|
||||
endef
|
||||
|
||||
define Package/cjdns-tests/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) \
|
||||
$(PKG_BUILD_DIR)/build_linux/test_testcjdroute_c \
|
||||
$(1)/usr/bin
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,cjdns))
|
||||
$(eval $(call BuildPackage,cjdns-tests))
|
127
cjdns/files/cjdns.defaults
Normal file
127
cjdns/files/cjdns.defaults
Normal file
|
@ -0,0 +1,127 @@
|
|||
#!/bin/sh
|
||||
|
||||
# if there is an existing config, our work is already done
|
||||
uci get cjdns.cjdns.ipv6 >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
|
||||
# register commit handler
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@cjdns[-1]
|
||||
add ucitrack cjdns
|
||||
set ucitrack.@cjdns[-1].init=cjdns
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
# generate configuration
|
||||
touch /etc/config/cjdns
|
||||
cjdroute --genconf | cjdroute --cleanconf | cjdrouteconf set
|
||||
|
||||
# make sure config is present (might fail for any reason)
|
||||
uci get cjdns.cjdns.ipv6 >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# enable auto-peering on ethernet interface lan, if existing
|
||||
uci get network.lan | grep interface >/dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
uci get network.lan.type | grep bridge >/dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
# most routers will set up an ethernet bridge for the lan
|
||||
ifname="br-lan"
|
||||
else
|
||||
# docker containers don't have permission to create bridges by default,
|
||||
# so we bind to the underlying interface instead (likely eth0)
|
||||
ifname=`uci get network.lan.ifname`
|
||||
fi
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
add cjdns eth_interface
|
||||
set cjdns.@eth_interface[-1].beacon=2
|
||||
set cjdns.@eth_interface[-1].bind=$ifname
|
||||
EOF
|
||||
fi
|
||||
# set the tun interface name
|
||||
uci set cjdns.cjdns.tun_device=tuncjdns
|
||||
|
||||
# create the network interface
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
set network.cjdns=interface
|
||||
set network.cjdns.ifname=tuncjdns
|
||||
set network.cjdns.proto=none
|
||||
EOF
|
||||
|
||||
# firewall rules by @dangowrt -- thanks <3
|
||||
|
||||
# create the firewall zone
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
add firewall zone
|
||||
set firewall.@zone[-1].name=cjdns
|
||||
add_list firewall.@zone[-1].network=cjdns
|
||||
set firewall.@zone[-1].input=REJECT
|
||||
set firewall.@zone[-1].output=ACCEPT
|
||||
set firewall.@zone[-1].forward=REJECT
|
||||
set firewall.@zone[-1].conntrack=1
|
||||
set firewall.@zone[-1].family=ipv6
|
||||
EOF
|
||||
|
||||
# allow ICMP from cjdns zone, e.g. ping6
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
add firewall rule
|
||||
set firewall.@rule[-1].name='Allow-ICMPv6-cjdns'
|
||||
set firewall.@rule[-1].src=cjdns
|
||||
set firewall.@rule[-1].proto=icmp
|
||||
add_list firewall.@rule[-1].icmp_type=echo-request
|
||||
add_list firewall.@rule[-1].icmp_type=echo-reply
|
||||
add_list firewall.@rule[-1].icmp_type=destination-unreachable
|
||||
add_list firewall.@rule[-1].icmp_type=packet-too-big
|
||||
add_list firewall.@rule[-1].icmp_type=time-exceeded
|
||||
add_list firewall.@rule[-1].icmp_type=bad-header
|
||||
add_list firewall.@rule[-1].icmp_type=unknown-header-type
|
||||
set firewall.@rule[-1].limit='1000/sec'
|
||||
set firewall.@rule[-1].family=ipv6
|
||||
set firewall.@rule[-1].target=ACCEPT
|
||||
EOF
|
||||
|
||||
# allow SSH from cjdns zone, needs to be explicitly enabled
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
add firewall rule
|
||||
set firewall.@rule[-1].enabled=0
|
||||
set firewall.@rule[-1].name='Allow-SSH-cjdns'
|
||||
set firewall.@rule[-1].src=cjdns
|
||||
set firewall.@rule[-1].proto=tcp
|
||||
set firewall.@rule[-1].dest_port=22
|
||||
set firewall.@rule[-1].target=ACCEPT
|
||||
EOF
|
||||
|
||||
# allow LuCI access from cjdns zone, needs to be explicitly enabled
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
add firewall rule
|
||||
set firewall.@rule[-1].enabled=0
|
||||
set firewall.@rule[-1].name='Allow-HTTP-cjdns'
|
||||
set firewall.@rule[-1].src=cjdns
|
||||
set firewall.@rule[-1].proto=tcp
|
||||
set firewall.@rule[-1].dest_port=80
|
||||
set firewall.@rule[-1].target=ACCEPT
|
||||
EOF
|
||||
|
||||
# allow UDP peering from wan zone, if it exists
|
||||
uci show network.wan >/dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
peeringPort=`uci get cjdns.@udp_interface[0].port`
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
add firewall rule
|
||||
set firewall.@rule[-1].name='Allow-cjdns-wan'
|
||||
set firewall.@rule[-1].src=wan
|
||||
set firewall.@rule[-1].proto=udp
|
||||
set firewall.@rule[-1].dest_port=$peeringPort
|
||||
set firewall.@rule[-1].target=ACCEPT
|
||||
EOF
|
||||
fi
|
||||
|
||||
uci commit cjdns
|
||||
uci commit firewall
|
||||
uci commit network
|
||||
|
||||
fi
|
||||
|
||||
exit 0
|
32
cjdns/files/cjdns.init
Executable file
32
cjdns/files/cjdns.init
Executable file
|
@ -0,0 +1,32 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=90
|
||||
STOP=85
|
||||
|
||||
USE_PROCD=1
|
||||
|
||||
start_service()
|
||||
{
|
||||
[ -f /etc/uci-defaults/cjdns ] && ( . /etc/uci-defaults/cjdns )
|
||||
|
||||
procd_open_instance
|
||||
procd_set_param respawn
|
||||
procd_set_param command /bin/ash -c "cjdrouteconf get | tee /tmp/etc/cjdroute.conf | cjdroute --nobg | logger -t cjdns"
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
stop_service()
|
||||
{
|
||||
killall cjdroute
|
||||
}
|
||||
|
||||
reload_service()
|
||||
{
|
||||
# cat /tmp/etc/cjdroute.conf | cjdrouteconf reload
|
||||
restart
|
||||
}
|
||||
|
||||
service_triggers()
|
||||
{
|
||||
procd_add_reload_trigger cjdns
|
||||
}
|
30
cjdns/files/cjdrouteconf
Executable file
30
cjdns/files/cjdrouteconf
Executable file
|
@ -0,0 +1,30 @@
|
|||
#!/usr/bin/env lua
|
||||
|
||||
dkjson = require("dkjson")
|
||||
cjdns = require("cjdns")
|
||||
require("cjdns/uci")
|
||||
|
||||
function help()
|
||||
print("JSON interface to /etc/config/cjdns\n\nExamples: \
|
||||
cjdrouteconf get > /tmp/etc/cjdroute.conf \
|
||||
cat /tmp/etc/cjdroute.conf | cjdrouteconf set \
|
||||
uci changes \
|
||||
cjdrouteconf get | cjdroute")
|
||||
end
|
||||
|
||||
if arg[1] == "get" then
|
||||
local json = dkjson.encode(cjdns.uci.get(), { indent = true })
|
||||
print(json)
|
||||
elseif arg[1] == "set" then
|
||||
local json = io.stdin:read("*a")
|
||||
local obj, pos, err = dkjson.decode(json, 1, nil)
|
||||
|
||||
if obj then
|
||||
cjdns.uci.set(obj)
|
||||
else
|
||||
print("dkjson: " .. err .. " (try cjdroute --cleanconf)")
|
||||
os.exit(1)
|
||||
end
|
||||
else
|
||||
help()
|
||||
end
|
105
cjdns/lua/cjdns/admin.lua
Normal file
105
cjdns/lua/cjdns/admin.lua
Normal file
|
@ -0,0 +1,105 @@
|
|||
-- Cjdns admin module for Lua
|
||||
-- Written by Philip Horger
|
||||
|
||||
common = require 'cjdns/common'
|
||||
|
||||
AdminInterface = {}
|
||||
AdminInterface.__index = AdminInterface
|
||||
common.AdminInterface = AdminInterface
|
||||
|
||||
function AdminInterface.new(properties)
|
||||
properties = properties or {}
|
||||
|
||||
properties.host = properties.host or "127.0.0.1"
|
||||
properties.port = properties.port or 11234
|
||||
properties.password = properties.password or nil
|
||||
properties.config = properties.config or common.ConfigFile.new("/etc/cjdroute.conf", false)
|
||||
properties.timeout = properties.timeout or 2
|
||||
|
||||
properties.udp = common.UDPInterface.new(properties)
|
||||
|
||||
return setmetatable(properties, AdminInterface)
|
||||
end
|
||||
|
||||
function AdminInterface:send(object)
|
||||
local bencoded, err = bencode.encode(object)
|
||||
if err then
|
||||
return nil, err
|
||||
end
|
||||
|
||||
local sock_obj = assert(socket.udp())
|
||||
sock_obj:settimeout(self.timeout)
|
||||
|
||||
local _, err = sock_obj:sendto(bencoded, self.host, self.port)
|
||||
if err then
|
||||
return nil, err
|
||||
end
|
||||
|
||||
return sock_obj
|
||||
end
|
||||
|
||||
function AdminInterface:recv(sock_obj)
|
||||
local retrieved, err = sock_obj:receive()
|
||||
if not retrieved then
|
||||
return nil, "ai:recv > " .. err
|
||||
end
|
||||
local bencoded, err = bencode.decode(retrieved)
|
||||
if bencoded then
|
||||
return bencoded
|
||||
else
|
||||
return nil, "ai:recv > " .. err
|
||||
end
|
||||
end
|
||||
|
||||
function AdminInterface:call(request)
|
||||
local sock_obj, err = self:send(request)
|
||||
if err then
|
||||
return nil, "ai:call > " .. err
|
||||
end
|
||||
|
||||
return self:recv(sock_obj)
|
||||
end
|
||||
|
||||
function AdminInterface:getCookie()
|
||||
local cookie_response, err = self:call({ q = "cookie" })
|
||||
if not cookie_response then
|
||||
return nil, "ai:getCookie > " .. err
|
||||
end
|
||||
return cookie_response.cookie
|
||||
end
|
||||
|
||||
function AdminInterface:auth(request)
|
||||
local funcname = request.q
|
||||
local args = {}
|
||||
for k, v in pairs(request) do
|
||||
args[k] = v
|
||||
end
|
||||
|
||||
-- Step 1: Get cookie
|
||||
local cookie, err = self:getCookie()
|
||||
if err then
|
||||
return nil, err
|
||||
end
|
||||
|
||||
-- Step 2: Calculate hash1 (password + cookie)
|
||||
local plaintext1 = self.password .. cookie
|
||||
local hash1 = sha2.sha256hex(plaintext1)
|
||||
|
||||
-- Step 3: Calculate hash2 (intermediate stage request)
|
||||
local request = {
|
||||
q = "auth",
|
||||
aq = funcname,
|
||||
args = args,
|
||||
hash = hash1,
|
||||
cookie = cookie
|
||||
}
|
||||
local plaintext2, err = bencode.encode(request)
|
||||
if err then
|
||||
return nil, err
|
||||
end
|
||||
local hash2 = sha2.sha256hex(plaintext2)
|
||||
|
||||
-- Step 4: Update hash in request, then ship it out
|
||||
request.hash = hash2
|
||||
return self:call(request)
|
||||
end
|
7
cjdns/lua/cjdns/common.lua
Normal file
7
cjdns/lua/cjdns/common.lua
Normal file
|
@ -0,0 +1,7 @@
|
|||
-- Cjdns admin module for Lua
|
||||
-- Written by Philip Horger
|
||||
|
||||
-- This table is preserved over multiple imports, and collects
|
||||
-- submodules import-by-import via init.lua.
|
||||
|
||||
return {}
|
12
cjdns/lua/cjdns/init.lua
Normal file
12
cjdns/lua/cjdns/init.lua
Normal file
|
@ -0,0 +1,12 @@
|
|||
-- Cjdns admin module for Lua
|
||||
-- Written by Philip Horger
|
||||
|
||||
bencode = require "bencode" -- https://bitbucket.org/wilhelmy/lua-bencode/
|
||||
dkjson = require "dkjson" -- http://dkolf.de/src/dkjson-lua.fsl/home
|
||||
socket = require "socket" -- http://w3.impa.br/~diego/software/luasocket/
|
||||
sha2 = require "sha2" -- https://code.google.com/p/sha2/
|
||||
|
||||
require "cjdns/admin"
|
||||
require "cjdns/udp"
|
||||
|
||||
return require "cjdns/common"
|
289
cjdns/lua/cjdns/uci.lua
Normal file
289
cjdns/lua/cjdns/uci.lua
Normal file
|
@ -0,0 +1,289 @@
|
|||
common = require("cjdns/common")
|
||||
uci = require("uci")
|
||||
|
||||
UCI = {}
|
||||
common.uci = UCI
|
||||
|
||||
--- Return the configuration defaults as a table suitable for JSON output
|
||||
--
|
||||
-- Mostly taken from cjdroute --genconf
|
||||
-- @return table with configuration defaults
|
||||
function UCI.defaults()
|
||||
return {
|
||||
security = {
|
||||
{ setuser = "nobody", keepNetAdmin = 1 },
|
||||
{ chroot = "/var/run/" },
|
||||
{ nofiles = 0 },
|
||||
{ noforks = 1 },
|
||||
{ seccomp = 0 },
|
||||
{ setupComplete = 1 }
|
||||
},
|
||||
router = {
|
||||
ipTunnel = { outgoingConnections = {}, allowedConnections = {} },
|
||||
interface = { type = "TUNInterface" }
|
||||
},
|
||||
interfaces = { UDPInterface = {}, ETHInterface = {} },
|
||||
authorizedPasswords = {},
|
||||
logging = { logTo = "stdout" }
|
||||
}
|
||||
end
|
||||
|
||||
--- Return the cjdns configuration as a table suitable for JSON output
|
||||
--
|
||||
-- Iterates over cjdns, eth_interface, udp_interface, eth_peer, udp_peer,
|
||||
-- and password sections. Doesn't include IPTunnel related options yet.
|
||||
-- @return table with cjdns configuration
|
||||
function UCI.get()
|
||||
local obj = UCI.defaults()
|
||||
|
||||
local cursor = uci.cursor()
|
||||
|
||||
local config = cursor:get_all("cjdns", "cjdns")
|
||||
if not config then return obj end
|
||||
|
||||
obj.ipv6 = config.ipv6
|
||||
obj.publicKey = config.public_key
|
||||
obj.privateKey = config.private_key
|
||||
obj.admin = {
|
||||
bind = config.admin_address .. ":" .. config.admin_port,
|
||||
password = config.admin_password }
|
||||
|
||||
if config.tun_device and string.len(config.tun_device) > 0 then
|
||||
obj.router.interface.tunDevice = config.tun_device
|
||||
end
|
||||
|
||||
for i,section in pairs(obj.security) do
|
||||
if type(section.seccomp) == "number" then
|
||||
obj.security[i].seccomp = tonumber(config.seccomp)
|
||||
end
|
||||
end
|
||||
|
||||
cursor:foreach("cjdns", "iptunnel_outgoing", function(outgoing)
|
||||
table.insert(obj.router.ipTunnel.outgoingConnections, outgoing.public_key)
|
||||
end)
|
||||
|
||||
cursor:foreach("cjdns", "iptunnel_allowed", function(allowed)
|
||||
entry = { publicKey = allowed.public_key }
|
||||
if allowed.ipv4 then
|
||||
entry["ip4Address"] = allowed.ipv4
|
||||
end
|
||||
if allowed.ipv6 then
|
||||
entry["ip6Address"] = allowed.ipv6
|
||||
end
|
||||
table.insert(obj.router.ipTunnel.allowedConnections, entry)
|
||||
end)
|
||||
|
||||
cursor:foreach("cjdns", "eth_interface", function(eth_interface)
|
||||
table.insert(obj.interfaces.ETHInterface, {
|
||||
bind = eth_interface.bind,
|
||||
beacon = tonumber(eth_interface.beacon),
|
||||
connectTo = {}
|
||||
})
|
||||
end)
|
||||
|
||||
cursor:foreach("cjdns", "udp_interface", function(udp_interface)
|
||||
table.insert(obj.interfaces.UDPInterface, {
|
||||
bind = udp_interface.address .. ":" .. udp_interface.port,
|
||||
connectTo = {}
|
||||
})
|
||||
end)
|
||||
|
||||
cursor:foreach("cjdns", "eth_peer", function(eth_peer)
|
||||
if not eth_peer.address == "" then
|
||||
local i = tonumber(eth_peer.interface)
|
||||
obj.interfaces.ETHInterface[i].connectTo[eth_peer.address] = {
|
||||
publicKey = eth_peer.public_key,
|
||||
password = eth_peer.password
|
||||
}
|
||||
end
|
||||
end)
|
||||
|
||||
cursor:foreach("cjdns", "udp_peer", function(udp_peer)
|
||||
local bind = udp_peer.address .. ":" .. udp_peer.port
|
||||
local i = tonumber(udp_peer.interface)
|
||||
obj.interfaces.UDPInterface[i].connectTo[bind] = {
|
||||
user = udp_peer.user,
|
||||
publicKey = udp_peer.public_key,
|
||||
password = udp_peer.password
|
||||
}
|
||||
end)
|
||||
|
||||
cursor:foreach("cjdns", "password", function(password)
|
||||
table.insert(obj.authorizedPasswords, {
|
||||
password = password.password,
|
||||
user = password.user,
|
||||
contact = password.contact
|
||||
})
|
||||
end)
|
||||
|
||||
return obj
|
||||
end
|
||||
|
||||
--- Parse and save updated configuration from JSON input
|
||||
--
|
||||
-- Transforms general settings, ETHInterface, UDPInterface, connectTo, and
|
||||
-- authorizedPasswords fields into UCI sections, and replaces the UCI config's
|
||||
-- contents with them.
|
||||
-- @param table JSON input
|
||||
-- @return Boolean whether saving succeeded
|
||||
function UCI.set(obj)
|
||||
local cursor = uci.cursor()
|
||||
|
||||
for i, section in pairs(cursor:get_all("cjdns")) do
|
||||
cursor:delete("cjdns", section[".name"])
|
||||
end
|
||||
|
||||
local admin_address, admin_port = string.match(obj.admin.bind, "^(.*):(.*)$")
|
||||
UCI.cursor_section(cursor, "cjdns", "cjdns", "cjdns", {
|
||||
ipv6 = obj.ipv6,
|
||||
public_key = obj.publicKey,
|
||||
private_key = obj.privateKey,
|
||||
admin_password = obj.admin.password,
|
||||
admin_address = admin_address,
|
||||
admin_port = admin_port
|
||||
})
|
||||
|
||||
if obj.router.interface.tunDevice then
|
||||
UCI.cursor_section(cursor, "cjdns", "cjdns", "cjdns", {
|
||||
tun_device = tostring(obj.router.interface.tunDevice)
|
||||
})
|
||||
end
|
||||
|
||||
if obj.security then
|
||||
for i,section in pairs(obj.security) do
|
||||
for key,value in pairs(section) do
|
||||
if key == "seccomp" then
|
||||
UCI.cursor_section(cursor, "cjdns", "cjdns", "cjdns", {
|
||||
seccomp = tonumber(value)
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if obj.router.ipTunnel.outgoingConnections then
|
||||
for i,public_key in pairs(obj.router.ipTunnel.outgoingConnections) do
|
||||
UCI.cursor_section(cursor, "cjdns", "iptunnel_outgoing", nil, {
|
||||
public_key = public_key
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
if obj.router.ipTunnel.allowedConnections then
|
||||
for i,allowed in pairs(obj.router.ipTunnel.allowedConnections) do
|
||||
entry = { public_key = allowed.publicKey }
|
||||
if allowed.ip4Address then
|
||||
entry["ipv4"] = allowed.ip4Address
|
||||
end
|
||||
if allowed.ip6Address then
|
||||
entry["ipv6"] = allowed.ip6Address
|
||||
end
|
||||
|
||||
UCI.cursor_section(cursor, "cjdns", "iptunnel_allowed", nil, entry)
|
||||
end
|
||||
end
|
||||
|
||||
if obj.interfaces.ETHInterface then
|
||||
for i,interface in pairs(obj.interfaces.ETHInterface) do
|
||||
UCI.cursor_section(cursor, "cjdns", "eth_interface", nil, {
|
||||
bind = interface.bind,
|
||||
beacon = tostring(interface.beacon)
|
||||
})
|
||||
|
||||
if interface.connectTo then
|
||||
for peer_address,peer in pairs(interface.connectTo) do
|
||||
UCI.cursor_section(cursor, "cjdns", "eth_peer", nil, {
|
||||
interface = i,
|
||||
address = peer_address,
|
||||
public_key = peer.publicKey,
|
||||
password = peer.password
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if obj.interfaces.UDPInterface then
|
||||
for i,interface in pairs(obj.interfaces.UDPInterface) do
|
||||
local address, port = string.match(interface.bind, "^(.*):(.*)$")
|
||||
UCI.cursor_section(cursor, "cjdns", "udp_interface", nil, {
|
||||
address = address,
|
||||
port = port
|
||||
})
|
||||
|
||||
if interface.connectTo then
|
||||
for peer_bind,peer in pairs(interface.connectTo) do
|
||||
local peer_address, peer_port = string.match(peer_bind, "^(.*):(.*)$")
|
||||
UCI.cursor_section(cursor, "cjdns", "udp_peer", nil, {
|
||||
interface = i,
|
||||
address = peer_address,
|
||||
port = peer_port,
|
||||
user = peer.user,
|
||||
public_key = peer.publicKey,
|
||||
password = peer.password
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if obj.authorizedPasswords then
|
||||
for i,password in pairs(obj.authorizedPasswords) do
|
||||
local user = password.user
|
||||
if not user or string.len(user) == 0 then
|
||||
user = "user-" .. UCI.random_string(6)
|
||||
end
|
||||
|
||||
UCI.cursor_section(cursor, "cjdns", "password", nil, {
|
||||
password = password.password,
|
||||
user = user,
|
||||
contact = password.contact
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
return cursor:save("cjdns")
|
||||
end
|
||||
|
||||
--- Simple backport of Cursor:section from luci.model.uci
|
||||
--
|
||||
-- Backport reason: we don't wanna depend on LuCI.
|
||||
-- @param Cursor the UCI cursor to operate on
|
||||
-- @param string name of the config
|
||||
-- @param string type of the section
|
||||
-- @param string name of the section (optional)
|
||||
-- @param table config values
|
||||
function UCI.cursor_section(cursor, config, type, section, values)
|
||||
if section then
|
||||
cursor:set(config, section, type)
|
||||
else
|
||||
section = cursor:add("cjdns", type)
|
||||
end
|
||||
|
||||
for k,v in pairs(values) do
|
||||
cursor:set(config, section, k, v)
|
||||
end
|
||||
end
|
||||
|
||||
function UCI.makeInterface()
|
||||
local cursor = uci.cursor()
|
||||
|
||||
local config = cursor:get_all("cjdns", "cjdns")
|
||||
if not config then return nil end
|
||||
|
||||
return common.AdminInterface.new({
|
||||
host = config.admin_address,
|
||||
port = config.admin_port,
|
||||
password = config.admin_password,
|
||||
config = UCI.get(),
|
||||
timeout = 2
|
||||
})
|
||||
end
|
||||
|
||||
function UCI.random_string(length)
|
||||
-- tr -cd 'A-Za-z0-9' < /dev/urandom
|
||||
local urandom = io.popen("tr -cd 'A-Za-z0-9' 2> /dev/null < /dev/urandom", "r")
|
||||
local string = urandom:read(length)
|
||||
urandom:close()
|
||||
return string
|
||||
end
|
102
cjdns/lua/cjdns/udp.lua
Normal file
102
cjdns/lua/cjdns/udp.lua
Normal file
|
@ -0,0 +1,102 @@
|
|||
-- Cjdns admin module for Lua
|
||||
-- Written by Philip Horger
|
||||
|
||||
common = require 'cjdns/common'
|
||||
|
||||
UDPInterface = {}
|
||||
UDPInterface.__index = UDPInterface
|
||||
common.UDPInterface = UDPInterface
|
||||
|
||||
function UDPInterface.new(ai, config, ptype)
|
||||
properties = {
|
||||
ai = ai,
|
||||
config = config or ai.config,
|
||||
ptype = ptype or "ai"
|
||||
}
|
||||
|
||||
return setmetatable(properties, UDPInterface)
|
||||
end
|
||||
|
||||
function UDPInterface:call(name, args)
|
||||
local func = self[name .. "_" .. self.ptype]
|
||||
return func(self, unpack(args))
|
||||
end
|
||||
|
||||
function UDPInterface:newBind(...)
|
||||
return self:call("newBind", arg)
|
||||
end
|
||||
|
||||
function UDPInterface:beginConnection(...)
|
||||
return self:call("beginConnection", arg)
|
||||
end
|
||||
|
||||
function UDPInterface:newBind_ai(address)
|
||||
local response, err = self.ai:auth({
|
||||
q = "UDPInterface_new",
|
||||
bindAddress = address
|
||||
})
|
||||
if not response then
|
||||
return nil, err
|
||||
elseif response.error ~= "none" then
|
||||
return nil, response.error
|
||||
elseif response.interfaceNumber then
|
||||
return response.interfaceNumber
|
||||
else
|
||||
return nil, "bad response format"
|
||||
end
|
||||
end
|
||||
|
||||
function UDPInterface:newBind_config(address)
|
||||
local udpif = self.config.contents.interfaces.UDPInterface
|
||||
local new_interface = {
|
||||
bind = address,
|
||||
connectTo = {}
|
||||
}
|
||||
table.insert(udpif, new_interface)
|
||||
return (#udpif - 1), new_interface
|
||||
end
|
||||
|
||||
function UDPInterface:newBind_perm(...)
|
||||
return
|
||||
self:newBind_config(unpack(arg)),
|
||||
self:newBind_ai(unpack(arg))
|
||||
end
|
||||
|
||||
function UDPInterface:beginConnection_ai(pubkey, addr, password, interface)
|
||||
local request = {
|
||||
q = "UDPInterface_beginConnection",
|
||||
publicKey = pubkey,
|
||||
address = addr,
|
||||
password = password
|
||||
}
|
||||
if interface then
|
||||
request.interfaceNumber = interface
|
||||
end
|
||||
|
||||
local response, err = self.ai:auth(request)
|
||||
if not response then
|
||||
return nil, err
|
||||
elseif response.error == "none" then
|
||||
-- Unfortunately, no real success indicator either.
|
||||
return "No error"
|
||||
else
|
||||
return nil, response.error
|
||||
end
|
||||
end
|
||||
|
||||
function UDPInterface:beginConnection_config(pubkey, addr, password, interface)
|
||||
local udpif = self.config.contents.interfaces.UDPInterface
|
||||
local connections = udpif[(interface or 0) + 1].connectTo
|
||||
local this_conn = {
|
||||
password = password,
|
||||
publicKey = pubkey
|
||||
}
|
||||
connections[addr] = this_conn
|
||||
return this_conn -- allows adding metadata fields afterwards
|
||||
end
|
||||
|
||||
function UDPInterface:beginConnection_perm(...)
|
||||
return
|
||||
self:beginConnection_config(unpack(arg)),
|
||||
self:beginConnection_ai(unpack(arg))
|
||||
end
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (C) 2012-2013 OpenWrt.org
|
||||
# Copyright (C) 2012-2014 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
|
@ -7,13 +7,14 @@
|
|||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=hnetd
|
||||
PKG_SOURCE_VERSION:=91aaab8bdd4de8bc96ad906673a79a6600cf93ac
|
||||
PKG_VERSION:=2014-09-02-$(PKG_SOURCE_VERSION)
|
||||
PKG_RELEASE:=2
|
||||
PKG_SOURCE_VERSION:=606d7e904603ad8792ac1a7ba825618df97b5a4e
|
||||
PKG_VERSION:=2016-06-28-$(PKG_SOURCE_VERSION)
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=git://github.com/sbyx/hnetd.git
|
||||
PKG_SOURCE_URL:=https://github.com/sbyx/hnetd.git
|
||||
PKG_MAINTAINER:=Steven Barth <cyrus@openwrt.org>
|
||||
PKG_LICENSE:=GPL-2.0
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
@ -27,25 +28,61 @@ CMAKE_OPTIONS += -DL_LEVEL=7
|
|||
# OpenWRT target
|
||||
CMAKE_OPTIONS += -DBACKEND=openwrt
|
||||
|
||||
define Package/hnetd
|
||||
ifeq ($(BUILD_VARIANT),openssl)
|
||||
CMAKE_OPTIONS += -DDTLS_OPENSSL=1
|
||||
endif
|
||||
|
||||
define Package/hnetd/Default
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=HNCP Homenet daemon
|
||||
TITLE:=HNCP Homenet daemon - $(2)
|
||||
URL:=https://github.com/sbyx/hnetd
|
||||
DEPENDS:=+odhcpd +odhcp6c +netifd
|
||||
DEPENDS+=+@IPV6
|
||||
DEPENDS:=+odhcpd +odhcp6c +netifd $(3)
|
||||
DEPENDS+=@IPV6
|
||||
VARIANT:=$1
|
||||
endef
|
||||
|
||||
Package/hnetd-nossl=$(call Package/hnetd/Default,nossl,no authentication)
|
||||
Package/hnetd-openssl=$(call Package/hnetd/Default,openssl,authentication via OpenSSL,+libopenssl)
|
||||
|
||||
define Package/hnet-full
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=HNCP Homenet metapackage
|
||||
URL:=https://github.com/sbyx/hnetd
|
||||
DEPENDS:=+hnetd +luci-app-hnet
|
||||
DEPENDS:=+hnetd-nossl +luci-app-hnet +ip
|
||||
# Routing
|
||||
DEPENDS+=+babels
|
||||
DEPENDS+=+babeld
|
||||
# Service discovery
|
||||
DEPENDS+=+ohybridproxy
|
||||
DEPENDS+=+ohybridproxy +zonestitcher
|
||||
# Distributed PCP support
|
||||
DEPENDS+=+miniupnpd +minimalist-pcproxy
|
||||
endef
|
||||
|
||||
define Package/hnet-full-secure
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=HNCP Homenet metapackage (w/ SSL)
|
||||
URL:=https://github.com/sbyx/hnetd
|
||||
DEPENDS:=+hnetd-openssl +luci-app-hnet +ip
|
||||
# Routing
|
||||
DEPENDS+=+babeld
|
||||
# Service discovery
|
||||
DEPENDS+=+ohybridproxy +zonestitcher
|
||||
# Distributed PCP support
|
||||
DEPENDS+=+miniupnpd +minimalist-pcproxy
|
||||
endef
|
||||
|
||||
define Package/hnet-full-l2tp
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=HNCP Homenet metapackage (w/ L2TP)
|
||||
URL:=https://github.com/sbyx/hnetd
|
||||
DEPENDS:=+hnetd-nossl +luci-app-hnet +ip-full +kmod-l2tp-eth
|
||||
# Routing
|
||||
DEPENDS+=+babeld
|
||||
# Service discovery
|
||||
DEPENDS+=+ohybridproxy +zonestitcher
|
||||
# Distributed PCP support
|
||||
DEPENDS+=+miniupnpd +minimalist-pcproxy
|
||||
endef
|
||||
|
@ -55,37 +92,52 @@ define Package/luci-app-hnet
|
|||
CATEGORY:=LuCI
|
||||
SUBMENU:=3. Applications
|
||||
TITLE:=HNCP Homenet configuration and visualization
|
||||
DEPENDS:=+hnetd
|
||||
# DEPENDS:=+hnetd
|
||||
# TBD - how to express dependency on 'some' hnetd?
|
||||
endef
|
||||
|
||||
define Package/hnetd/description
|
||||
define Package/hnetd-$(BUILD_VARIANT)/description
|
||||
This package provides a daemon which implementats distributed prefix assignment
|
||||
and service discovery for a home network consisting of multiple routers
|
||||
connected to multiple service providers. It provides a netifd protocol "hnet"
|
||||
for use in /etc/config/network.
|
||||
endef
|
||||
|
||||
define Package/hnetd/install
|
||||
define Package/hnetd-$(BUILD_VARIANT)/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin/
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/hnetd $(1)/usr/sbin/
|
||||
$(INSTALL_DIR) $(1)/lib/netifd/proto
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/openwrt/hnet.sh $(1)/lib/netifd/proto
|
||||
ln -s hnetd $(1)/usr/sbin/hnet-ifresolve
|
||||
ln -s hnetd $(1)/usr/sbin/hnet-trust
|
||||
ln -s hnetd $(1)/usr/sbin/hnet-dump
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/hnetd.init $(1)/etc/init.d/hnetd
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_DATA) ./files/hnet.config $(1)/etc/config/hnet
|
||||
$(INSTALL_BIN) ./files/ohp-script $(1)/usr/sbin/hnetd-ohp-script
|
||||
$(INSTALL_BIN) ./files/pcp-script $(1)/usr/sbin/hnetd-pcp-script
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/generic/ohp.script $(1)/usr/sbin/hnetd-ohp-script
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/generic/ddz.script $(1)/usr/sbin/hnetd-ddz-script
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/generic/pcp.script $(1)/usr/sbin/hnetd-pcp-script
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/generic/hnetd-routing $(1)/usr/sbin/hnetd-routing
|
||||
$(INSTALL_DIR) $(1)/etc/uci-defaults
|
||||
$(INSTALL_BIN) ./files/hnetd.defaults $(1)/etc/uci-defaults/x-hnetd.defaults
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/generic/multicast.script $(1)/usr/sbin/hnet-multicast
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/openwrt/autowifi.script $(1)/usr/sbin/autowifi
|
||||
endef
|
||||
|
||||
define Package/hnet-full/install
|
||||
true
|
||||
endef
|
||||
|
||||
define Package/hnet-full-secure/install
|
||||
true
|
||||
endef
|
||||
|
||||
define Package/hnet-full-l2tp/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin/
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/generic/tunnel.script $(1)/usr/sbin/hnetd-tunnel
|
||||
endef
|
||||
|
||||
define Package/luci-app-hnet/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib/lua/luci
|
||||
$(INSTALL_DIR) $(1)/www
|
||||
|
@ -93,7 +145,7 @@ define Package/luci-app-hnet/install
|
|||
$(CP) -R $(PKG_BUILD_DIR)/openwrt/luci/htdocs/* $(1)/www/
|
||||
endef
|
||||
|
||||
define Package/hnetd/postinst
|
||||
define Package/hnetd-$(BUILD_VARIANT)/postinst
|
||||
#!/bin/sh
|
||||
[ -n "$${IPKG_INSTROOT}" ] || {
|
||||
(. /etc/uci-defaults/x-hnetd.defaults) && rm -f /etc/uci-defaults/x-hnetd.defaults
|
||||
|
@ -101,9 +153,11 @@ define Package/hnetd/postinst
|
|||
/etc/init.d/hnetd enable
|
||||
/etc/init.d/hnetd start
|
||||
}
|
||||
exit 0
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,hnetd))
|
||||
$(eval $(call BuildPackage,hnetd-nossl))
|
||||
$(eval $(call BuildPackage,hnetd-openssl))
|
||||
$(eval $(call BuildPackage,hnet-full))
|
||||
$(eval $(call BuildPackage,hnet-full-secure))
|
||||
$(eval $(call BuildPackage,hnet-full-l2tp))
|
||||
$(eval $(call BuildPackage,luci-app-hnet))
|
||||
|
|
|
@ -1,8 +1,29 @@
|
|||
config security security
|
||||
# Simplest security mode:
|
||||
# option password foo
|
||||
# Trust consensus and CA-based share these options:
|
||||
# option certificate_file /etc/hnetd-cert.pem
|
||||
# option private_key_file /etc/hnetd-key.pem
|
||||
# Then to enable trust consensus:
|
||||
# option trust_store /etc/hnetd-trust.dat
|
||||
# Or CA-based authentication:
|
||||
# option trust_certificate_file /etc/ca-cert.pem
|
||||
|
||||
config pa pa
|
||||
# option ip4prefix 10.0.0.0/8
|
||||
# option ip4mode ifuplink
|
||||
# option ulaprefix fd12:3456:789A::/48
|
||||
# option persistent_store /etc/hnet-pa.store
|
||||
# option ulamode off
|
||||
option persistent_store /etc/hnet-pa.store
|
||||
|
||||
config sd sd
|
||||
# option router_name openwrt
|
||||
# option domain_name home.
|
||||
|
||||
|
||||
# Wifi allows for very basic wifi autoconfiguration
|
||||
# Warning: This feature is unstable
|
||||
config wifi wifi
|
||||
# option enable 0
|
||||
# option ssid ssidtest
|
||||
# option password test
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Why we tune dnsmasq?
|
||||
# localservice=0 => other hnetd instances can query for local names
|
||||
# boguspriv=0 => allow reverse resolution of RFC1918 w/o local hosts entries
|
||||
|
||||
uci batch <<EOF
|
||||
set dhcp.odhcpd.maindhcp=1
|
||||
set dhcp.@dnsmasq[0].localservice=0
|
||||
set dhcp.@dnsmasq[0].boguspriv=0
|
||||
commit dhcp
|
||||
EOF
|
||||
|
|
|
@ -12,8 +12,12 @@ DNSMASQ_DIR=/tmp/dnsmasq.d
|
|||
DNSMASQ_SCRIPT=/etc/init.d/dnsmasq
|
||||
OHP_SCRIPT=/usr/sbin/hnetd-ohp-script
|
||||
OHP_BINARY=/usr/sbin/ohybridproxy
|
||||
DDZ_SCRIPT=/usr/sbin/hnetd-ddz-script
|
||||
DDZ_BINARY=/usr/sbin/zonestitcher
|
||||
PCP_SCRIPT=/usr/sbin/hnetd-pcp-script
|
||||
PCP_BINARY=/usr/sbin/minimalist-pcproxy
|
||||
MULTICAST_SCRIPT=/usr/sbin/hnet-multicast
|
||||
WIFI_SCRIPT=/usr/sbin/autowifi
|
||||
|
||||
start_service() {
|
||||
. /lib/functions.sh
|
||||
|
@ -36,6 +40,27 @@ start_service() {
|
|||
then
|
||||
procd_append_param command -n "$HOSTNAME"
|
||||
fi
|
||||
if [ -f $DDZ_BINARY ]
|
||||
then
|
||||
procd_append_param command -z $DDZ_SCRIPT
|
||||
fi
|
||||
fi
|
||||
|
||||
# Enable multicast if present and installed
|
||||
if [ -f "$MULTICAST_SCRIPT" ]
|
||||
then
|
||||
$MULTICAST_SCRIPT status && procd_append_param command -M "$MULTICAST_SCRIPT"
|
||||
fi
|
||||
|
||||
config_get enableval wifi enable
|
||||
if [ -f "$WIFI_SCRIPT" -a "$enableval" = "1" ]; then
|
||||
wifiopt=$WIFI_SCRIPT
|
||||
config_get ssidval wifi ssid
|
||||
config_get passval wifi password
|
||||
if [ -n "$ssidval" -a -n "$passval" ]; then
|
||||
wifiopt=${wifiopt},${ssidval}:${passval}
|
||||
fi
|
||||
procd_append_param command -w "$wifiopt"
|
||||
fi
|
||||
|
||||
# Enable PCP, if it's present
|
||||
|
@ -51,21 +76,52 @@ start_service() {
|
|||
# Routing script
|
||||
procd_append_param command -r /usr/sbin/hnetd-routing
|
||||
|
||||
[ -x /usr/sbin/hnetd-tunnel ] && \
|
||||
procd_append_param command -t /usr/sbin/hnetd-tunnel
|
||||
|
||||
# Prefix assignment (pa)
|
||||
config_get val pa ip4prefix
|
||||
[ -n "$val" ] && procd_append_param command --ip4prefix $val
|
||||
|
||||
config_get val pa ip4mode
|
||||
[ -n "$val" ] && procd_append_param command --ip4mode $val
|
||||
|
||||
config_get val pa ulaprefix
|
||||
[ -n "$val" ] && procd_append_param command --ulaprefix $val
|
||||
|
||||
config_get val pa ulamode
|
||||
[ -n "$val" ] && procd_append_param command --ulamode $val
|
||||
|
||||
# Service discovery (sd)
|
||||
config_get val sd router_name
|
||||
[ -n "$val" ] && procd_append_param command -n $val
|
||||
|
||||
config_get val sd domain_name
|
||||
[ -n "$val" ] && procd_append_param command -m $val
|
||||
|
||||
# Security (needs security-enabled build)
|
||||
config_get val security password
|
||||
[ -n "$val" ] && procd_append_param command --password $val
|
||||
|
||||
config_get val security certificate_file
|
||||
[ -n "$val" ] && procd_append_param command --certificate $val
|
||||
|
||||
config_get val security private_key_file
|
||||
[ -n "$val" ] && procd_append_param command --privatekey $val
|
||||
|
||||
config_get val security trust_store
|
||||
[ -n "$val" ] && procd_append_param command --trust $val
|
||||
|
||||
config_get val security trust_certificate_file
|
||||
[ -n "$val" ] && procd_append_param command --verify-path $val
|
||||
|
||||
# For more verbose logging, uncomment this:
|
||||
#procd_append_param command --loglevel 7
|
||||
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger "hnet"
|
||||
}
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
#!/bin/sh
|
||||
#-*-sh-*-
|
||||
#
|
||||
# $Id: ohp-script $
|
||||
#
|
||||
# Author: Markus Stenberg <mstenber@cisco.com>
|
||||
#
|
||||
# Copyright (c) 2014 cisco Systems, Inc.
|
||||
#
|
||||
# Created: Fri Jan 17 11:46:30 2014 mstenber
|
||||
# Last modified: Mon Feb 3 14:39:15 2014 mstenber
|
||||
# Edit time: 15 min
|
||||
#
|
||||
|
||||
# This is minimalist init.d-like start/stop script for
|
||||
# ohybridproxy. However, as ohybridproxy receives it's configuration
|
||||
# via command line, the 'start' command is also equivalent to
|
||||
# 'restart', and has bunch of extra arguments..
|
||||
|
||||
OHP=ohybridproxy
|
||||
|
||||
start() {
|
||||
$OHP $* &
|
||||
}
|
||||
|
||||
stop() {
|
||||
killall -9 $OHP
|
||||
}
|
||||
|
||||
|
||||
CMD=$1
|
||||
# For debugging purposes
|
||||
LOGNAME=`basename $0`
|
||||
echo "$*" | logger -t "$LOGNAME"
|
||||
case $CMD in
|
||||
start)
|
||||
shift
|
||||
stop
|
||||
start $*
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
*)
|
||||
echo "Only start [config]/stop supported"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
|
@ -1,46 +0,0 @@
|
|||
#!/bin/sh
|
||||
#-*-sh-*-
|
||||
#
|
||||
# $Id: pcp-script $
|
||||
#
|
||||
# Author: Markus Stenberg <mstenber@cisco.com>
|
||||
#
|
||||
# Copyright (c) 2014 cisco Systems, Inc.
|
||||
#
|
||||
# Created: Fri Jan 17 11:46:30 2014 mstenber
|
||||
# Last modified: Fri May 30 13:27:57 2014 mstenber
|
||||
# Edit time: 16 min
|
||||
#
|
||||
|
||||
# Copied from ohp-script.. Same idea. Just prod minimalist-pcproxy as
|
||||
# needed, hoping the miniupnpd is taken care of by the system.
|
||||
|
||||
PCP=minimalist-pcproxy
|
||||
|
||||
start() {
|
||||
$PCP $* &
|
||||
}
|
||||
|
||||
stop() {
|
||||
killall -9 $PCP
|
||||
}
|
||||
|
||||
|
||||
CMD=$1
|
||||
# For debugging purposes
|
||||
LOGNAME=`basename $0`
|
||||
echo "$*" | logger -t "$LOGNAME"
|
||||
case $CMD in
|
||||
start)
|
||||
shift
|
||||
stop
|
||||
start $*
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
*)
|
||||
echo "Only start [config]/stop supported"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
|
@ -1,56 +0,0 @@
|
|||
#
|
||||
# Copyright (C) 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:=luci-app-bcp38
|
||||
PKG_VERSION:=2
|
||||
PKG_RELEASE:=1
|
||||
LUCI_DIR:=/usr/lib/lua/luci
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/luci-app-bcp38
|
||||
SECTION:=luci
|
||||
CATEGORY:=LuCI
|
||||
TITLE:=BCP38 LuCI interface
|
||||
MAINTAINER:=Toke Høiland-Jørgensen <toke@toke.dk>
|
||||
PKGARCH:=all
|
||||
DEPENDS:= lua luci-base +bcp38
|
||||
SUBMENU:=3. Applications
|
||||
endef
|
||||
|
||||
define Package/luci-app-bcp38/description
|
||||
Control BCP38 subnet blocking
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
define Build/Configure
|
||||
endef
|
||||
|
||||
define Package/luci-app-bcp38/install
|
||||
$(INSTALL_DIR) $(1)$(LUCI_DIR)/controller $(1)$(LUCI_DIR)/model/cbi
|
||||
$(INSTALL_DATA) ./files/bcp38-controller.lua $(1)$(LUCI_DIR)/controller/bcp38.lua
|
||||
$(INSTALL_DATA) ./files/bcp38-cbi.lua $(1)$(LUCI_DIR)/model/cbi/bcp38.lua
|
||||
$(INSTALL_DIR) $(1)/etc/uci-defaults
|
||||
$(INSTALL_BIN) ./files/uci-defaults-bcp38 $(1)/etc/uci-defaults/luci-bcp38
|
||||
endef
|
||||
|
||||
define Package/luci-app-bcp38/postinst
|
||||
#!/bin/sh
|
||||
[ -x /etc/uci-defaults/luci-bcp38 ] && /etc/uci-defaults/luci-bcp38 || exit 0
|
||||
endef
|
||||
|
||||
define Package/luci-app-bcp38/postrm
|
||||
#!/bin/sh
|
||||
uci delete ucitrack.@bcp38[0]
|
||||
uci commit
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,luci-app-bcp38))
|
|
@ -1,58 +0,0 @@
|
|||
--[[
|
||||
LuCI - Lua Configuration Interface
|
||||
|
||||
Copyright 2014 Toke Høiland-Jørgensen <toke@toke.dk>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
$Id$
|
||||
]]--
|
||||
|
||||
local wa = require "luci.tools.webadmin"
|
||||
local net = require "luci.model.network".init()
|
||||
local ifaces = net:get_interfaces()
|
||||
|
||||
m = Map("bcp38", translate("BCP38"),
|
||||
translate("This function blocks packets with private address destinations " ..
|
||||
"from going out onto the internet as per " ..
|
||||
"<a href=\"http://tools.ietf.org/html/bcp38\">BCP 38</a>."))
|
||||
|
||||
s = m:section(TypedSection, "bcp38", translate("BCP38 config"))
|
||||
s.anonymous = true
|
||||
-- BASIC
|
||||
e = s:option(Flag, "enabled", translate("Enable"))
|
||||
e.rmempty = false
|
||||
|
||||
a = s:option(Flag, "detect_upstream", translate("Auto-detect upstream IP"),
|
||||
translate("Attempt to automatically detect if the upstream IP " ..
|
||||
"will be blocked by the configuration, and add an exception if it will. " ..
|
||||
"If this does not work correctly, you can add exceptions manually below."))
|
||||
a.rmempty = false
|
||||
|
||||
n = s:option(ListValue, "interface", translate("Interface name"), translate("Interface to apply the blocking to " ..
|
||||
"(should be the upstream WAN interface)."))
|
||||
for _, iface in ipairs(ifaces) do
|
||||
if iface:is_up() then
|
||||
n:value(iface:name())
|
||||
end
|
||||
end
|
||||
n.rmempty = false
|
||||
|
||||
ma = s:option(DynamicList, "match",
|
||||
translate("Blocked IP ranges"))
|
||||
|
||||
ma.datatype = "ip4addr"
|
||||
|
||||
nm = s:option(DynamicList, "nomatch",
|
||||
translate("Allowed IP ranges"), translate("Takes precedence over blocked ranges. "..
|
||||
"Use to whitelist your upstream network if you're behind a double NAT " ..
|
||||
"and the auto-detection doesn't work."))
|
||||
|
||||
nm.datatype = "ip4addr"
|
||||
|
||||
|
||||
return m
|
|
@ -1,7 +0,0 @@
|
|||
module("luci.controller.bcp38", package.seeall)
|
||||
|
||||
function index()
|
||||
entry({"admin", "network", "firewall", "bcp38"},
|
||||
cbi("bcp38"),
|
||||
_("BCP38"), 50).dependent = false
|
||||
end
|
|
@ -1,11 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@bcp38[-1]
|
||||
add ucitrack bcp38
|
||||
add_list ucitrack.@bcp38[0].affects=firewall
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
rm -f /tmp/luci-indexcache
|
||||
exit 0
|
|
@ -23,6 +23,7 @@ PKG_NAME:=luci-app-bmx6
|
|||
PKG_RELEASE:=3
|
||||
|
||||
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
|
||||
PKG_LICENSE:=GPL-2.0+
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
|
|
|
@ -112,12 +112,16 @@ function wget(url, timeout)
|
|||
if pid == 0 then
|
||||
rfd:close()
|
||||
nixio.dup(wfd, nixio.stdout)
|
||||
|
||||
local candidates = { "/usr/bin/wget", "/bin/wget" }
|
||||
-- candidates for wget, try first ones with SSL support
|
||||
local candidates = {{"/usr/bin/wget-ssl",1},{"/usr/bin/wget",0},{"/bin/wget",0}}
|
||||
local _, bin
|
||||
for _, bin in ipairs(candidates) do
|
||||
if nixiofs.access(bin, "x") then
|
||||
nixio.exec(bin, "-q", "-O", "-", url)
|
||||
if nixiofs.access(bin[1], "x") then
|
||||
if bin[2] == 0 then
|
||||
nixio.exec(bin[1], "-q", "-O", "-", url)
|
||||
else
|
||||
nixio.exec(bin[1], "--no-check-certificate", "-q", "-O", "-", url)
|
||||
end
|
||||
end
|
||||
end
|
||||
return
|
||||
|
|
|
@ -27,7 +27,8 @@ m = Map("bmx6", "bmx6")
|
|||
-- Getting json and Checking if bmx6-json is avaiable
|
||||
local options = bmx6json.get("options")
|
||||
if options == nil or options.OPTIONS == nil then
|
||||
m.message = "bmx6-json plugin is not running or some mistake in luci-bmx6 configuration, check /etc/config/luci-bmx6"
|
||||
m.message = "bmx6-json plugin is not running or some mistake in luci-bmx6 configuration, check /etc/config/luci-bmx6"
|
||||
return m
|
||||
else
|
||||
options = options.OPTIONS
|
||||
end
|
||||
|
|
339
luci-app-bmx7/COPYING
Normal file
339
luci-app-bmx7/COPYING
Normal file
|
@ -0,0 +1,339 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
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.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
63
luci-app-bmx7/Makefile
Normal file
63
luci-app-bmx7/Makefile
Normal file
|
@ -0,0 +1,63 @@
|
|||
# Copyright © 2011 Pau Escrich <pau@dabax.net>
|
||||
# Contributors Roger Pueyo Centelles <roger.pueyo@guifi.net>
|
||||
#
|
||||
# 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.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# The full GNU General Public License is included in this distribution in
|
||||
# the file called "COPYING".
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-bmx7
|
||||
PKG_RELEASE:=0.0-alpha
|
||||
|
||||
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
|
||||
PKG_LICENSE:=GPL-2.0+
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/luci-app-bmx7
|
||||
SECTION:=luci
|
||||
CATEGORY:=LuCI
|
||||
SUBMENU:=3. Applications
|
||||
TITLE:= LuCI support for BMX7
|
||||
DEPENDS:=+luci-lib-json +luci-mod-admin-full +luci-lib-httpclient +bmx7
|
||||
MAINTAINER:= Roger Pueyo Centelles <roger.pueyo@guifi.net>
|
||||
endef
|
||||
|
||||
define Package/luci-app-bmx7/description
|
||||
LuCI application for web-based configuration and visualization of the BMX7 routing daemon
|
||||
endef
|
||||
|
||||
define Package/luci-app-bmx7/conffiles
|
||||
/etc/config/luci-bmx7
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
endef
|
||||
|
||||
define Build/Configure
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
define Package/luci-app-bmx7/install
|
||||
$(CP) ./files/* $(1)/
|
||||
chmod 755 $(1)/www/cgi-bin/bmx7-info
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,luci-app-bmx7))
|
||||
|
7
luci-app-bmx7/files/etc/config/luci-bmx7
Normal file
7
luci-app-bmx7/files/etc/config/luci-bmx7
Normal file
|
@ -0,0 +1,7 @@
|
|||
config 'bmx7' 'luci'
|
||||
option ignore '0'
|
||||
option place 'admin network BMX7'
|
||||
#option place 'qmp Mesh'
|
||||
option position '3'
|
||||
#option json 'http://127.0.0.1/cgi-bin/bmx7-info?'
|
||||
option json 'exec:/www/cgi-bin/bmx7-info -s'
|
77
luci-app-bmx7/files/usr/lib/lua/luci/controller/bmx7.lua
Normal file
77
luci-app-bmx7/files/usr/lib/lua/luci/controller/bmx7.lua
Normal file
|
@ -0,0 +1,77 @@
|
|||
--[[
|
||||
Copyright (C) 2011 Pau Escrich <pau@dabax.net>
|
||||
Contributors Jo-Philipp Wich <xm@subsignal.org>
|
||||
Roger Pueyo Centelles <roger.pueyo@guifi.net>
|
||||
|
||||
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.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
The full GNU General Public License is included in this distribution in
|
||||
the file called "COPYING".
|
||||
--]]
|
||||
|
||||
module("luci.controller.bmx7", package.seeall)
|
||||
|
||||
function index()
|
||||
local place = {}
|
||||
local ucim = require "luci.model.uci"
|
||||
local uci = ucim.cursor()
|
||||
|
||||
-- checking if ignore is on
|
||||
if uci:get("luci-bmx7","luci","ignore") == "1" then
|
||||
return nil
|
||||
end
|
||||
|
||||
-- getting value from uci database
|
||||
local uci_place = uci:get("luci-bmx7","luci","place")
|
||||
|
||||
-- default values
|
||||
if uci_place == nil then
|
||||
place = {"bmx7"}
|
||||
else
|
||||
local util = require "luci.util"
|
||||
place = util.split(uci_place," ")
|
||||
end
|
||||
|
||||
-- getting position of menu
|
||||
local uci_position = uci:get("luci-bmx7","luci","position")
|
||||
|
||||
|
||||
---------------------------
|
||||
-- Placing the pages in the menu
|
||||
---------------------------
|
||||
|
||||
-- Status (default)
|
||||
entry(place,call("action_status_j"),place[#place],tonumber(uci_position))
|
||||
|
||||
table.insert(place,"Status")
|
||||
entry(place,call("action_status_j"),"Status",0)
|
||||
table.remove(place)
|
||||
|
||||
-- Nodes list
|
||||
table.insert(place,"Nodes")
|
||||
entry(place,call("action_nodes_j"),"Nodes",1)
|
||||
table.remove(place)
|
||||
end
|
||||
|
||||
|
||||
function action_status_j()
|
||||
luci.template.render("bmx7/status_j", {})
|
||||
end
|
||||
|
||||
function action_nodes_j()
|
||||
local http = require "luci.http"
|
||||
local link_non_js = "/cgi-bin/luci" .. http.getenv("PATH_INFO") .. '/nodes_nojs'
|
||||
luci.template.render("bmx7/nodes_j", {link_non_js=link_non_js})
|
||||
end
|
175
luci-app-bmx7/files/usr/lib/lua/luci/view/bmx7/nodes_j.htm
Normal file
175
luci-app-bmx7/files/usr/lib/lua/luci/view/bmx7/nodes_j.htm
Normal file
|
@ -0,0 +1,175 @@
|
|||
<%#
|
||||
Copyright © 2011 Pau Escrich <pau@dabax.net>
|
||||
Contributors Lluis Esquerda <eskerda@gmail.com>
|
||||
Roger Pueyo Centelles <roger.pueyo@guifi.net>
|
||||
|
||||
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.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
The full GNU General Public License is included in this distribution in
|
||||
the file called "COPYING".
|
||||
-%>
|
||||
|
||||
<%+header%>
|
||||
<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
|
||||
<script type="text/javascript" src="<%=resource%>/bmx7/js/polling.js"></script>
|
||||
|
||||
|
||||
<style>
|
||||
|
||||
div.hideme{
|
||||
display: none;
|
||||
}
|
||||
|
||||
div.info{
|
||||
background: #FFF;
|
||||
border: solid 0px;
|
||||
height: 90px;
|
||||
display: block;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
div.inforow{
|
||||
text-align:left;
|
||||
display:inline-block;
|
||||
margin:10px;
|
||||
vertical-align:top;
|
||||
float: left;
|
||||
white-space:nowrap;
|
||||
}
|
||||
|
||||
div.inforow.newline{
|
||||
clear: both;
|
||||
}
|
||||
|
||||
u {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
#extra-info ul { list-style: none outside none; margin-left: 0em; }
|
||||
|
||||
</style>
|
||||
<div class="cbi-map">
|
||||
|
||||
<h2>Mesh nodes</h2>
|
||||
<div class="cbi-map-descr"></div>
|
||||
<div id="extra-info" class="info">
|
||||
<br />
|
||||
<center>
|
||||
Tip: click the <img src="<%=resource%>/bmx7/world.png" /> icon to see individual node information.
|
||||
</center>
|
||||
</div>
|
||||
<fieldset class="cbi-section">
|
||||
<legend><%:Originators%></legend>
|
||||
<table class="cbi-section-table" id="descriptions_table">
|
||||
<tr class="cbi-section-table-titles">
|
||||
<th class="cbi-section-table-cell"></th>
|
||||
<th class="cbi-section-table-cell"><%:Name%></th>
|
||||
<th class="cbi-section-table-cell"><%:Short ID%></th>
|
||||
<th class="cbi-section-table-cell"><%:S/s/T/t%></th>
|
||||
<th class="cbi-section-table-cell"><%:Primary IPv6 address%></th>
|
||||
<th class="cbi-section-table-cell"><%:Via neighbour%></th>
|
||||
<th class="cbi-section-table-cell"><%:Metric%></th>
|
||||
<th class="cbi-section-table-cell"><%:Last desc.%></th>
|
||||
<th class="cbi-section-table-cell"><%:Last ref.%></th>
|
||||
<th class="cbi-section-table-cell"><%: %></th>
|
||||
</tr>
|
||||
<tr class="cbi-section-table-row">
|
||||
<td colspan="11"><br /><center><em><%:Collecting data...%></em></center></td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
var displayExtraInfo = function ( id ) {
|
||||
console.log('aaa'+id)
|
||||
document.getElementById('extra-info').innerHTML = document.getElementById(id).innerHTML;
|
||||
}
|
||||
|
||||
new TablePooler(5,"/cgi-bin/bmx7-info", {'$originators':''}, "descriptions_table", function(st){
|
||||
var infoicon = "<%=resource%>/bmx7/world_small.png";
|
||||
var originators = st.originators;
|
||||
var res = Array();
|
||||
|
||||
originators.forEach(function(originator,i){
|
||||
var name = originator.name;
|
||||
var shortId = originator.shortId;
|
||||
var nodeId = originator.nodeId;
|
||||
var extensions = originator.name;
|
||||
var SsTt = originator.S+'/'+originator.s+'/'+originator.T+'/'+originator.t;
|
||||
var nodeKey = originator.nodeKey;
|
||||
var descSize = originator.descSize;
|
||||
var primaryIp = originator.primaryIp;
|
||||
var nbName = originator.nbName;
|
||||
var dev = originator.dev;
|
||||
var nbLocalIp = originator.nbLocalIp;
|
||||
var metric = originator.metric;
|
||||
var lastDesc = originator.lastDesc;
|
||||
var lastRef = originator.lastRef;
|
||||
|
||||
var extrainfo = '<a onclick="displayExtraInfo(\'ip-' + i + '\')"><img src="' + infoicon + '" / ></a>';
|
||||
var extrainfo_link = '<a onclick="displayExtraInfo(\'ip-' + i + '\')">' + '<img src="' + infoicon + '" />' + '</a>';
|
||||
|
||||
extrainfo = '<div id="ip-'+ i +'" class="hideme">'
|
||||
|
||||
+ "<div class='inforow'>"
|
||||
+ "<h4><u>" + name + '</u></h4>\n'
|
||||
+ 'Node ID: ' + nodeId + "</div>"
|
||||
|
||||
+ "<div class='inforow'>"
|
||||
+ "<h5>Primary IPv6 address</h5>\n"
|
||||
+ primaryIp + "</div>\n"
|
||||
|
||||
+ "<div class='inforow'>"
|
||||
+ "<h5>Support & Trust</h5>\n"
|
||||
+ SsTt + "</div>\n"
|
||||
|
||||
+ "<div class='inforow'>"
|
||||
+ "<h5>Node key</h5>\n"
|
||||
+ nodeKey + "</div>\n"
|
||||
|
||||
+ "<div class='inforow newline'>"
|
||||
+ "<h5>Via neighbour</h5>\n"
|
||||
+ nbName + "</div>\n"
|
||||
|
||||
+ "<div class='inforow'>"
|
||||
+ "<h5>Via device</h5>\n"
|
||||
+ dev + "</div>\n"
|
||||
|
||||
+ "<div class='inforow'>"
|
||||
+ "<h5>Via remote link-local IPv6 address</h5>\n"
|
||||
+ nbLocalIp + "</div>\n"
|
||||
|
||||
+ "<div class='inforow'>"
|
||||
+ "<h5>Route metric</h5>\n"
|
||||
+ metric + "</div>\n"
|
||||
|
||||
+ "<div class='inforow'>"
|
||||
+ "<h5>Desc. size</h5>\n"
|
||||
+ descSize + "</div>\n"
|
||||
|
||||
+ "\n</div>";
|
||||
|
||||
res.push([extrainfo_link, name, shortId, SsTt, primaryIp,
|
||||
nbName, metric, lastDesc, lastRef, extrainfo]);
|
||||
|
||||
});
|
||||
return res;
|
||||
});
|
||||
//]]></script>
|
||||
|
||||
<%+footer%>
|
||||
|
182
luci-app-bmx7/files/usr/lib/lua/luci/view/bmx7/status_j.htm
Normal file
182
luci-app-bmx7/files/usr/lib/lua/luci/view/bmx7/status_j.htm
Normal file
|
@ -0,0 +1,182 @@
|
|||
<%+header%>
|
||||
<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
|
||||
<script type="text/javascript" src="<%=resource%>/bmx7/js/polling.js"></script>
|
||||
|
||||
<style>
|
||||
div.hideme{
|
||||
display: none;
|
||||
}
|
||||
|
||||
div.info{
|
||||
background: #FFF;
|
||||
border: solid 1px;
|
||||
height: 80px;
|
||||
display: block;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
div.inforow{
|
||||
text-align:left;
|
||||
display:inline-block;
|
||||
width:20%;
|
||||
margin:5px;
|
||||
vertical-align:top;
|
||||
}
|
||||
|
||||
#extra-info ul { list-style: none outside none; margin-left: 0em; }
|
||||
</style>
|
||||
|
||||
<div class="cbi-map">
|
||||
<center>
|
||||
<img src="<%=resource%>/bmx7/bmx7logo.png" />
|
||||
<br />
|
||||
<br />
|
||||
A mesh routing protocol for Linux devices.<br />
|
||||
Visit <a href="http://bmx6.net">bmx6.net</a> for more information.<br />
|
||||
<br />
|
||||
</center>
|
||||
|
||||
<div class="cbi-map-descr"></div>
|
||||
|
||||
<fieldset class="cbi-section">
|
||||
<legend><%:Node configuration%></legend>
|
||||
<table class="cbi-section-table" id="config_table">
|
||||
<tr class="cbi-section-table-titles">
|
||||
<th class="cbi-section-table-cell"><%:Short ID%></th>
|
||||
<th class="cbi-section-table-cell"><%:Node name%></th>
|
||||
<th class="cbi-section-table-cell"><%:Primary IPv6 address%></th>
|
||||
<th class="cbi-section-table-cell"><%:Node key%></th>
|
||||
<th class="cbi-section-table-cell"><%:BMX7 revision%></th>
|
||||
</tr>
|
||||
<tr class="cbi-section-table-row">
|
||||
<td colspan="5"><em><br /><%:Collecting data...%></em></td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="cbi-section">
|
||||
<legend><%:Node status%></legend>
|
||||
<table class="cbi-section-table" id="status_table">
|
||||
<tr class="cbi-section-table-titles">
|
||||
<th class="cbi-section-table-cell"><%:Nodes seen%></th>
|
||||
<th class="cbi-section-table-cell"><%:Neighbours%></th>
|
||||
<th class="cbi-section-table-cell"><%:Tunnelled IPv6 address%></th>
|
||||
<th class="cbi-section-table-cell"><%:Tunnelled IPv4 address%></th>
|
||||
<th class="cbi-section-table-cell"><%:Uptime%></th>
|
||||
<th class="cbi-section-table-cell"><%:CPU usage%></th>
|
||||
<th class="cbi-section-table-cell"><%:Memory usage%></th>
|
||||
<th class="cbi-section-table-cell"><%:Tx queue%></th>
|
||||
|
||||
</tr>
|
||||
<tr class="cbi-section-table-row">
|
||||
<td colspan="8"><em><br /><%:Collecting data...%></em></td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="cbi-section">
|
||||
<legend><%:Interfaces%></legend>
|
||||
<table class="cbi-section-table" id="ifaces_table">
|
||||
<tr class="cbi-section-table-titles">
|
||||
<th class="cbi-section-table-cell"><%:Interface%></th>
|
||||
<th class="cbi-section-table-cell"><%:State%></th>
|
||||
<th class="cbi-section-table-cell"><%:Type%></th>
|
||||
<th class="cbi-section-table-cell"><%:Max. rate%></th>
|
||||
<th class="cbi-section-table-cell"><%:Link-local IPv6 address%></th>
|
||||
<th class="cbi-section-table-cell"><%:Rx BpP%></th>
|
||||
<th class="cbi-section-table-cell"><%:Tx BpP%></th>
|
||||
|
||||
</tr>
|
||||
<tr class="cbi-section-table-row">
|
||||
<td colspan="7"><em><br /><%:Collecting data...%></em></td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="cbi-section">
|
||||
<legend><%:Links%></legend>
|
||||
<table class="cbi-section-table" id="links_table">
|
||||
<tr class="cbi-section-table-titles">
|
||||
<th class="cbi-section-table-cell"><%:Short ID%></th>
|
||||
<th class="cbi-section-table-cell"><%:Name%></th>
|
||||
<th class="cbi-section-table-cell"><%:Link key%></th>
|
||||
<th class="cbi-section-table-cell"><%:Remote link-local IPv6 address%></th>
|
||||
<th class="cbi-section-table-cell"><%:Device%></th>
|
||||
<th class="cbi-section-table-cell"><%:Rx rate%></th>
|
||||
<th class="cbi-section-table-cell"><%:Tx rate%></th>
|
||||
<th class="cbi-section-table-cell"><%:Routes%></th>
|
||||
|
||||
</tr>
|
||||
<tr class="cbi-section-table-row">
|
||||
<td colspan="8"><em><br /><%:Collecting data...%></em></td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
new TablePooler(1,"/cgi-bin/bmx7-info", {'$info':''}, "config_table", function(st){
|
||||
var res = Array();
|
||||
var sta = st.info[0].status;
|
||||
var ifaces = st.info[1].interfaces;
|
||||
|
||||
res.push([sta.shortId, sta.name, sta.primaryIp, sta.nodeKey, sta.revision]);
|
||||
res.push(['','','','',''])
|
||||
res.push(['','','','',''])
|
||||
|
||||
return res;
|
||||
});
|
||||
|
||||
|
||||
new TablePooler(1,"/cgi-bin/bmx7-info", {'$info':''}, "status_table", function(st){
|
||||
var res = Array();
|
||||
var sta = st.info[0].status;
|
||||
var mem = st.info[3].memory;
|
||||
|
||||
var txQ = sta.txQ.split('/');
|
||||
console.log(txQ)
|
||||
|
||||
var ptxQ = '<p style="color:rgb('+parseInt(255*txQ[0]/txQ[1])+','+parseInt(128*(txQ[1]-txQ[0])/txQ[1])+',0)")>'+sta.txQ+'</p>';
|
||||
console.log(ptxQ)
|
||||
|
||||
res.push([sta.nodes, sta.nbs, sta.tun6Address, sta.tun4Address, sta.uptime, sta.cpu, mem.bmx7, ptxQ]);
|
||||
|
||||
res.push(['','','','','','','',''])
|
||||
res.push(['','','','','','','',''])
|
||||
|
||||
return res;
|
||||
});
|
||||
|
||||
new TablePooler(1,"/cgi-bin/bmx7-info", {'$info':''}, "ifaces_table", function(st){
|
||||
var res = Array();
|
||||
var sta = st.info[0].status;
|
||||
var ifaces = st.info[1].interfaces;
|
||||
|
||||
ifaces.forEach(function(iface){
|
||||
res.push([iface.dev, iface.state, iface.type, iface.rateMax, iface.localIp, iface.rxBpP, iface.txBpP]);
|
||||
});
|
||||
res.push(['','','','','','',''])
|
||||
if (ifaces.length % 2 == 0)
|
||||
res.push('')
|
||||
res.push(['','','','','','',''])
|
||||
return res;
|
||||
});
|
||||
|
||||
new TablePooler(1,"/cgi-bin/bmx7-info", {'links':''}, "links_table", function(st){
|
||||
var res = Array();
|
||||
links = st.links;
|
||||
|
||||
links.forEach(function(link){
|
||||
res.push([link.shortId, link.name, link.linkKey, link.nbLocalIp, link.dev, link.rxRate, link.txRate, link.routes]);
|
||||
});
|
||||
res.push(['','','','','','','',''])
|
||||
if (links.length % 2 == 0)
|
||||
res.push([])
|
||||
res.push(['','','','','','','',''])
|
||||
return res;
|
||||
});
|
||||
//]]></script>
|
||||
|
||||
<%+footer%>
|
136
luci-app-bmx7/files/www/cgi-bin/bmx7-info
Executable file
136
luci-app-bmx7/files/www/cgi-bin/bmx7-info
Executable file
|
@ -0,0 +1,136 @@
|
|||
#!/bin/sh
|
||||
# Copyright © 2011 Pau Escrich
|
||||
# Contributors Jo-Philipp Wich <xm@subsignal.org>
|
||||
# Roger Pueyo Centelles <roger.pueyo@guifi.net>
|
||||
#
|
||||
# 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.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# The full GNU General Public License is included in this distribution in
|
||||
# the file called "COPYING".
|
||||
#
|
||||
# This script gives information about bmx7
|
||||
# Can be executed from a linux shell: ./bmx7-info -s links
|
||||
# Or from web interfae (with cgi enabled): http://host/cgi-bin/bmx7-info?links
|
||||
# If you ask for a directory you wil get the directory contents in JSON forman
|
||||
|
||||
BMX7_DIR="$(uci get bmx7.general.runtimeDir 2>/dev/null)" || BMX7_DIR="/var/run/bmx7/json"
|
||||
|
||||
#Checking if shell mode or cgi-bin mode
|
||||
if [ "$1" == "-s" ]; then
|
||||
QUERY="$2"
|
||||
else
|
||||
QUERY="${QUERY_STRING%%=*}"
|
||||
echo "Content-type: application/json"
|
||||
echo ""
|
||||
|
||||
fi
|
||||
|
||||
check_path() {
|
||||
[ -d "$1" ] && path=$(cd $1; pwd)
|
||||
[ -f "$1" ] && path=$(cd $1/..; pwd)
|
||||
[ $(echo "$path" | grep -c "^$BMX7_DIR") -ne 1 ] && exit 1
|
||||
}
|
||||
|
||||
print_mem() {
|
||||
echo -n '{ "memory": { "bmx7": "'
|
||||
cat /proc/$(cat /var/run/bmx7/pid)/status |grep -i VmSize | tr -s " " | cut -d " " -f 2,3 | tr -d "\n"
|
||||
echo '"}}'
|
||||
}
|
||||
|
||||
print_query() {
|
||||
# If the query is a directory
|
||||
[ -d "$BMX7_DIR/$1" ] &&
|
||||
{
|
||||
# If /all has not been specified
|
||||
[ -z "$QALL" ] &&
|
||||
{
|
||||
total=$(ls $BMX7_DIR/$1 | wc -w)
|
||||
i=1
|
||||
echo -n "{ \"$1\": [ "
|
||||
for f in $(ls $BMX7_DIR/$1); do
|
||||
echo -n "{ \"name\": \"$f\" }"
|
||||
[ $i -lt $total ] && echo -n ','
|
||||
i=$(( $i + 1 ))
|
||||
done
|
||||
echo -n " ] }"
|
||||
|
||||
# If /all has been specified, printing all the files together
|
||||
} || {
|
||||
comma=""
|
||||
echo -n "[ "
|
||||
for entry in "$BMX7_DIR/$1/"*; do
|
||||
[ -f "$entry" ] &&
|
||||
{
|
||||
${comma:+echo "$comma"}
|
||||
tr -d '\n' < "$entry"
|
||||
comma=","
|
||||
}
|
||||
done
|
||||
echo -n " ]"
|
||||
}
|
||||
}
|
||||
|
||||
# If the query is a file, just printing the file
|
||||
[ -f "$BMX7_DIR/$1" ] && cat "$BMX7_DIR/$1";
|
||||
}
|
||||
|
||||
if [ "${QUERY##*/}" == "all" ]; then
|
||||
QUERY="${QUERY%/all}"
|
||||
QALL=1
|
||||
fi
|
||||
|
||||
if [ "$QUERY" == '$info' ]; then
|
||||
echo '{ "info": [ '
|
||||
print_query status
|
||||
echo -n ","
|
||||
print_query interfaces
|
||||
echo -n ","
|
||||
print_query links
|
||||
echo -n ","
|
||||
print_mem
|
||||
echo "] }"
|
||||
fi
|
||||
|
||||
if [ "$QUERY" == '$neighbours' ]; then
|
||||
QALL=1
|
||||
echo '{ "neighbours": [ '
|
||||
echo '{ "originators": '
|
||||
print_query originators
|
||||
echo '}, '
|
||||
echo '{ "descriptions": '
|
||||
print_query descriptions
|
||||
echo "} ] }"
|
||||
exit 0
|
||||
|
||||
else if [ "$QUERY" == '$tunnels' ]; then
|
||||
bmx7 -c --jshow tunnels /r=0
|
||||
exit 0
|
||||
|
||||
else if [ "$QUERY" == '$originators' ]; then
|
||||
bmx7 -c --jshow originators /r=0
|
||||
exit 0
|
||||
|
||||
else
|
||||
check_path "$BMX7_DIR/$QUERY"
|
||||
print_query $QUERY
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
ls -1F "$BMX7_DIR"
|
||||
exit 0
|
||||
|
BIN
luci-app-bmx7/files/www/luci-static/resources/bmx7/bmx7logo.png
Normal file
BIN
luci-app-bmx7/files/www/luci-static/resources/bmx7/bmx7logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5 KiB |
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
Copyright © 2011 Pau Escrich <pau@dabax.net>
|
||||
Contributors Lluis Esquerda <eskerda@gmail.com>
|
||||
|
||||
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.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
The full GNU General Public License is included in this distribution in
|
||||
the file called "COPYING".
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
Table pooler is a function to easy call XHR poller.
|
||||
|
||||
new TablePooler(5,"/cgi-bin/bmx7-info", {'status':''}, "status_table", function(st){
|
||||
var table = Array()
|
||||
table.push(st.first,st.second)
|
||||
return table
|
||||
}
|
||||
|
||||
The parameters are:
|
||||
polling_time: time between pollings
|
||||
json_url: the json url to fetch the data
|
||||
json_call: the json call
|
||||
output_table_id: the table where javascript will put the data
|
||||
callback_function: the function that will be executed each polling_time
|
||||
|
||||
The callback_function must return an array of arrays (matrix).
|
||||
In the code st is the data obtained from the json call
|
||||
*/
|
||||
|
||||
function TablePooler (time, jsonurl, getparams, table_id, callback) {
|
||||
this.table = document.getElementById(table_id);
|
||||
this.callback = callback;
|
||||
this.jsonurl = jsonurl;
|
||||
this.getparams = getparams;
|
||||
this.time = time;
|
||||
|
||||
/* clear all rows */
|
||||
this.clear = function(){
|
||||
while( this.table.rows.length > 1 ) this.table.deleteRow(1);
|
||||
}
|
||||
|
||||
this.start = function(){
|
||||
XHR.poll(this.time, this.jsonurl, this.getparams, function(x, st){
|
||||
var data = this.callback(st);
|
||||
var content, tr, td;
|
||||
this.clear();
|
||||
for (var i = 0; i < data.length; i++){
|
||||
tr = this.table.insertRow(-1);
|
||||
tr.className = 'cbi-section-table-row cbi-rowstyle-' + ((i % 2) + 1);
|
||||
|
||||
for (var j = 0; j < data[i].length; j++){
|
||||
td = tr.insertCell(-1);
|
||||
if (data[i][j].length == 2) {
|
||||
td.colSpan = data[i][j][1];
|
||||
content = data[i][j][0];
|
||||
}
|
||||
else content = data[i][j];
|
||||
td.innerHTML = content;
|
||||
}
|
||||
}
|
||||
}.bind(this));
|
||||
}
|
||||
|
||||
|
||||
this.start();
|
||||
}
|
BIN
luci-app-bmx7/files/www/luci-static/resources/bmx7/world.png
Normal file
BIN
luci-app-bmx7/files/www/luci-static/resources/bmx7/world.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
Binary file not shown.
After Width: | Height: | Size: 923 B |
54
luci-app-cjdns/Makefile
Normal file
54
luci-app-cjdns/Makefile
Normal file
|
@ -0,0 +1,54 @@
|
|||
#
|
||||
# Copyright (C) 2014,2015 Hyperboria.net
|
||||
#
|
||||
# You may redistribute this program and/or modify it under the terms of
|
||||
# the GNU General Public License as published by the Free Software Foundation,
|
||||
# either version 3 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, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-cjdns
|
||||
PKG_VERSION:=1.3
|
||||
PKG_RELEASE:=5
|
||||
|
||||
PKG_LICENSE:=GPL-3.0
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/luci-app-cjdns
|
||||
SECTION:=luci
|
||||
CATEGORY:=LuCI
|
||||
SUBMENU:=3. Applications
|
||||
TITLE:=Encrypted near-zero-conf mesh routing protocol
|
||||
URL:=https://github.com/hyperboria/cjdns
|
||||
MAINTAINER:=Lars Gierth <larsg@systemli.org>
|
||||
DEPENDS:=+cjdns +luci-base
|
||||
endef
|
||||
|
||||
define Package/luci-app-cjdns/description
|
||||
This package allows you to configure and inspect cjdns networking using LuCI.
|
||||
|
||||
Cjdns implements an encrypted IPv6 network using public-key cryptography
|
||||
for address allocation and a distributed hash table for routing.
|
||||
This provides near-zero-configuration networking, and prevents many
|
||||
of the security and scalability issues that plague existing networks.
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
define Package/luci-app-cjdns/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib/lua/luci
|
||||
$(CP) ./luasrc/* $(1)/usr/lib/lua/luci
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,luci-app-cjdns))
|
105
luci-app-cjdns/luasrc/controller/cjdns.lua
Normal file
105
luci-app-cjdns/luasrc/controller/cjdns.lua
Normal file
|
@ -0,0 +1,105 @@
|
|||
module("luci.controller.cjdns", package.seeall)
|
||||
|
||||
cjdns = require "cjdns/init"
|
||||
dkjson = require "dkjson"
|
||||
|
||||
function index()
|
||||
if not nixio.fs.access("/etc/config/cjdns") then
|
||||
return
|
||||
end
|
||||
|
||||
entry({"admin", "services", "cjdns"},
|
||||
cbi("cjdns/overview"), _("cjdns")).dependent = true
|
||||
|
||||
entry({"admin", "services", "cjdns", "overview"},
|
||||
cbi("cjdns/overview"), _("Overview"), 1).leaf = false
|
||||
|
||||
entry({"admin", "services", "cjdns", "peering"},
|
||||
cbi("cjdns/peering"), _("Peers"), 2).leaf = false
|
||||
|
||||
entry({"admin", "services", "cjdns", "iptunnel"},
|
||||
cbi("cjdns/iptunnel"), _("IP Tunnel"), 3).leaf = false
|
||||
|
||||
entry({"admin", "services", "cjdns", "settings"},
|
||||
cbi("cjdns/settings"), _("Settings"), 4).leaf = false
|
||||
|
||||
entry({"admin", "services", "cjdns", "cjdrouteconf"},
|
||||
cbi("cjdns/cjdrouteconf"), _("cjdroute.conf"), 5).leaf = false
|
||||
|
||||
entry({"admin", "services", "cjdns", "peers"}, call("act_peers")).leaf = true
|
||||
entry({"admin", "services", "cjdns", "ping"}, call("act_ping")).leaf = true
|
||||
end
|
||||
|
||||
function act_peers()
|
||||
require("cjdns/uci")
|
||||
admin = cjdns.uci.makeInterface()
|
||||
|
||||
local page = 0
|
||||
local peers = {}
|
||||
|
||||
while page do
|
||||
local response, err = admin:auth({
|
||||
q = "InterfaceController_peerStats",
|
||||
page = page
|
||||
})
|
||||
|
||||
if err or response.error then
|
||||
luci.http.status(502, "Bad Gateway")
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json({ err = err, response = response })
|
||||
return
|
||||
end
|
||||
|
||||
for i,peer in pairs(response.peers) do
|
||||
peer.ipv6 = publictoip6(peer.publicKey)
|
||||
if peer.user == nil then
|
||||
peer.user = ''
|
||||
uci.cursor():foreach("cjdns", "udp_peer", function(udp_peer)
|
||||
if peer.publicKey == udp_peer.public_key then
|
||||
peer.user = udp_peer.user
|
||||
end
|
||||
end)
|
||||
end
|
||||
peers[#peers + 1] = peer
|
||||
end
|
||||
|
||||
if response.more then
|
||||
page = page + 1
|
||||
else
|
||||
page = nil
|
||||
end
|
||||
end
|
||||
|
||||
luci.http.status(200, "OK")
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(peers)
|
||||
end
|
||||
|
||||
function act_ping()
|
||||
require("cjdns/uci")
|
||||
admin = cjdns.uci.makeInterface()
|
||||
|
||||
local response, err = admin:auth({
|
||||
q = "SwitchPinger_ping",
|
||||
path = luci.http.formvalue("label"),
|
||||
timeout = tonumber(luci.http.formvalue("timeout"))
|
||||
})
|
||||
|
||||
if err or response.error then
|
||||
luci.http.status(502, "Bad Gateway")
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json({ err = err, response = response })
|
||||
return
|
||||
end
|
||||
|
||||
luci.http.status(200, "OK")
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(response)
|
||||
end
|
||||
|
||||
function publictoip6(publicKey)
|
||||
local process = io.popen("/usr/bin/publictoip6 " .. publicKey, "r")
|
||||
local ipv6 = process:read()
|
||||
process:close()
|
||||
return ipv6
|
||||
end
|
32
luci-app-cjdns/luasrc/model/cbi/cjdns/cjdrouteconf.lua
Normal file
32
luci-app-cjdns/luasrc/model/cbi/cjdns/cjdrouteconf.lua
Normal file
|
@ -0,0 +1,32 @@
|
|||
m = Map("cjdns", translate("cjdns"),
|
||||
translate("Implements an encrypted IPv6 network using public-key \
|
||||
cryptography for address allocation and a distributed hash table for \
|
||||
routing. This provides near-zero-configuration networking, and prevents \
|
||||
many of the security and scalability issues that plague existing \
|
||||
networks."))
|
||||
|
||||
dkjson = require("dkjson")
|
||||
cjdns = require("cjdns")
|
||||
require("cjdns/uci")
|
||||
|
||||
local f = SimpleForm("cjdrouteconf", translate("Edit cjdroute.conf"),
|
||||
translate("JSON interface to what's /etc/cjdroute.conf on other systems. \
|
||||
Will be parsed and written to UCI by <code>cjdrouteconf set</code>."))
|
||||
|
||||
local o = f:field(Value, "_cjdrouteconf")
|
||||
o.template = "cbi/tvalue"
|
||||
o.rows = 25
|
||||
|
||||
function o.cfgvalue(self, section)
|
||||
return dkjson.encode(cjdns.uci.get(), { indent = true })
|
||||
end
|
||||
|
||||
function o.write(self, section, value)
|
||||
local obj, pos, err = dkjson.decode(value, 1, nil)
|
||||
|
||||
if obj then
|
||||
cjdns.uci.set(obj)
|
||||
end
|
||||
end
|
||||
|
||||
return f
|
46
luci-app-cjdns/luasrc/model/cbi/cjdns/iptunnel.lua
Normal file
46
luci-app-cjdns/luasrc/model/cbi/cjdns/iptunnel.lua
Normal file
|
@ -0,0 +1,46 @@
|
|||
uci = require "luci.model.uci"
|
||||
cursor = uci:cursor_state()
|
||||
|
||||
m = Map("cjdns", translate("cjdns"),
|
||||
translate("Implements an encrypted IPv6 network using public-key \
|
||||
cryptography for address allocation and a distributed hash table for \
|
||||
routing. This provides near-zero-configuration networking, and prevents \
|
||||
many of the security and scalability issues that plague existing \
|
||||
networks."))
|
||||
|
||||
m.on_after_commit = function(self)
|
||||
os.execute("/etc/init.d/cjdns restart")
|
||||
end
|
||||
|
||||
-- Outgoing
|
||||
outgoing = m:section(TypedSection, "iptunnel_outgoing", translate("Outgoing IP Tunnel Connections"),
|
||||
translate("Enter the public keys of the nodes that will provide Internet access."))
|
||||
outgoing.anonymous = true
|
||||
outgoing.addremove = true
|
||||
outgoing.template = "cbi/tblsection"
|
||||
|
||||
outgoing:option(Value, "public_key", translate("Public Key")).size = 55
|
||||
|
||||
-- Allowed
|
||||
allowed = m:section(TypedSection, "iptunnel_allowed", translate("Allowed IP Tunnel Connections"),
|
||||
translate("Enter the public key of the node you will provide Internet access to, along with the \
|
||||
IPv4 and/or IPv6 address you will assign them."))
|
||||
allowed.anonymous = true
|
||||
allowed.addremove = true
|
||||
|
||||
public_key = allowed:option(Value, "public_key", translate("Public Key"))
|
||||
public_key.template = "cjdns/value"
|
||||
public_key.size = 55
|
||||
|
||||
ipv4 = allowed:option(Value, "ipv4", translate("IPv4"))
|
||||
ipv4.template = "cjdns/value"
|
||||
ipv4.datatype = 'ipaddr'
|
||||
ipv4.size = 55
|
||||
|
||||
ipv6 = allowed:option(Value, "ipv6", translate("IPv6"),
|
||||
translate("IPv6 addresses should be entered <em>without</em> brackets here, e.g. <code>2001:123:ab::10</code>."))
|
||||
ipv6.template = "cjdns/value"
|
||||
ipv6.datatype = 'ip6addr'
|
||||
ipv6.size = 55
|
||||
|
||||
return m
|
10
luci-app-cjdns/luasrc/model/cbi/cjdns/overview.lua
Normal file
10
luci-app-cjdns/luasrc/model/cbi/cjdns/overview.lua
Normal file
|
@ -0,0 +1,10 @@
|
|||
m = Map("cjdns", translate("cjdns"),
|
||||
translate("Implements an encrypted IPv6 network using public-key \
|
||||
cryptography for address allocation and a distributed hash table for \
|
||||
routing. This provides near-zero-configuration networking, and prevents \
|
||||
many of the security and scalability issues that plague existing \
|
||||
networks."))
|
||||
|
||||
m:section(SimpleSection).template = "cjdns/status"
|
||||
|
||||
return m
|
73
luci-app-cjdns/luasrc/model/cbi/cjdns/peering.lua
Normal file
73
luci-app-cjdns/luasrc/model/cbi/cjdns/peering.lua
Normal file
|
@ -0,0 +1,73 @@
|
|||
uci = require "luci.model.uci"
|
||||
cursor = uci:cursor_state()
|
||||
|
||||
cjdns = require("cjdns")
|
||||
require("cjdns/uci")
|
||||
|
||||
m = Map("cjdns", translate("cjdns"),
|
||||
translate("Implements an encrypted IPv6 network using public-key \
|
||||
cryptography for address allocation and a distributed hash table for \
|
||||
routing. This provides near-zero-configuration networking, and prevents \
|
||||
many of the security and scalability issues that plague existing \
|
||||
networks."))
|
||||
|
||||
m.on_after_commit = function(self)
|
||||
os.execute("/etc/init.d/cjdns restart")
|
||||
end
|
||||
|
||||
-- Authorized Passwords
|
||||
passwords = m:section(TypedSection, "password", translate("Authorized Passwords"),
|
||||
translate("Anyone offering one of the these passwords will be allowed to peer with you on the existing UDP and Ethernet interfaces."))
|
||||
passwords.anonymous = true
|
||||
passwords.addremove = true
|
||||
passwords.template = "cbi/tblsection"
|
||||
|
||||
passwords:option(Value, "user", translate("User/Name"),
|
||||
translate("Must be unique.")
|
||||
).default = "user-" .. cjdns.uci.random_string(6)
|
||||
passwords:option(Value, "contact", translate("Contact"), translate("Optional, for out-of-band communication."))
|
||||
passwords:option(Value, "password", translate("Password"),
|
||||
translate("Hand out to your peer, in accordance with the peering best practices of the network.")
|
||||
).default = cjdns.uci.random_string(32)
|
||||
|
||||
-- UDP Peers
|
||||
udp_peers = m:section(TypedSection, "udp_peer", translate("Outgoing UDP Peers"),
|
||||
translate("For peering via public IP networks, the peer handed you their Public Key and IP address/port along with a password. IPv6 addresses should be entered with square brackets, like so: <code>[2001::1]</code>."))
|
||||
udp_peers.anonymous = true
|
||||
udp_peers.addremove = true
|
||||
udp_peers.template = "cbi/tblsection"
|
||||
udp_peers:option(Value, "user", translate("User/Name")).datatype = "string"
|
||||
|
||||
udp_interface = udp_peers:option(Value, "interface", translate("UDP interface"))
|
||||
local index = 1
|
||||
for i,section in pairs(cursor:get_all("cjdns")) do
|
||||
if section[".type"] == "udp_interface" then
|
||||
udp_interface:value(index, section.address .. ":" .. section.port)
|
||||
end
|
||||
end
|
||||
udp_interface.default = 1
|
||||
udp_peers:option(Value, "address", translate("IP address"))
|
||||
udp_peers:option(Value, "port", translate("Port")).datatype = "portrange"
|
||||
udp_peers:option(Value, "public_key", translate("Public key"))
|
||||
udp_peers:option(Value, "password", translate("Password"))
|
||||
|
||||
-- Ethernet Peers
|
||||
eth_peers = m:section(TypedSection, "eth_peer", translate("Outgoing Ethernet Peers"),
|
||||
translate("For peering via local Ethernet networks, the peer handed you their Public Key and MAC address along with a password."))
|
||||
eth_peers.anonymous = true
|
||||
eth_peers.addremove = true
|
||||
eth_peers.template = "cbi/tblsection"
|
||||
|
||||
eth_interface = eth_peers:option(Value, "interface", translate("Ethernet interface"))
|
||||
local index = 1
|
||||
for i,section in pairs(cursor:get_all("cjdns")) do
|
||||
if section[".type"] == "eth_interface" then
|
||||
eth_interface:value(index, section.bind)
|
||||
end
|
||||
end
|
||||
eth_interface.default = 1
|
||||
eth_peers:option(Value, "address", translate("MAC address")).datatype = "macaddr"
|
||||
eth_peers:option(Value, "public_key", translate("Public key"))
|
||||
eth_peers:option(Value, "password", translate("Password"))
|
||||
|
||||
return m
|
67
luci-app-cjdns/luasrc/model/cbi/cjdns/settings.lua
Normal file
67
luci-app-cjdns/luasrc/model/cbi/cjdns/settings.lua
Normal file
|
@ -0,0 +1,67 @@
|
|||
m = Map("cjdns", translate("cjdns"),
|
||||
translate("Implements an encrypted IPv6 network using public-key \
|
||||
cryptography for address allocation and a distributed hash table for \
|
||||
routing. This provides near-zero-configuration networking, and prevents \
|
||||
many of the security and scalability issues that plague existing \
|
||||
networks."))
|
||||
|
||||
m.on_after_commit = function(self)
|
||||
os.execute("/etc/init.d/cjdns restart")
|
||||
end
|
||||
|
||||
s = m:section(NamedSection, "cjdns", nil, translate("Settings"))
|
||||
s.addremove = false
|
||||
|
||||
-- Identity
|
||||
s:tab("identity", translate("Identity"))
|
||||
node6 = s:taboption("identity", Value, "ipv6", translate("IPv6 address"),
|
||||
translate("This node's IPv6 address within the cjdns network."))
|
||||
node6.datatype = "ip6addr"
|
||||
pbkey = s:taboption("identity", Value, "public_key", translate("Public key"),
|
||||
translate("Used for packet encryption and authentication."))
|
||||
pbkey.datatype = "string"
|
||||
prkey = s:taboption("identity", Value, "private_key", translate("Private key"),
|
||||
translate("Keep this private. When compromised, generate a new keypair and IPv6."))
|
||||
prkey.datatype = "string"
|
||||
|
||||
-- Admin Interface
|
||||
s:tab("admin", translate("Admin API"), translate("The Admin API can be used by other applications or services to configure and inspect cjdns' routing and peering.<br/><br/>Documentation: <a href=\"https://github.com/cjdelisle/cjdns/tree/master/admin#cjdns-admin-api\">admin/README.md</a>"))
|
||||
aip = s:taboption("admin", Value, "admin_address", translate("IP Address"),
|
||||
translate("IPv6 addresses should be entered like so: <code>[2001::1]</code>."))
|
||||
apt = s:taboption("admin", Value, "admin_port", translate("Port"))
|
||||
apt.datatype = "port"
|
||||
apw = s:taboption("admin", Value, "admin_password", translate("Password"))
|
||||
apw.datatype = "string"
|
||||
|
||||
-- Security
|
||||
s:tab("security", translate("Security"), translate("Functionality related to hardening the cjdroute process."))
|
||||
s:taboption("security", Flag, "seccomp", translate("SecComp sandboxing"))
|
||||
|
||||
-- UDP Interfaces
|
||||
udp_interfaces = m:section(TypedSection, "udp_interface", translate("UDP Interfaces"),
|
||||
translate("These interfaces allow peering via public IP networks, such as the Internet, or many community-operated wireless networks. IPv6 addresses should be entered with square brackets, like so: <code>[2001::1]</code>."))
|
||||
udp_interfaces.anonymous = true
|
||||
udp_interfaces.addremove = true
|
||||
udp_interfaces.template = "cbi/tblsection"
|
||||
|
||||
udp_address = udp_interfaces:option(Value, "address", translate("IP Address"))
|
||||
udp_address.placeholder = "0.0.0.0"
|
||||
udp_interfaces:option(Value, "port", translate("Port")).datatype = "portrange"
|
||||
|
||||
-- Ethernet Interfaces
|
||||
eth_interfaces = m:section(TypedSection, "eth_interface", translate("Ethernet Interfaces"),
|
||||
translate("These interfaces allow peering via local Ethernet networks, such as home or office networks, or phone tethering. If an interface name is set to \"all\" each available device will be used."))
|
||||
eth_interfaces.anonymous = true
|
||||
eth_interfaces.addremove = true
|
||||
eth_interfaces.template = "cbi/tblsection"
|
||||
|
||||
eth_bind = eth_interfaces:option(Value, "bind", translate("Network Interface"))
|
||||
eth_bind.placeholder = "br-lan"
|
||||
eth_beacon = eth_interfaces:option(Value, "beacon", translate("Beacon Mode"))
|
||||
eth_beacon:value(0, translate("0 -- Disabled"))
|
||||
eth_beacon:value(1, translate("1 -- Accept beacons"))
|
||||
eth_beacon:value(2, translate("2 -- Accept and send beacons"))
|
||||
eth_beacon.default = 2
|
||||
eth_beacon.datatype = "integer(range(0,2))"
|
||||
|
||||
return m
|
1
luci-app-cjdns/luasrc/view/admin_status/index/cjdns.htm
Normal file
1
luci-app-cjdns/luasrc/view/admin_status/index/cjdns.htm
Normal file
|
@ -0,0 +1 @@
|
|||
<%+cjdns/status%>
|
116
luci-app-cjdns/luasrc/view/cjdns/status.htm
Normal file
116
luci-app-cjdns/luasrc/view/cjdns/status.htm
Normal file
|
@ -0,0 +1,116 @@
|
|||
<script type="text/javascript">//<![CDATA[
|
||||
|
||||
var peersURI = '<%=luci.dispatcher.build_url("admin", "services", "cjdns", "peers")%>';
|
||||
var updatePeers = function(x, peers) {
|
||||
var table = document.getElementById('cjdns-peerings');
|
||||
while (table.rows.length > 1) {
|
||||
table.deleteRow(1);
|
||||
}
|
||||
|
||||
if ((peers) && ((peers.err) || (typeof peers.length === 'undefined'))) {
|
||||
var errpeer = (peers.err)
|
||||
? 'Socket Error: unable to connect to Admin API'
|
||||
: 'No active peers';
|
||||
var row = table.insertRow(-1);
|
||||
row.className = 'cbi-section-table-row';
|
||||
var cell = row.insertCell(-1);
|
||||
cell.colSpan = 7;
|
||||
cell.textContent = errpeer;
|
||||
return;
|
||||
};
|
||||
|
||||
peers.forEach(function(peer, i) {
|
||||
if (peer.user == null) {
|
||||
var user = '';
|
||||
} else if (peer.user == 'Local Peers') {
|
||||
var user = 'beacon';
|
||||
} else {
|
||||
var user = peer.user;
|
||||
}
|
||||
|
||||
if (peer.isIncoming === 0) {
|
||||
var interface = 'outgoing';
|
||||
} else {
|
||||
var interface = 'incoming';
|
||||
}
|
||||
|
||||
var status = interface + ', ' + peer.state.toLowerCase();
|
||||
|
||||
if (peer.version === 0) {
|
||||
var version = '-';
|
||||
} else {
|
||||
var version = 'v' + peer.version;
|
||||
}
|
||||
|
||||
var rxtx = lbbytes(peer.bytesIn) + ' / ' + lbbytes(peer.bytesOut);
|
||||
|
||||
var row = table.insertRow(-1);
|
||||
row.className = 'cbi-section-table-row cbi-rowstyle-' + ((i % 2) + 1);
|
||||
row.insertCell(-1).textContent = user;
|
||||
row.insertCell(-1).textContent = peer.ipv6;
|
||||
row.insertCell(-1).textContent = status;
|
||||
row.insertCell(-1).textContent = version;
|
||||
row.insertCell(-1).textContent = rxtx;
|
||||
var latencyCell = row.insertCell(-1);
|
||||
latencyCell.textContent = 'waiting';
|
||||
|
||||
var pingURI = '<%=luci.dispatcher.build_url("admin", "services", "cjdns", "ping")%>';
|
||||
var timeout = 2000;
|
||||
XHR.get(pingURI, { label: peer.switchLabel, timeout: timeout }, function(x, pong) {
|
||||
var pongrsp = ((pong.err == "ai:recv > timeout") || (pong == "undefined") || (pong.ms >= timeout))
|
||||
? '> ' + timeout + ' ms'
|
||||
: pong.ms + ' ms';
|
||||
latencyCell.textContent = pongrsp;
|
||||
})
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
XHR.get(peersURI, null, updatePeers);
|
||||
XHR.poll(5, peersURI, null, updatePeers);
|
||||
|
||||
//]]></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
<%# Author: [GitHub/75lb] -%>
|
||||
//<![CDATA[
|
||||
function lbbytes (bytes){
|
||||
|
||||
var kilobyte = 1024,
|
||||
megabyte = kilobyte * 1024,
|
||||
gigabyte = megabyte * 1024,
|
||||
terabyte = gigabyte * 1024;
|
||||
|
||||
if ((bytes >= 0) && (bytes < kilobyte)) {
|
||||
return bytes + " B";
|
||||
} else if ((bytes >= kilobyte) && (bytes < megabyte)) {
|
||||
return (bytes / kilobyte).toFixed(2) + " KB";
|
||||
} else if ((bytes >= megabyte) && (bytes < gigabyte)) {
|
||||
return (bytes / megabyte).toFixed(2) + " MB";
|
||||
} else if ((bytes >= gigabyte) && (bytes < terabyte)) {
|
||||
return (bytes / gigabyte).toFixed(2) + " GB";
|
||||
} else if (bytes >= terabyte) {
|
||||
return (bytes / terabyte).toFixed(2) + " TB";
|
||||
} else {
|
||||
return bytes + " B";
|
||||
}
|
||||
};
|
||||
//]]>
|
||||
</script>
|
||||
|
||||
<fieldset class="cbi-section">
|
||||
<legend>Active cjdns peers</legend>
|
||||
<table class="cbi-section-table" id="cjdns-peerings">
|
||||
<tr class="cbi-section-table-titles">
|
||||
<th class="cbi-section-table-cell">User/Name</th>
|
||||
<th class="cbi-section-table-cell">IPv6</th>
|
||||
<th class="cbi-section-table-cell">Status</th>
|
||||
<th class="cbi-section-table-cell">Version</th>
|
||||
<th class="cbi-section-table-cell">Rx / Tx</th>
|
||||
<th class="cbi-section-table-cell">Latency</th>
|
||||
</tr>
|
||||
<tr class="cbi-section-table-row">
|
||||
<td colspan="7">Querying Admin API</td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
35
luci-app-cjdns/luasrc/view/cjdns/value.htm
Normal file
35
luci-app-cjdns/luasrc/view/cjdns/value.htm
Normal file
|
@ -0,0 +1,35 @@
|
|||
<%+cbi/valueheader%>
|
||||
<input type="<%=self.password and 'password" class="cbi-input-password' or 'text" class="cbi-input-text' %>" onchange="cbi_d_update(this.id)"<%=
|
||||
attr("name", cbid) .. attr("id", cbid) .. attr("value", self:cfgvalue(section) or self.default) ..
|
||||
ifattr(self.size, "size") .. ifattr(self.placeholder, "placeholder")
|
||||
%> style="width: auto" />
|
||||
<% if self.password then %><img src="<%=resource%>/cbi/reload.gif" style="vertical-align:middle" title="<%:Reveal/hide password%>" onclick="var e = document.getElementById('<%=cbid%>'); e.type = (e.type=='password') ? 'text' : 'password';" /><% end %>
|
||||
<% if #self.keylist > 0 or self.datatype then -%>
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
<% if #self.keylist > 0 then -%>
|
||||
cbi_combobox_init('<%=cbid%>', {
|
||||
<%-
|
||||
for i, k in ipairs(self.keylist) do
|
||||
-%>
|
||||
<%-=string.format("%q", k) .. ":" .. string.format("%q", self.vallist[i])-%>
|
||||
<%-if i<#self.keylist then-%>,<%-end-%>
|
||||
<%-
|
||||
end
|
||||
-%>
|
||||
}, '<%- if not self.rmempty and not self.optional then -%>
|
||||
<%-: -- Please choose -- -%>
|
||||
<%- elseif self.placeholder then -%>
|
||||
<%-= pcdata(self.placeholder) -%>
|
||||
<%- end -%>', '
|
||||
<%- if self.combobox_manual then -%>
|
||||
<%-=self.combobox_manual-%>
|
||||
<%- else -%>
|
||||
<%-: -- custom -- -%>
|
||||
<%- end -%>');
|
||||
<%- end %>
|
||||
<% if self.datatype then -%>
|
||||
cbi_validate_field('<%=cbid%>', <%=tostring((self.optional or self.rmempty) == true)%>, '<%=self.datatype:gsub("'", "\\'")%>');
|
||||
<%- end %>
|
||||
//]]></script>
|
||||
<% end -%>
|
||||
<%+cbi/valuefooter%>
|
|
@ -1,62 +0,0 @@
|
|||
#
|
||||
# Copyright (C) 2014 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=mcast-tools
|
||||
PKG_SOURCE_VERSION:=e5c860f174c6deb4cc30211e895831aca0a55b7f
|
||||
PKG_VERSION:=2014-04-06
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://github.com/F0rth/mcast-tools.git
|
||||
PKG_MAINTAINER:=Steven Barth <cyrus@openwrt.org>
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
CONFIGURE_ARGS+=--enable-mldv2host --disable-pim6dd --disable-mcastread --disable-mcastsend --disable-mfc --disable-mtrace6 --disable-pmsft
|
||||
TARGET_CFLAGS+=-DIP6OPT_RTALERT_LEN=4 -D_GNU_SOURCE
|
||||
|
||||
define Package/pim6sd
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
SUBMENU:=Routing and Redirection
|
||||
TITLE:=Sparse PIM IPv6 Multicast Routing Daemon
|
||||
endef
|
||||
|
||||
define Package/pim6sd/description
|
||||
pim6sd is an IPv6 multicast routing daemon, which supports PIMv2(Protocol
|
||||
Independent Multicast Version 2) sparse mode and SSM(Source-Specific-
|
||||
Multicast) for IPv6.
|
||||
endef
|
||||
|
||||
define Package/pim6sd/conffiles
|
||||
/etc/pim6sd.conf
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
$(call Build/Prepare/Default)
|
||||
( cd $(PKG_BUILD_DIR) ; \
|
||||
aclocal ; \
|
||||
autoheader ; \
|
||||
automake --add-missing; \
|
||||
autoconf ; \
|
||||
)
|
||||
endef
|
||||
|
||||
define Package/pim6sd/install
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_CONF) ./files/pim6sd.conf $(1)/etc
|
||||
$(INSTALL_BIN) ./files/pim6sd.init $(1)/etc/init.d/pim6sd
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/pim6sd/pim6sd $(1)/usr/sbin/pim6sd
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,pim6sd))
|
|
@ -1,105 +0,0 @@
|
|||
#The timer granularity.
|
||||
#More this value is small,more pim6sd will be accurate
|
||||
#default if not specified : 5
|
||||
#BE SURE to have to same granularity on ALL routers,
|
||||
#otherwise....
|
||||
|
||||
#granularity 5;
|
||||
|
||||
#syntax : phyint <interface> <disable> <metric> [metric] <preference> [preference]
|
||||
#metric and pref are for the asserts messages
|
||||
#samples :
|
||||
|
||||
#phyint ed1 disable;
|
||||
#phyint de0 disable;
|
||||
#phyint ed0 disable;
|
||||
#phyint gif0 disable;
|
||||
|
||||
#---------------Protocol timer specifications---------------------------#
|
||||
#Notes : theses value are the default spec value!
|
||||
#do not touch it if you don't know what you do!!
|
||||
#you MUST change theses values according to the granularity value!
|
||||
#syntax : 'hello_period <number> <coef>'.
|
||||
# number is the period in second between 2 hello messages
|
||||
# and coef is the coef to determine the hello holdtime=hello_period*coef
|
||||
# default if not specified: 30 3.5
|
||||
|
||||
#hello_period 30 3.5;
|
||||
|
||||
#syntax : 'join_prune_period <number> <coef>'.
|
||||
# number is the period in second between 2 join/prune messages
|
||||
# and coef is the coef to determine the join/prune holdtime=join_prune_period*coef
|
||||
# default if not specified : 60 3.5
|
||||
|
||||
#join_prune_period 60 3.5;
|
||||
|
||||
#syntax : 'data_timeout <number>'.
|
||||
# number is the time after which (S,G) state for a silent source will be deleted
|
||||
# default if not specified : 210
|
||||
|
||||
#data_timeout 210;
|
||||
|
||||
#syntax : 'register_suppression_timeout <number>'.
|
||||
# This is the mean interval between receiving a Register-Stop and allowing
|
||||
#Register to be send again.
|
||||
# default if not specified : 60
|
||||
|
||||
#register_suppression_timeout 60;
|
||||
|
||||
#syntax : 'probe_time <number>'.
|
||||
#This is the time between sending a null Register and the Register-Suppression-Timer
|
||||
#expiring unless it is restarted by receiving a Register-Stop.
|
||||
#default if not specified : 5
|
||||
|
||||
#probe_time 5;
|
||||
|
||||
#syntax : 'assert_timeout <number>'.
|
||||
#this is the interval between the last time an Assert is received and the time at which the
|
||||
#assert is timeout
|
||||
#default if not specified : 180
|
||||
|
||||
#assert_timeout 180;
|
||||
|
||||
#syntax : <cand_rp> <interface> <time> [time] <priority> [priority]
|
||||
#and time can't be < 10
|
||||
#you can just type cand_rp,
|
||||
#samples :
|
||||
#cand_rp;
|
||||
#cand_rp de0;
|
||||
#cand_rp ed0 priority 0 time 6;
|
||||
|
||||
#syntax : <group_prefix> <multicast address>/<prefix length>
|
||||
#group_prefix ff06::15
|
||||
#default if not specified : ff00::/8
|
||||
#samples:
|
||||
#group_prefix ff1e::15/128;
|
||||
#group_prefix ff2e::/16;
|
||||
|
||||
#syntax : <cand_bootstrap_router> <interface> <priority> [priority] <time> [time]
|
||||
#Typically, you can simply set cand_bootstrap_router for a candidate bootstrap
|
||||
#router. All other parameters are optional.
|
||||
#the bootstrap period is configurable, BUT the holdtime of a bootstrap
|
||||
#router is not in the fields of a bootstrap message : it is hard-coded
|
||||
#in the pim6sd include file!
|
||||
#So be sure to have a time < PIM_BOOTSTRAP_TIMEOUT (file pimd.h )
|
||||
#cand_bootstrap_router de0 priority 15 time 5;
|
||||
|
||||
#syntax : <switch_register_threshold> <rate> [number] <interval> [number]
|
||||
#default rate = 50000 interval = 20s
|
||||
#samples :
|
||||
#TODO : not tested
|
||||
#switch_register_threshold rate 54389 interval 45;
|
||||
#switch_register_threshold;
|
||||
|
||||
#syntax : <switch_data_threshold> <rate> [number] <interval> [number]
|
||||
#default rate = 50000 interval = 20s
|
||||
#TODO : not tested
|
||||
#samples:
|
||||
#switch_data_threshold interval 100 rate 1000;
|
||||
|
||||
#syntax : <default_source_metric> [number]
|
||||
|
||||
#default_source_metric 1243;
|
||||
#syntax : <default_source_preference> [number]
|
||||
|
||||
#default_source_preference 123 ;
|
|
@ -1,14 +0,0 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=50
|
||||
USE_PROCD=1
|
||||
|
||||
start_service() {
|
||||
procd_open_instance
|
||||
|
||||
procd_set_param command /usr/sbin/pim6sd
|
||||
procd_append_param command -f -c /etc/pim6sd.conf
|
||||
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
}
|
|
@ -1,90 +0,0 @@
|
|||
From 179b60f9d6a8a104fd8d1f810d105ddba914cc7a Mon Sep 17 00:00:00 2001
|
||||
From: Steven Barth <steven@midlink.org>
|
||||
Date: Thu, 3 Apr 2014 09:09:06 +0200
|
||||
Subject: [PATCH 1/3] Fix compilation on recent Linux
|
||||
|
||||
---
|
||||
pim6sd/debug.c | 6 +++---
|
||||
pim6sd/mld6.c | 8 ++++----
|
||||
pim6sd/trace.c | 8 ++++++++
|
||||
3 files changed, 15 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/pim6sd/debug.c b/pim6sd/debug.c
|
||||
index a06a876..a96e949 100644
|
||||
--- a/pim6sd/debug.c
|
||||
+++ b/pim6sd/debug.c
|
||||
@@ -169,7 +169,7 @@ packet_kind(proto, type, code)
|
||||
return "Multicast Listener Query ";
|
||||
case MLD_LISTENER_REPORT:
|
||||
return "Multicast Listener Report ";
|
||||
- case MLD_LISTENER_DONE:
|
||||
+ case MLD_LISTENER_REDUCTION:
|
||||
return "Multicast Listener Done ";
|
||||
default:
|
||||
snprintf(unknown, sizeof(unknown),
|
||||
@@ -230,7 +230,7 @@ debug_kind(proto, type, code)
|
||||
return DEBUG_MLD;
|
||||
case MLD_LISTENER_REPORT:
|
||||
return DEBUG_MLD;
|
||||
- case MLD_LISTENER_DONE:
|
||||
+ case MLD_LISTENER_REDUCTION:
|
||||
return DEBUG_MLD;
|
||||
default:
|
||||
return DEBUG_MLD;
|
||||
@@ -574,7 +574,7 @@ dump_nbrs(fp)
|
||||
if (n->options_bitmap & PIM_HELLO_GENID_BIT)
|
||||
fprintf(fp, " %-8x", n->genid);
|
||||
else
|
||||
- fprintf(fp, " %-8x", "-");
|
||||
+ fprintf(fp, " %-8s", "-");
|
||||
if (v->uv_pim_dr == n)
|
||||
fprintf(fp, " D");
|
||||
fprintf(fp, "\n");
|
||||
diff --git a/pim6sd/mld6.c b/pim6sd/mld6.c
|
||||
index d828bbf..0bac85d 100644
|
||||
--- a/pim6sd/mld6.c
|
||||
+++ b/pim6sd/mld6.c
|
||||
@@ -207,9 +207,9 @@ init_mld6()
|
||||
|
||||
/* filter all non-MLD ICMP messages */
|
||||
ICMP6_FILTER_SETBLOCKALL(&filt);
|
||||
- ICMP6_FILTER_SETPASS(ICMP6_MEMBERSHIP_QUERY, &filt);
|
||||
- ICMP6_FILTER_SETPASS(ICMP6_MEMBERSHIP_REPORT, &filt);
|
||||
- ICMP6_FILTER_SETPASS(ICMP6_MEMBERSHIP_REDUCTION, &filt);
|
||||
+ ICMP6_FILTER_SETPASS(MLD_LISTENER_QUERY, &filt);
|
||||
+ ICMP6_FILTER_SETPASS(MLD_LISTENER_REPORT, &filt);
|
||||
+ ICMP6_FILTER_SETPASS(MLD_LISTENER_REDUCTION, &filt);
|
||||
#ifdef MLD_MTRACE_RESP
|
||||
ICMP6_FILTER_SETPASS(MLD_MTRACE_RESP, &filt);
|
||||
ICMP6_FILTER_SETPASS(MLD_MTRACE, &filt);
|
||||
@@ -448,7 +448,7 @@ accept_mld6(recvlen)
|
||||
accept_listener_report(src, dst, group);
|
||||
return;
|
||||
|
||||
- case MLD_LISTENER_DONE:
|
||||
+ case MLD_LISTENER_REDUCTION:
|
||||
accept_listener_done(src, dst, group);
|
||||
return;
|
||||
|
||||
diff --git a/pim6sd/trace.c b/pim6sd/trace.c
|
||||
index e361633..175c858 100644
|
||||
--- a/pim6sd/trace.c
|
||||
+++ b/pim6sd/trace.c
|
||||
@@ -110,6 +110,14 @@
|
||||
#include "rp.h"
|
||||
#include "trace.h"
|
||||
|
||||
+#ifndef MLD_MTRACE_RESP
|
||||
+# define MLD_MTRACE_RESP 200
|
||||
+#endif
|
||||
+
|
||||
+#ifndef MLD_MTRACE
|
||||
+# define MLD_MTRACE 201
|
||||
+#endif
|
||||
+
|
||||
/* TODO */
|
||||
/*
|
||||
* Traceroute function which returns traceroute replies to the requesting
|
||||
--
|
||||
1.8.3.2
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
From 52e110289fcc0990688e16e640ca5e7f01c66bb1 Mon Sep 17 00:00:00 2001
|
||||
From: Steven Barth <steven@midlink.org>
|
||||
Date: Sun, 6 Apr 2014 17:46:42 +0200
|
||||
Subject: [PATCH 23/23] Fix configure.in for cross-compilation
|
||||
|
||||
---
|
||||
configure.in | 26 ++------------------------
|
||||
1 file changed, 2 insertions(+), 24 deletions(-)
|
||||
|
||||
diff --git a/configure.in b/configure.in
|
||||
index b8446e2..e626a19 100644
|
||||
--- a/configure.in
|
||||
+++ b/configure.in
|
||||
@@ -170,30 +170,8 @@ fi
|
||||
AC_MSG_RESULT($enable_mldv2host)
|
||||
|
||||
dnl Determine routing get and set method
|
||||
-AC_MSG_CHECKING(userland-kernel interface for routing information)
|
||||
-AC_TRY_RUN([#include <errno.h>
|
||||
-#include <sys/types.h>
|
||||
-#include <sys/socket.h>
|
||||
-
|
||||
-main ()
|
||||
-{
|
||||
-#ifdef AF_NETLINK
|
||||
- exit(1);
|
||||
-#else
|
||||
- int ac_sock;
|
||||
-
|
||||
- ac_sock = socket (AF_ROUTE, SOCK_RAW, 0);
|
||||
- if (ac_sock < 0 && errno == EINVAL)
|
||||
- exit (1);
|
||||
- exit (0);
|
||||
-#endif
|
||||
-}],
|
||||
- [AC_DEFINE(HAVE_ROUTING_SOCKETS)
|
||||
- UK_METHOD=routesock
|
||||
- AC_MSG_RESULT(routing socket)],
|
||||
- [AC_DEFINE(HAVE_NETLINK)
|
||||
- UK_METHOD=netlink
|
||||
- AC_MSG_RESULT(netlink)])
|
||||
+AC_DEFINE(HAVE_NETLINK)
|
||||
+UK_METHOD=netlink
|
||||
AC_SUBST(UK_METHOD)
|
||||
|
||||
dnl Checks for RFC3542
|
||||
--
|
||||
1.9.1
|
||||
|
|
@ -1,227 +0,0 @@
|
|||
From 50bcf257f5f7d359d06744128585103f19072ee3 Mon Sep 17 00:00:00 2001
|
||||
From: Steven Barth <steven@midlink.org>
|
||||
Date: Thu, 10 Apr 2014 18:56:53 +0200
|
||||
Subject: [PATCH] Add compatibility code for uclibc
|
||||
|
||||
---
|
||||
pim6sd/cftoken.l | 5 ++
|
||||
pim6sd/inet6_compat.c | 161 ++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
pim6sd/mld6.c | 4 ++
|
||||
pim6sd/mld6v2.c | 5 ++
|
||||
4 files changed, 175 insertions(+)
|
||||
create mode 100644 pim6sd/inet6_compat.c
|
||||
|
||||
diff --git a/pim6sd/cftoken.l b/pim6sd/cftoken.l
|
||||
index 17479d0..5b20741 100644
|
||||
--- a/pim6sd/cftoken.l
|
||||
+++ b/pim6sd/cftoken.l
|
||||
@@ -697,3 +697,8 @@ cfparse(strict, debugonly)
|
||||
|
||||
return cf_post_config();
|
||||
}
|
||||
+
|
||||
+int yywrap(void)
|
||||
+{
|
||||
+ return 1;
|
||||
+}
|
||||
diff --git a/pim6sd/inet6_compat.c b/pim6sd/inet6_compat.c
|
||||
new file mode 100644
|
||||
index 0000000..375f17f
|
||||
--- /dev/null
|
||||
+++ b/pim6sd/inet6_compat.c
|
||||
@@ -0,0 +1,161 @@
|
||||
+#include <assert.h>
|
||||
+
|
||||
+static void
|
||||
+add_pad (struct cmsghdr *cmsg, int len)
|
||||
+{
|
||||
+ unsigned char *p = CMSG_DATA (cmsg) + cmsg->cmsg_len - CMSG_LEN (0);
|
||||
+
|
||||
+ if (len == 1)
|
||||
+ /* Special handling for 1, a one-byte solution. */
|
||||
+ *p++ = IP6OPT_PAD1;
|
||||
+ else if (len != 0)
|
||||
+ {
|
||||
+ /* Multibyte padding. */
|
||||
+ *p++ = IP6OPT_PADN;
|
||||
+ *p++ = len - 2; /* Discount the two header bytes. */
|
||||
+ /* The rest is filled with zero. */
|
||||
+ memset (p, '\0', len - 2);
|
||||
+ p += len - 2;
|
||||
+ }
|
||||
+
|
||||
+ /* Account for the bytes. */
|
||||
+ cmsg->cmsg_len += len;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+/* RFC 2292, 6.3.4
|
||||
+
|
||||
+ This function appends a Hop-by-Hop option or a Destination option
|
||||
+ into an ancillary data object that has been initialized by
|
||||
+ inet6_option_init(). This function returns a pointer to the 8-bit
|
||||
+ option type field that starts the option on success, or NULL on an
|
||||
+ error. */
|
||||
+static uint8_t *
|
||||
+option_alloc (struct cmsghdr *cmsg, int datalen, int multx, int plusy)
|
||||
+{
|
||||
+ /* The RFC limits the value of the alignment values. */
|
||||
+ if ((multx != 1 && multx != 2 && multx != 4 && multx != 8)
|
||||
+ || ! (plusy >= 0 && plusy <= 7))
|
||||
+ return NULL;
|
||||
+
|
||||
+ /* Current data size. */
|
||||
+ int dsize = cmsg->cmsg_len - CMSG_LEN (0);
|
||||
+
|
||||
+ /* The first two bytes of the option are for the extended header. */
|
||||
+ if (__builtin_expect (dsize == 0, 0))
|
||||
+ {
|
||||
+ cmsg->cmsg_len += sizeof (struct ip6_ext);
|
||||
+ dsize = sizeof (struct ip6_ext);
|
||||
+ }
|
||||
+
|
||||
+ /* First add padding. */
|
||||
+ add_pad (cmsg, ((multx - (dsize & (multx - 1))) & (multx - 1)) + plusy);
|
||||
+
|
||||
+ /* Return the pointer to the start of the option space. */
|
||||
+ uint8_t *result = CMSG_DATA (cmsg) + cmsg->cmsg_len - CMSG_LEN (0);
|
||||
+ cmsg->cmsg_len += datalen;
|
||||
+
|
||||
+ /* The extended option header length is measured in 8-byte groups.
|
||||
+ To represent the current length we might have to add padding. */
|
||||
+ dsize = cmsg->cmsg_len - CMSG_LEN (0);
|
||||
+ add_pad (cmsg, (8 - (dsize & (8 - 1))) & (8 - 1));
|
||||
+
|
||||
+ /* Record the new length of the option. */
|
||||
+ assert (((cmsg->cmsg_len - CMSG_LEN (0)) % 8) == 0);
|
||||
+ int len8b = (cmsg->cmsg_len - CMSG_LEN (0)) / 8 - 1;
|
||||
+ if (len8b >= 256)
|
||||
+ /* Too long. */
|
||||
+ return NULL;
|
||||
+
|
||||
+ struct ip6_ext *ie = (void *) CMSG_DATA (cmsg);
|
||||
+ ie->ip6e_len = len8b;
|
||||
+
|
||||
+ return result;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+/* RFC 2292, 6.3.1
|
||||
+
|
||||
+ This function returns the number of bytes required to hold an option
|
||||
+ when it is stored as ancillary data, including the cmsghdr structure
|
||||
+ at the beginning, and any padding at the end (to make its size a
|
||||
+ multiple of 8 bytes). The argument is the size of the structure
|
||||
+ defining the option, which must include any pad bytes at the
|
||||
+ beginning (the value y in the alignment term "xn + y"), the type
|
||||
+ byte, the length byte, and the option data. */
|
||||
+static int
|
||||
+inet6_option_space (nbytes)
|
||||
+ int nbytes;
|
||||
+{
|
||||
+ /* Add room for the extension header. */
|
||||
+ nbytes += sizeof (struct ip6_ext);
|
||||
+
|
||||
+ return CMSG_SPACE (roundup (nbytes, 8));
|
||||
+}
|
||||
+
|
||||
+
|
||||
+/* RFC 2292, 6.3.2
|
||||
+
|
||||
+ This function is called once per ancillary data object that will
|
||||
+ contain either Hop-by-Hop or Destination options. It returns 0 on
|
||||
+ success or -1 on an error. */
|
||||
+static int
|
||||
+inet6_option_init (bp, cmsgp, type)
|
||||
+ void *bp;
|
||||
+ struct cmsghdr **cmsgp;
|
||||
+ int type;
|
||||
+{
|
||||
+ /* Only Hop-by-Hop or Destination options allowed. */
|
||||
+ if (type != IPV6_HOPOPTS && type != IPV6_DSTOPTS)
|
||||
+ return -1;
|
||||
+
|
||||
+ /* BP is a pointer to the previously allocated space. */
|
||||
+ struct cmsghdr *newp = (struct cmsghdr *) bp;
|
||||
+
|
||||
+ /* Initialize the message header.
|
||||
+
|
||||
+ Length: No data yet, only the cmsghdr struct. */
|
||||
+ newp->cmsg_len = CMSG_LEN (0);
|
||||
+ /* Originating protocol: obviously IPv6. */
|
||||
+ newp->cmsg_level = IPPROTO_IPV6;
|
||||
+ /* Message type. */
|
||||
+ newp->cmsg_type = type;
|
||||
+
|
||||
+ /* Pass up the result. */
|
||||
+ *cmsgp = newp;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+/* RFC 2292, 6.3.3
|
||||
+
|
||||
+ This function appends a Hop-by-Hop option or a Destination option
|
||||
+ into an ancillary data object that has been initialized by
|
||||
+ inet6_option_init(). This function returns 0 if it succeeds or -1 on
|
||||
+ an error. */
|
||||
+static int
|
||||
+inet6_option_append (cmsg, typep, multx, plusy)
|
||||
+ struct cmsghdr *cmsg;
|
||||
+ const uint8_t *typep;
|
||||
+ int multx;
|
||||
+ int plusy;
|
||||
+{
|
||||
+ /* typep is a pointer to the 8-bit option type. It is assumed that this
|
||||
+ field is immediately followed by the 8-bit option data length field,
|
||||
+ which is then followed immediately by the option data.
|
||||
+
|
||||
+ The option types IP6OPT_PAD1 and IP6OPT_PADN also must be handled. */
|
||||
+ int len = typep[0] == IP6OPT_PAD1 ? 1 : typep[1] + 2;
|
||||
+
|
||||
+ /* Get the pointer to the space in the message. */
|
||||
+ uint8_t *ptr = option_alloc (cmsg, len, multx, plusy);
|
||||
+ if (ptr == NULL)
|
||||
+ /* Some problem with the parameters. */
|
||||
+ return -1;
|
||||
+
|
||||
+ /* Copy the content. */
|
||||
+ memcpy (ptr, typep, len);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
diff --git a/pim6sd/mld6.c b/pim6sd/mld6.c
|
||||
index 0bac85d..febdc98 100644
|
||||
--- a/pim6sd/mld6.c
|
||||
+++ b/pim6sd/mld6.c
|
||||
@@ -108,6 +108,10 @@
|
||||
#include "trace.h"
|
||||
#include "mld6.h"
|
||||
|
||||
+#ifdef __UCLIBC__
|
||||
+#include "inet6_compat.c"
|
||||
+#endif
|
||||
+
|
||||
/*
|
||||
* Exported variables.
|
||||
*/
|
||||
diff --git a/pim6sd/mld6v2.c b/pim6sd/mld6v2.c
|
||||
index 8cd5a4d..322cb7b 100644
|
||||
--- a/pim6sd/mld6v2.c
|
||||
+++ b/pim6sd/mld6v2.c
|
||||
@@ -73,6 +73,11 @@
|
||||
#include "callout.h"
|
||||
#include "timer.h"
|
||||
|
||||
+#ifdef __UCLIBC__
|
||||
+#include "inet6_compat.c"
|
||||
+#endif
|
||||
+
|
||||
+
|
||||
#ifdef HAVE_MLDV2
|
||||
|
||||
#ifndef HAVE_RFC3542
|
||||
--
|
||||
1.9.1
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
--- a/include/linux/pim.h
|
||||
+++ b/include/linux/pim.h
|
||||
@@ -10,7 +10,7 @@ struct pim {
|
||||
__u8 pim_type:4, /* PIM message type */
|
||||
pim_ver:4; /* PIM version */
|
||||
#elif defined(__BIG_ENDIAN_BITFIELD)
|
||||
- __u8 pim_ver:4; /* PIM version */
|
||||
+ __u8 pim_ver:4, /* PIM version */
|
||||
pim_type:4; /* PIM message type */
|
||||
#endif
|
||||
__u8 pim_rsv; /* Reserved */
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright (C) 2006-2011 OpenWrt.org
|
||||
# Copyright (C) 2014-2015 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
|
@ -8,13 +8,14 @@
|
|||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=mcproxy
|
||||
PKG_SOURCE_VERSION:=6638aa9aabd2ccdde8915b61a8e0fb995b1f91a3
|
||||
PKG_VERSION:=2014-05-31-$(PKG_SOURCE_VERSION)
|
||||
PKG_RELEASE:=1
|
||||
PKG_SOURCE_VERSION:=b7bd2d0809a0d1f177181c361b9a6c83e193b79a
|
||||
PKG_VERSION:=2014-12-31-$(PKG_SOURCE_VERSION)
|
||||
PKG_RELEASE:=3
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=git://github.com/mcproxy/mcproxy.git
|
||||
PKG_MAINTAINER:=Steven Barth <cyrus@openwrt.org>
|
||||
PKG_LICENSE:=GPL-2.0+
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
@ -39,11 +40,15 @@ endef
|
|||
|
||||
define Package/mcproxy/conffiles
|
||||
/etc/mcproxy.conf
|
||||
/etc/config/mcproxy
|
||||
endef
|
||||
|
||||
define Package/mcproxy/install
|
||||
$(INSTALL_DIR) $(1)/etc
|
||||
$(INSTALL_CONF) ./files/mcproxy.conf $(1)/etc/mcproxy.conf
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_CONF) ./files/mcproxy.config $(1)/etc/config/mcproxy
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_CONF) ./files/mcproxy.conf $(1)/etc
|
||||
$(INSTALL_BIN) ./files/mcproxy.init $(1)/etc/init.d/mcproxy
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/mcproxy-bin $(1)/usr/sbin/mcproxy
|
||||
|
|
|
@ -2,13 +2,67 @@
|
|||
##-- mcproxy configuration script --##
|
||||
######################################
|
||||
|
||||
# Erase or comment out the following line when configured
|
||||
disable;
|
||||
|
||||
# Protocol: IGMPv1|IGMPv2|IGMPv3 (IPv4) - MLDv1|MLDv2 (IPv6)
|
||||
protocol IGMPv3;
|
||||
|
||||
###########################################
|
||||
|
||||
# Proxy Instance: upstream ==> downstream
|
||||
pinstance proxy1: eth1 ==> "eth0.1";
|
||||
#pinstance proxy2: "eth0.2" ==> "br-lan";
|
||||
#pinstance proxy3: eth0 ==> eth1 eth2;
|
||||
pinstance A: ap a1 ==> ap a2;
|
||||
pinstance B: bp b1 ==> bp b2;
|
||||
|
||||
###########################################
|
||||
|
||||
# Tables
|
||||
table allways {
|
||||
(*|*)
|
||||
};
|
||||
|
||||
table piA_peering_ifs {
|
||||
ap(*|*)
|
||||
};
|
||||
|
||||
table piA_upstreams {
|
||||
a1(*|*)
|
||||
};
|
||||
|
||||
table piB_peering_ifs {
|
||||
bp(*|*)
|
||||
};
|
||||
|
||||
table piB_upstreams {
|
||||
b1(*|*)
|
||||
};
|
||||
|
||||
###########################################
|
||||
|
||||
# Instance Behaviour
|
||||
pinstance A upstream * in rulematching mutex 10; #or 25ms (u4)
|
||||
#pinstance A upstream * out rulematching all; #default
|
||||
|
||||
pinstance A upstream ap out blacklist table allways; #(u1)
|
||||
#pinstance A upstream ap in whitelist table {(*|*)}; #default (u2, u3)
|
||||
|
||||
pinstance A upstream a1 out blacklist table piA_peering_ifs; #(u3_1)
|
||||
#pinstance A upstream a1 in whitelist table {(*|*)}; #default
|
||||
|
||||
pinstance A downstream ap in blacklist table allways; #(d1)
|
||||
pinstance A downstream ap out blacklist table piA_upstreams; #(d2, d2_1, d3, d4)
|
||||
|
||||
#pinstance A downstream a2 in whitelist table {(*|*)}; #default
|
||||
#pinstance A downstream a2 out whitelist table {(*|*)}; #default
|
||||
|
||||
pinstance B upstream * in rulematching mutex 10; #or 25ms (u4)
|
||||
#pinstance B upstream * out rulematching all; #default
|
||||
|
||||
pinstance B upstream bp out blacklist table allways; #(u1)
|
||||
#pinstance B upstream bp in whitelist table {(*|*)}; #default (u2, u3)
|
||||
|
||||
pinstance B upstream b1 out blacklist table piB_peering_ifs; #(u3_1)
|
||||
#pinstance b upstream b1 in whitelist table {(*|*)}; #default
|
||||
|
||||
pinstance B downstream bp in blacklist table allways; #(d1)
|
||||
pinstance B downstream bp out blacklist table piB_upstreams; #(d2, d2_1, d3, d4)
|
||||
|
||||
#pinstance B downstream b2 in whitelist table {(*|*)}; #default
|
||||
#pinstance B downstream b2 out whitelist table {(*|*)}; #default
|
||||
|
|
231
mcproxy/files/mcproxy.config
Normal file
231
mcproxy/files/mcproxy.config
Normal file
|
@ -0,0 +1,231 @@
|
|||
# Use your own MCProxy config file
|
||||
config mcproxy 'mcproxy_file'
|
||||
option disabled '1'
|
||||
option respawn '1'
|
||||
option file '/etc/mcproxy.conf'
|
||||
|
||||
# Use OpenWrt UCI config
|
||||
config mcproxy 'mcproxy'
|
||||
option disabled '1'
|
||||
option respawn '1'
|
||||
option protocol 'IGMPv3'
|
||||
|
||||
###########################################
|
||||
|
||||
# Simple configuration examples
|
||||
|
||||
config instance
|
||||
option disabled '1'
|
||||
option name 'proxy1'
|
||||
list upstream 'eth1'
|
||||
list downstream 'eth0.2'
|
||||
|
||||
config instance
|
||||
option disabled '1'
|
||||
option name 'proxy2'
|
||||
list upstream 'eth0.2'
|
||||
list downstream 'eth0.4'
|
||||
list downstream 'br-lan'
|
||||
|
||||
config instance
|
||||
option disabled '1'
|
||||
option name 'proxy3'
|
||||
list upstream 'eth1.2'
|
||||
list upstream 'eth1.4'
|
||||
list downstream 'eth0.1'
|
||||
|
||||
###########################################
|
||||
|
||||
# Advanced configuration example
|
||||
|
||||
config instance
|
||||
option name 'A'
|
||||
list upstream 'ap'
|
||||
list upstream 'a1'
|
||||
list downstream 'ap'
|
||||
list downstream 'a2'
|
||||
|
||||
config instance
|
||||
option name 'B'
|
||||
list upstream 'bp'
|
||||
list upstream 'b1'
|
||||
list downstream 'bp'
|
||||
list downstream 'b2'
|
||||
|
||||
config table
|
||||
option name 'allways'
|
||||
list entries '(*|*)'
|
||||
|
||||
config table
|
||||
option name 'piA_peering_ifs'
|
||||
list entries 'ap(*|*)'
|
||||
|
||||
config table
|
||||
option name 'piA_upstreams'
|
||||
list entries 'a1(*|*)'
|
||||
|
||||
config table
|
||||
option name 'piB_peering_ifs'
|
||||
list entries 'bp(*|*)'
|
||||
|
||||
config table
|
||||
option name 'piB_upstreams'
|
||||
list entries 'b1(*|*)'
|
||||
|
||||
config behaviour
|
||||
option instance 'A'
|
||||
option section 'upstream'
|
||||
option interface '*'
|
||||
option direction 'in'
|
||||
option rulematching 'mutex 10'
|
||||
|
||||
config behaviour
|
||||
option disabled '1'
|
||||
option instance 'A'
|
||||
option section 'upstream'
|
||||
option interface '*'
|
||||
option direction 'out'
|
||||
option rulematching 'all'
|
||||
|
||||
config behaviour
|
||||
option instance 'A'
|
||||
option section 'upstream'
|
||||
option interface 'ap'
|
||||
option direction 'out'
|
||||
option table 'allways'
|
||||
|
||||
config behaviour
|
||||
option disabled '1'
|
||||
option instance 'A'
|
||||
option section 'upstream'
|
||||
option interface 'ap'
|
||||
option direction 'in'
|
||||
option whitelist '1'
|
||||
option table '{(*|*)}'
|
||||
|
||||
config behaviour
|
||||
option instance 'A'
|
||||
option section 'upstream'
|
||||
option interface 'a1'
|
||||
option direction 'out'
|
||||
option table 'piA_peering_ifs'
|
||||
|
||||
config behaviour
|
||||
option disabled '1'
|
||||
option instance 'A'
|
||||
option section 'upstream'
|
||||
option interface 'a1'
|
||||
option direction 'in'
|
||||
option whitelist '1'
|
||||
option table '{(*|*)}'
|
||||
|
||||
config behaviour
|
||||
option instance 'A'
|
||||
option section 'downstream'
|
||||
option interface 'ap'
|
||||
option direction 'in'
|
||||
option table 'allways'
|
||||
|
||||
config behaviour
|
||||
option instance 'A'
|
||||
option section 'downstream'
|
||||
option interface 'ap'
|
||||
option direction 'out'
|
||||
option table 'piA_upstreams'
|
||||
|
||||
config behaviour
|
||||
option disabled '1'
|
||||
option instance 'A'
|
||||
option section 'downstream'
|
||||
option interface 'a2'
|
||||
option direction 'in'
|
||||
option whitelist '1'
|
||||
option table '{(*|*)}'
|
||||
|
||||
config behaviour
|
||||
option disabled '1'
|
||||
option instance 'A'
|
||||
option section 'downstream'
|
||||
option interface 'a2'
|
||||
option direction 'out'
|
||||
option whitelist '1'
|
||||
option table '{(*|*)}'
|
||||
|
||||
config behaviour
|
||||
option instance 'B'
|
||||
option section 'upstream'
|
||||
option interface '*'
|
||||
option direction 'in'
|
||||
option rulematching 'mutex 10'
|
||||
|
||||
config behaviour
|
||||
option disabled '1'
|
||||
option instance 'B'
|
||||
option section 'upstream'
|
||||
option interface '*'
|
||||
option direction 'out'
|
||||
option rulematching 'all'
|
||||
|
||||
config behaviour
|
||||
option instance 'B'
|
||||
option section 'upstream'
|
||||
option interface 'bp'
|
||||
option direction 'out'
|
||||
option table 'allways'
|
||||
|
||||
config behaviour
|
||||
option disabled '1'
|
||||
option instance 'B'
|
||||
option section 'upstream'
|
||||
option interface 'bp'
|
||||
option direction 'in'
|
||||
option whitelist '1'
|
||||
option table '{(*|*)}'
|
||||
|
||||
config behaviour
|
||||
option instance 'B'
|
||||
option section 'upstream'
|
||||
option interface 'b1'
|
||||
option direction 'out'
|
||||
option table 'piB_peering_ifs'
|
||||
|
||||
config behaviour
|
||||
option disabled '1'
|
||||
option instance 'B'
|
||||
option section 'upstream'
|
||||
option interface 'b1'
|
||||
option direction 'in'
|
||||
option whitelist '1'
|
||||
option table '{(*|*)}'
|
||||
|
||||
config behaviour
|
||||
option instance 'B'
|
||||
option section 'downstream'
|
||||
option interface 'bp'
|
||||
option direction 'in'
|
||||
option table 'allways'
|
||||
|
||||
config behaviour
|
||||
option instance 'B'
|
||||
option section 'downstream'
|
||||
option interface 'bp'
|
||||
option direction 'out'
|
||||
option table 'piB_upstreams'
|
||||
|
||||
config behaviour
|
||||
option disabled '1'
|
||||
option instance 'B'
|
||||
option section 'downstream'
|
||||
option interface 'b2'
|
||||
option direction 'in'
|
||||
option whitelist '1'
|
||||
option table '{(*|*)}'
|
||||
|
||||
config behaviour
|
||||
option disabled '1'
|
||||
option instance 'B'
|
||||
option section 'downstream'
|
||||
option interface 'b2'
|
||||
option direction 'out'
|
||||
option whitelist '1'
|
||||
option table '{(*|*)}'
|
|
@ -1,14 +1,184 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2014-2015 OpenWrt.org
|
||||
|
||||
START=50
|
||||
START=99
|
||||
USE_PROCD=1
|
||||
|
||||
start_service() {
|
||||
mcproxy_handle_instances() {
|
||||
local instance="$1"
|
||||
local conf_file="$2"
|
||||
local disabled
|
||||
local pre=""
|
||||
local name
|
||||
local upstreams
|
||||
local downstreams
|
||||
|
||||
config_get_bool disabled "$instance" 'disabled' '0'
|
||||
config_get name "$instance" "name" "$instance"
|
||||
config_get upstreams "$instance" "upstream"
|
||||
config_get downstreams "$instance" "downstream"
|
||||
|
||||
if [ $disabled -eq 1 ]; then
|
||||
pre="# "
|
||||
fi
|
||||
|
||||
local str_up=""
|
||||
if [ -n "$upstreams" ]; then
|
||||
local upstream
|
||||
for upstream in $upstreams; do
|
||||
str_up="$str_up \"$upstream\""
|
||||
done
|
||||
fi
|
||||
|
||||
local str_down=""
|
||||
if [ -n "$downstreams" ]; then
|
||||
local downstream
|
||||
for downstream in $downstreams; do
|
||||
str_down="$str_down \"$downstream\""
|
||||
done
|
||||
fi
|
||||
|
||||
if [ ! -z $downstream ]; then
|
||||
echo -e "${pre}pinstance ${name}:${str_up} ==>${str_down};\n" >> $conf_file
|
||||
fi
|
||||
}
|
||||
|
||||
# mcproxy_list_table <var> <section> <option>
|
||||
mcproxy_list_table() {
|
||||
local val
|
||||
local len
|
||||
local _buffer
|
||||
local c=1
|
||||
|
||||
config_get len "$2" "${3}_LENGTH"
|
||||
[ -z "$len" ] && return 0
|
||||
while [ $c -le "$len" ]; do
|
||||
config_get val "$2" "${3}_ITEM$c"
|
||||
append _buffer "\t${val}\n"
|
||||
c="$(($c + 1))"
|
||||
done
|
||||
|
||||
export "${1}=${_buffer}";
|
||||
}
|
||||
|
||||
mcproxy_handle_tables() {
|
||||
local table="$1"
|
||||
local conf_file="$2"
|
||||
local name
|
||||
local entries
|
||||
|
||||
config_get name "$table" "name" ""
|
||||
mcproxy_list_table entries "$table" "entries"
|
||||
|
||||
if [ ! -z $name ] && [ ! -z $table ]; then
|
||||
echo -e "table $name {\n${entries}};\n" >> $conf_file
|
||||
fi
|
||||
}
|
||||
|
||||
mcproxy_handle_behaviour() {
|
||||
local behaviour="$1"
|
||||
local conf_file="$2"
|
||||
local disabled
|
||||
local pre=""
|
||||
local instance
|
||||
local section
|
||||
local interface
|
||||
local direction
|
||||
local rulematching
|
||||
local table
|
||||
|
||||
config_get_bool disabled "$behaviour" 'disabled' '0'
|
||||
config_get instance "$behaviour" "instance"
|
||||
config_get section "$behaviour" "section" "upstream"
|
||||
config_get interface "$behaviour" "interface" "*"
|
||||
config_get direction "$behaviour" "direction" "in"
|
||||
config_get rulematching "$behaviour" "rulematching"
|
||||
config_get table "$behaviour" "table"
|
||||
|
||||
if [ -z $instance ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
local rule_table
|
||||
if [ ! -z $rulematching ]; then
|
||||
rule_table="rulematching $rulematching"
|
||||
elif [ ! -z $table ]; then
|
||||
local whitelist
|
||||
local list
|
||||
|
||||
config_get_bool whitelist "$behaviour" 'whitelist' '0'
|
||||
if [ $whitelist -eq 1 ]; then
|
||||
list="whitelist"
|
||||
else
|
||||
list="blacklist"
|
||||
fi
|
||||
|
||||
rule_table="$list table $table"
|
||||
else
|
||||
rule_table="rulematching all"
|
||||
fi
|
||||
|
||||
if [ $disabled -eq 1 ]; then
|
||||
pre="# "
|
||||
fi
|
||||
|
||||
echo -e "${pre}pinstance $instance $section \"$interface\" $direction $rule_table;\n" >> $conf_file
|
||||
}
|
||||
|
||||
mcproxy_network_trigger() {
|
||||
procd_add_interface_trigger "interface.*" "$1" /etc/init.d/mcproxy restart
|
||||
}
|
||||
mcproxy_handle_network() {
|
||||
local instance="$1"
|
||||
|
||||
config_list_foreach "$instance" upstream mcproxy_network_trigger
|
||||
config_list_foreach "$instance" downstream mcproxy_network_trigger
|
||||
}
|
||||
|
||||
start_instance() {
|
||||
local cfg="$1"
|
||||
local aux
|
||||
local conf_file
|
||||
|
||||
config_get_bool aux "$cfg" 'disabled' '0'
|
||||
[ "$aux" = 1 ] && return 1
|
||||
|
||||
config_get conf_file "$cfg" "file"
|
||||
if [ ! -n "$conf_file" ]; then
|
||||
mkdir -p /var/etc
|
||||
conf_file="/var/etc/mcproxy_${cfg}.conf"
|
||||
|
||||
local protocol
|
||||
config_get protocol "$cfg" "protocol" "IGMPv3"
|
||||
echo -e "protocol ${protocol};\n" > $conf_file
|
||||
|
||||
config_foreach mcproxy_handle_instances instance $conf_file
|
||||
config_foreach mcproxy_handle_tables table $conf_file
|
||||
config_foreach mcproxy_handle_behaviour behaviour $conf_file
|
||||
fi
|
||||
|
||||
procd_open_instance
|
||||
|
||||
procd_set_param command /usr/sbin/mcproxy
|
||||
procd_append_param command -f /etc/mcproxy.conf
|
||||
procd_append_param command -f $conf_file
|
||||
|
||||
config_get_bool aux "$cfg" 'respawn' '0'
|
||||
[ "$aux" = 1 ] && procd_set_param respawn
|
||||
|
||||
procd_open_trigger
|
||||
config_foreach mcproxy_handle_network instance
|
||||
procd_close_trigger
|
||||
|
||||
procd_set_param respawn
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_open_trigger
|
||||
procd_add_config_trigger "config.change" "mcproxy" /etc/init.d/mcproxy restart
|
||||
procd_close_trigger
|
||||
}
|
||||
|
||||
start_service() {
|
||||
config_load mcproxy
|
||||
config_foreach start_instance mcproxy
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
#include <numeric>
|
||||
#include <unistd.h>
|
||||
|
||||
+#ifdef __UCLIBC__
|
||||
+#ifndef __GLIBC__
|
||||
+#include "sourcefilter.cpp"
|
||||
+#endif /* __UCLIBC__ */
|
||||
+#endif /* __GLIBC__ */
|
||||
+
|
||||
std::string ipAddrResolver(std::string ipAddr)
|
||||
{
|
11
mcproxy/patches/0004-add-defs.patch
Normal file
11
mcproxy/patches/0004-add-defs.patch
Normal file
|
@ -0,0 +1,11 @@
|
|||
--- a/mcproxy/src/utils/mc_socket.cpp
|
||||
+++ b/mcproxy/src/utils/mc_socket.cpp
|
||||
@@ -38,6 +38,8 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#ifndef __GLIBC__
|
||||
+#define IP_MULTICAST_ALL 49
|
||||
+
|
||||
#include "sourcefilter.cpp"
|
||||
#endif /* __GLIBC__ */
|
||||
|
|
@ -7,13 +7,14 @@
|
|||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=minimalist-pcproxy
|
||||
PKG_SOURCE_VERSION:=9e41b6b698ff719960299711707785ffa0b250ab
|
||||
PKG_VERSION:=2014-09-02-$(PKG_SOURCE_VERSION)
|
||||
PKG_RELEASE:=2
|
||||
PKG_SOURCE_VERSION:=2d6d1b0b0a3b79a9b4a9b0a7606a84600a967bcb
|
||||
PKG_VERSION:=2015-01-12-$(PKG_SOURCE_VERSION)
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=git://github.com/fingon/minimalist-pcproxy.git
|
||||
PKG_MAINTAINER:=Markus Stenberg <fingon@iki.fi>
|
||||
PKG_LICENSE:=GPL-2.0
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
|
||||
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
@ -26,7 +27,7 @@ define Package/minimalist-pcproxy
|
|||
CATEGORY:=Network
|
||||
TITLE:=Lightweight PCP proxy
|
||||
URL:=https://github.com/fingon/minimalist-pcproxy
|
||||
DEPENDS:=+libubox +@IPV6
|
||||
DEPENDS:=+libubox @IPV6
|
||||
endef
|
||||
|
||||
define Package/minimalist-pcproxy/description
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
|
||||
if [ `uci get -q upnpd.config._pcproxy_configured` = "1" ]
|
||||
if [ `uci -q get upnpd.config._pcproxy_configured` = "1" ]
|
||||
then
|
||||
exit
|
||||
fi
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue