33a78ab597
git-svn-id: svn://svn.openwrt.org/openwrt/packages@21667 3c298f89-4303-0410-b956-a3cf2f4a3e73
138 lines
3.1 KiB
Bash
Executable File
138 lines
3.1 KiB
Bash
Executable File
#!/bin/sh /etc/rc.common
|
|
|
|
START=70
|
|
|
|
PID_F='/var/run/babeld.pid'
|
|
EXTRA_COMMANDS="status"
|
|
EXTRA_HELP=" status Dump Babel's table to the log file."
|
|
|
|
listen_ifname() {
|
|
local name="$1"
|
|
local switch="$2"
|
|
local _uciname=`uci get -q -P /var/state network.$name.ifname`
|
|
append args "$switch ${_uciname:-$name}"
|
|
append interfaces "${_uciname:-$name}"
|
|
}
|
|
|
|
append_ifname() {
|
|
local section="$1"
|
|
local option="$2"
|
|
local switch="$3"
|
|
local _name
|
|
config_get _name "$section" "$option"
|
|
[ -z "$_name" ] && return 0
|
|
local _uciname=`uci get -q -P /var/state network.$_name.ifname`
|
|
append args "$switch ${_uciname:-$_name}"
|
|
}
|
|
|
|
append_bool() {
|
|
local section="$1"
|
|
local option="$2"
|
|
local value="$3"
|
|
local _loctmp
|
|
config_get_bool _loctmp "$section" "$option"
|
|
[ "$_loctmp" -gt 0 ] && append args "$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" '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" 'parasitic' '-P'
|
|
|
|
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" 'idle_hello_interval' '-i'
|
|
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'
|
|
append_parm "$cfg" 'import_table' '-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 $PID_F $args $interfaces"
|
|
}
|
|
|
|
stop() {
|
|
[ -f $PID_F ] && kill $(cat $PID_F)
|
|
}
|
|
|
|
status() {
|
|
[ -f $PID_F ] && kill -USR1 $(cat $PID_F)
|
|
}
|