###############################################################################
# network(8) completion
-function _network_find_on_cmdline () {
+_network_find_on_cmdline () {
local word subcommand c=0
while [ ${c} -lt ${cword} ]; do
word="${words[c]}"
done
}
-function _network_complete_hooks() {
+_network_complete_hooks() {
local type="${1}"
COMPREPLY=( $(compgen -W "$(network raw list-hooks "${type}")" -- "${cur}") )
}
-function _network_complete_ports() {
+_network_complete_ports() {
COMPREPLY=( $(compgen -W "$(network raw list-ports)" -- "${cur}") )
}
-function _network_complete_zones() {
+_network_complete_zones() {
COMPREPLY=( $(compgen -W "$(network raw list-zones)" -- "${cur}") )
}
-function _network_device() {
+_network_device() {
local words=( $@ )
local commands="list $(network raw list-devices)"
esac
}
-function _network_device_subcommand() {
+_network_device_subcommand() {
local words=( $@ )
local commands="discover monitor status unlock ussd"
esac
}
-function _network_dhcpd() {
+_network_dhcpd() {
local proto="${1}"
shift
esac
}
-function _network_dhcpd_subnet() {
+_network_dhcpd_subnet() {
local proto="${1}"
shift
esac
}
-function _network_dhcpd_subnet_subcommand() {
+_network_dhcpd_subnet_subcommand() {
local proto="${1}"
local subnet="${2}"
shift 2
esac
}
-function _network_dhcpd_subnet_subcommand_options() {
+_network_dhcpd_subnet_subcommand_options() {
local proto="${1}"
local subnet="${2}"
shift 2
COMPREPLY=( $(compgen -W "${options}" -- "${cur}") )
}
-function _network_dhcpd_subnet_subcommand_range() {
+_network_dhcpd_subnet_subcommand_range() {
local proto="${1}"
local subnet="${2}"
shift 2
esac
}
-function _network_dns_server() {
+_network_dns_server() {
local words=( $@ )
local commands="add list remove update"
esac
}
-function _network_port() {
+_network_port() {
local words=( $@ )
local commands="new destroy $(network raw list-ports)"
esac
}
-function _network_port_subcommand() {
+_network_port_subcommand() {
local words=( $@ )
local commands="create down edit remove status up"
fi
}
-function _network_route() {
+_network_route() {
local words=( $@ )
local commands="add list remove"
esac
}
-function _network_settings() {
+_network_settings() {
local words=( $@ )
local key keys
COMPREPLY=( $(compgen -W "${keys}" -- "${cur}") )
}
-function _network_zone() {
+_network_zone() {
local words=( $@ )
local commands="new destroy $(network raw list-zones)"
esac
}
-function _network_zone_subcommand() {
+_network_zone_subcommand() {
local zone="${1}"
shift
esac
}
-function _network_zone_subcommand_port() {
+_network_zone_subcommand_port() {
local zone="${1}"
shift
esac
}
-function _network_zone_subcommand_port_subcommand() {
+_network_zone_subcommand_port_subcommand() {
local zone="${1}"
local port="${2}"
shift 2
esac
}
-function _network() {
+_network() {
local cur prev words cword
_init_completion || return
# Define protocols which are supported by aiccu.
AICCU_SUPPORTED_PROTOCOLS="tic tsp l2tp"
-function aiccu_start() {
+aiccu_start() {
local device=${1}
assert isset device
return ${EXIT_OK}
}
-function aiccu_stop() {
+aiccu_stop() {
local device=${1}
assert isset device
service_stop "aiccu@${device}.service"
}
-function aiccu_write_config() {
+aiccu_write_config() {
local device=${1}
local file=${2}
shift 2
# #
###############################################################################
-function batman_adv_start() {
+batman_adv_start() {
# Load the batman kernel module.
module_load "batman-adv"
}
-function batman_adv_add() {
+batman_adv_add() {
local device="${1}"
assert isset device
return ${ret}
}
-function batman_adv_delete() {
+batman_adv_delete() {
local device="${1}"
assert isset device
device_delete "${device}"
}
-function batman_adv_attach() {
+batman_adv_attach() {
local device=${1}
assert isset device
fwrite "${SYS_CLASS_NET}/${port}/batman_adv/mesh_iface" "${device}"
}
-function batman_adv_detach() {
+batman_adv_detach() {
local port=${1}
assert isset port
fwrite "${SYS_CLASS_NET}/${port}/batman_adv/mesh_iface" "none"
}
-function batman_adv_get_aggregated_ogms() {
+batman_adv_get_aggregated_ogms() {
local device=${1}
assert isset device
return ${EXIT_ERROR}
}
-function batman_adv_get_ap_isolation() {
+batman_adv_get_ap_isolation() {
local device=${1}
assert isset device
return ${EXIT_ERROR}
}
-function batman_adv_get_bonding_mode() {
+batman_adv_get_bonding_mode() {
local device=${1}
assert isset device
return ${EXIT_ERROR}
}
-function batman_adv_get_distributed_arp_table() {
+batman_adv_get_distributed_arp_table() {
local device=${1}
assert isset device
return ${EXIT_ERROR}
}
-function batman_adv_get_bridge_loop_avoidance() {
+batman_adv_get_bridge_loop_avoidance() {
local device=${1}
assert isset device
return ${EXIT_ERROR}
}
-function batman_adv_get_fragmentation() {
+batman_adv_get_fragmentation() {
local device=${1}
assert isset device
return ${EXIT_ERROR}
}
-function batman_adv_get_gateway_mode() {
+batman_adv_get_gateway_mode() {
local device=${1}
assert isset device
return ${EXIT_ERROR}
}
-function batman_adv_get_gateway_bandwidth() {
+batman_adv_get_gateway_bandwidth() {
local device=${1}
assert isset device
fread "${SYS_CLASS_NET}/${device}/mesh/gw_bandwidth"
}
-function batman_adv_get_gateway_selection_class() {
+batman_adv_get_gateway_selection_class() {
local device=${1}
assert isset device
fread "${SYS_CLASS_NET}/${device}/mesh/gw_sel_class"
}
-function batman_adv_get_hop_penalty() {
+batman_adv_get_hop_penalty() {
local device=${1}
assert isset device
fread "${SYS_CLASS_NET}/${device}/mesh/hop_penalty"
}
-function batman_adv_get_originator_interval() {
+batman_adv_get_originator_interval() {
local device=${1}
assert isset device
fread "${SYS_CLASS_NET}/${device}/mesh/orig_interval"
}
-function batman_adv_get_routing_algorithm() {
+batman_adv_get_routing_algorithm() {
local device=${1}
assert isset device
balance-tlb balance-alb"
BONDING_MASTERS="/sys/class/net/bonding_masters"
-function bonding_init() {
+bonding_init() {
module_load "bonding"
}
-function bonding_create() {
+bonding_create() {
local device=${1}
assert isset device
shift
return ${EXIT_OK}
}
-function bonding_remove() {
+bonding_remove() {
local device=${1}
assert isset device
return ${EXIT_OK}
}
-function bonding_get_mode() {
+bonding_get_mode() {
local device=${1}
assert isset device
print "${mode}"
}
-function bonding_set_mode() {
+bonding_set_mode() {
assert [ $# -eq 2 ]
local device="${1}"
return ${EXIT_OK}
}
-function bonding_enslave_device() {
+bonding_enslave_device() {
local device=${1}
assert isset device
return ${EXIT_OK}
}
-function bonding_get_slaves() {
+bonding_get_slaves() {
local device=${1}
assert isset device
shift
return ${EXIT_OK}
}
-function bonding_get_lacp_rate() {
+bonding_get_lacp_rate() {
local device=${1}
assert isset device
return ${EXIT_OK}
}
-function bonding_get_miimon() {
+bonding_get_miimon() {
local device=${1}
assert isset device
fread ${SYS_CLASS_NET}/${device}/bonding/miimon
}
-function bonding_set_miimon() {
+bonding_set_miimon() {
local device=${1}
assert isset device
print "${miimon}" > ${SYS_CLASS_NET}/${device}/bonding/miimon
}
-function bonding_slave_get_master() {
+bonding_slave_get_master() {
local slave=${1}
assert isset slave
# #
###############################################################################
-function bridge_create() {
+bridge_create() {
local bridge=${1}
assert isset bridge
shift
return ${ret}
}
-function bridge_delete() {
+bridge_delete() {
local bridge=${1}
assert isset bridge
device_delete ${bridge}
}
-function bridge_attach_device() {
+bridge_attach_device() {
local bridge=${1}
assert isset bridge
return ${ret}
}
-function bridge_detach_device() {
+bridge_detach_device() {
local bridge=${1}
assert isset bridge
return ${ret}
}
-function bridge_get_members() {
+bridge_get_members() {
local bridge=${1}
assert isset bridge
done
}
-function bridge_is_forwarding() {
+bridge_is_forwarding() {
local seconds=45
local zone=${1}
return ${EXIT_ERROR}
}
-function bridge_has_carrier() {
+bridge_has_carrier() {
local zone=${1}
local has_carrier=${EXIT_ERROR}
IDENT=" "
-function cli_help_requested() {
+cli_help_requested() {
local argument="${1}"
if [ -n "${argument}" ]; then
return ${EXIT_FALSE}
}
-function cli_run_help() {
+cli_run_help() {
local command="$@"
print "Run \"${command} help\" to get more information."
return ${EXIT_OK}
}
-function cli_device_headline() {
+cli_device_headline() {
local device=${1}
assert isset device
fi
}
-function cli_device_stats() {
+cli_device_stats() {
local level=${1}
local device=${2}
cli_space
}
-function cli_device_vlan() {
+cli_device_vlan() {
local device=${1}
cli_headline 2 "VLAN"
cli_space
}
-function cli_device_bonded() {
+cli_device_bonded() {
local device=${1}
cli_headline 2 "Bonding information"
cli_space
}
-function cli_device_bonding() {
+cli_device_bonding() {
local device=${1}
assert isset device
cli_space
}
-function cli_headline() {
+cli_headline() {
local level=${1}
local format=${2}
shift 2
printf "${out}"
}
-function cli_statusline() {
+cli_statusline() {
local level=${1}
shift
cli_print $(( ${level} - 1 )) "%-12s %s" "${head}" "$@"
}
-function cli_print() {
+cli_print() {
local level=${1}
local format=${2}
shift 2
printf "${out}"
}
-function cli_print_fmt1() {
+cli_print_fmt1() {
local level=${1}
shift
cli_print ${level} "${format}" "$@"
}
-function cli_print_bool() {
+cli_print_bool() {
if [ "${1}" = "${EXIT_TRUE}" ]; then
echo "true"
else
fi
}
-function cli_print_yesno() {
+cli_print_yesno() {
if [ "${1}" = "${EXIT_TRUE}" ]; then
echo "yes"
else
fi
}
-function cli_print_enabled() {
+cli_print_enabled() {
enabled ${1}
cli_print_bool $?
}
-function cli_print_warning() {
+cli_print_warning() {
local level=${1}
shift
cli_print ${level} "${CLR_YELLOW_B}%s${CLR_RESET}" "$@"
}
-function cli_space() {
+cli_space() {
printf "\n"
}
-function cli_ident() {
+cli_ident() {
local level=${1}
assert isinteger level
print "${ident}"
}
-function cli_yesno() {
+cli_yesno() {
local message="$@ [y/n] "
local yesno
done
}
-function cli_get_key() {
+cli_get_key() {
local key="${1%%=*}"
echo "${key/--/}"
}
-function cli_get_val() {
+cli_get_val() {
echo "${@#*=}"
}
-function cli_get_bool() {
+cli_get_bool() {
local value="$(cli_get_val "$@")"
if enabled value; then
return ${EXIT_FALSE}
}
-function cli_usage() {
+cli_usage() {
local command="$@"
local basename="$(basename ${0})"
echo "Please run '${command}' for detailed help." >&2
}
-function cli_show_man() {
+cli_show_man() {
local manpage=${1}
assert isset manpage
# #
###############################################################################
-function firewall_cli() {
+firewall_cli() {
local protocol="${1}"
assert isset protocol
shift
exit ${EXIT_OK}
}
-function firewall_cli_panic() {
+firewall_cli_panic() {
local protocol="${1}"
assert isset protocol
shift
firewall_panic ${admin_hosts}
}
-function firewall_cli_settings() {
+firewall_cli_settings() {
if cli_help_requested $@; then
cli_show_man firewall-settings
exit ${EXIT_OK}
fi
}
-function firewall_cli_zone() {
+firewall_cli_zone() {
local protocol="${1}"
assert isset protocol
shift
}
# Show firewall zone conifguration.
-function firewall_cli_zone_status() {
+firewall_cli_zone_status() {
local zone=${1}
assert isset zone
}
# Edit firewall zone configuration.
-function firewall_cli_zone_edit() {
+firewall_cli_zone_edit() {
firewall_zone_edit "$@"
exit ${EXIT_OK}
# #
###############################################################################
-function config_header() {
+config_header() {
local what=${1}
assert isset what
echo
}
-function config_hostname() {
+config_hostname() {
local hostname=${1}
if [ -n "${hostname}" ]; then
fi
}
-function config_domainname() {
+config_domainname() {
local hostname=$(config_hostname)
# Strip off the hostname part and just return
# Accounting
-function conntrack_get_accounting() {
+conntrack_get_accounting() {
sysctl_get "net.netfilter.nf_conntrack_acct"
}
-function conntrack_set_accounting() {
+conntrack_set_accounting() {
local value="${1}"
assert isset value
# Max. connections
-function conntrack_get_max_connections() {
+conntrack_get_max_connections() {
sysctl_get "net.netfilter.nf_conntrack_max"
}
-function conntrack_set_max_connections() {
+conntrack_set_max_connections() {
local value="${1}"
assert isinteger value
# UDP timeout
-function conntrack_get_udp_timeout() {
+conntrack_get_udp_timeout() {
sysctl_get "net.netfilter.nf_conntrack_udp_timeout"
}
-function conntrack_set_udp_timeout() {
+conntrack_set_udp_timeout() {
local value="${1}"
assert isinteger value
# #
###############################################################################
-function db_connection_init() {
+db_connection_init() {
if [ -e "${DB_CONNECTION_FILE}" ]; then
return ${EXIT_OK}
fi
EOF
}
-function db_connection_update() {
+db_connection_update() {
local zone=${1}
local action=${2}
shift 2
EOF
}
-function db_ppp_init() {
+db_ppp_init() {
local file=${1}
if [ -e "${file}" ]; then
EOF
}
-function db_ppp_update() {
+db_ppp_update() {
local zone=${1}
shift
# #
###############################################################################
-function device_list() {
+device_list() {
local devices
# Add all interfaces
}
# Check if the device exists
-function device_exists() {
+device_exists() {
local device=${1}
# If device name was not found, exit.
serial_exists ${device}
}
-function device_matches_pattern() {
+device_matches_pattern() {
local device="${1}"
assert isset device
&& return ${EXIT_TRUE} || return ${EXIT_FALSE}
}
-function device_delete() {
+device_delete() {
local device=${1}
assert isset device
return ${ret}
}
-function device_has_flag() {
+device_has_flag() {
local device=${1}
local flag=${2}
}
# Check if the device is up
-function device_is_up() {
+device_is_up() {
local device=${1}
device_exists ${device} || return ${EXIT_ERROR}
device_has_flag ${device} 0x1
}
-function device_ifindex_to_name() {
+device_ifindex_to_name() {
local idx=${1}
assert isset idx
return ${EXIT_ERROR}
}
-function device_get_ifindex() {
+device_get_ifindex() {
local device=${1}
assert isset device
}
# Check if the device is a batman-adv bridge
-function device_is_batman_adv() {
+device_is_batman_adv() {
[ -d "${SYS_CLASS_NET}/${1}/mesh" ]
}
# Check if the device is a batman-adv slave port
-function device_is_batman_adv_slave() {
+device_is_batman_adv_slave() {
local device="${1}"
if [ -d "${SYS_CLASS_NET}/${device}/batman_adv" ]; then
}
# Check if the device is a bonding device
-function device_is_bonding() {
+device_is_bonding() {
[ -d "/sys/class/net/${1}/bonding" ]
}
# Check if the device bonded in a bonding device
-function device_is_bonded() {
+device_is_bonded() {
local device=${1}
[ -d "${SYS_CLASS_NET}/${device}/bonding_slave" ]
}
# Check if the device is a bridge
-function device_is_bridge() {
+device_is_bridge() {
[ -d "/sys/class/net/${1}/bridge" ]
}
-function device_is_bridge_attached() {
+device_is_bridge_attached() {
local device=${1}
[ -d "${SYS_CLASS_NET}/${device}/brport" ]
}
-function device_is_wireless_monitor() {
+device_is_wireless_monitor() {
local device="${1}"
assert isset device
device_matches_pattern "${device}" "${PORT_PATTERN_WIRELESS_MONITOR}"
}
-function device_is_wireless_adhoc() {
+device_is_wireless_adhoc() {
local device="${1}"
assert isset device
device_matches_pattern "${device}" "${PORT_PATTERN_WIRELESS_ADHOC}"
}
-function device_get_bridge() {
+device_get_bridge() {
local device=${1}
assert isset device
}
# Check if the device is a vlan device
-function device_is_vlan() {
+device_is_vlan() {
local device=${1}
assert isset device
}
# Check if the device has vlan devices
-function device_has_vlans() {
+device_has_vlans() {
local device=${1}
assert isset device
[ -n "${vlans}" ] && return ${EXIT_OK} || return ${EXIT_ERROR}
}
-function device_get_vlans() {
+device_get_vlans() {
local device=${1}
assert isset device
}
# Check if the device is a ppp device
-function device_is_ppp() {
+device_is_ppp() {
local device=${1}
local type=$(__device_get_file ${device} type)
}
# Check if the device is a pointopoint device.
-function device_is_ptp() {
+device_is_ptp() {
local device=${1}
device_has_flag ${device} 0x10
}
# Check if the device is a loopback device
-function device_is_loopback() {
+device_is_loopback() {
local device=${1}
[ "${device}" = "lo" ]
# Check if the device is a dummy device
# This is the worst possible check, but all I could come up with
-function device_is_dummy() {
+device_is_dummy() {
local device="${1}"
[[ ${device} =~ ^dummy[0-9]+$ ]]
}
# Check if the device is a wireless device
-function device_is_wireless() {
+device_is_wireless() {
local device=${1}
[ -d "${SYS_CLASS_NET}/${device}/phy80211" ]
}
-function device_get_phy() {
+device_get_phy() {
local device="${1}"
if device_is_wireless "${device}"; then
return ${EXIT_ERROR}
}
-function device_is_phy() {
+device_is_phy() {
phy_exists $@
}
-function device_is_serial() {
+device_is_serial() {
serial_exists $@
}
# Check if the device is a physical network interface
-function device_is_ethernet() {
+device_is_ethernet() {
local device=${1}
device_is_ethernet_compatible "${device}" || \
}
# Get the device type
-function device_get_type() {
+device_get_type() {
local device=${1}
# If the device does not exist (happens on udev remove events),
fi
}
-function device_is_ethernet_compatible() {
+device_is_ethernet_compatible() {
local device="${1}"
# /sys/class/net/*/type must equal 1 for ethernet compatible devices
[[ "${type}" = "1" ]]
}
-function device_get_status() {
+device_get_status() {
local device=${1}
assert isset device
echo "${status}"
}
-function device_get_address() {
+device_get_address() {
local device=${1}
cat ${SYS_CLASS_NET}/${device}/address 2>/dev/null
}
-function device_set_address() {
+device_set_address() {
assert [ $# -eq 2 ]
local device="${1}"
return ${ret}
}
-function device_get() {
+device_get() {
local device
local devices
return ${EXIT_OK}
}
-function devices_get_all() {
+devices_get_all() {
device_get
}
# Check if a device has a cable plugged in
-function device_has_carrier() {
+device_has_carrier() {
local device=${1}
assert isset device
[ "${carrier}" = "1" ]
}
-function device_is_promisc() {
+device_is_promisc() {
local device=${1}
device_has_flag ${device} 0x200
}
-function device_set_promisc() {
+device_set_promisc() {
local device=${1}
local state=${2}
}
# Check if the device is free
-function device_is_free() {
+device_is_free() {
! device_is_used $@
}
# Check if the device is used
-function device_is_used() {
+device_is_used() {
local device=${1}
device_has_vlans ${device} && \
}
# Give the device a new name
-function device_set_name() {
+device_set_name() {
local source=$1
local destination=${2}
}
# Set device up
-function device_set_up() {
+device_set_up() {
local device=${1}
# Silently fail if device was not found
ip link set ${device} up
}
-function device_set_parent_up() {
+device_set_parent_up() {
local device=${1}
local parent
}
# Set device down
-function device_set_down() {
+device_set_down() {
local device=${1}
assert isset device
return ${ret}
}
-function device_set_parent_down() {
+device_set_parent_down() {
local device=${1}
local parent
return ${EXIT_OK}
}
-function device_get_mtu() {
+device_get_mtu() {
local device=${1}
if ! device_exists ${device}; then
}
# Set mtu to a device
-function device_set_mtu() {
+device_set_mtu() {
local device=${1}
local mtu=${2}
return ${ret}
}
-function device_adjust_mtu() {
+device_adjust_mtu() {
assert [ $# -eq 2 ]
local device="${1}"
device_set_mtu "${device}" "${mtu}"
}
-function device_discover() {
+device_discover() {
local device=${1}
log INFO "Running discovery process on device '${device}'."
done
}
-function device_has_ip() {
+device_has_ip() {
local device=${1}
local addr=${2}
listmatch ${addr} $(device_get_addresses ${device})
}
-function device_get_addresses() {
+device_get_addresses() {
local device=${1}
assert device_exists ${device}
done
}
-function __device_get_file() {
+__device_get_file() {
local device=${1}
local file=${2}
echo "$(<${path})"
}
-function __device_set_file() {
+__device_set_file() {
assert [ $# -eq 3 ]
local device="${1}"
echo "${value}" > "${path}"
}
-function device_get_rx_bytes() {
+device_get_rx_bytes() {
local device=${1}
__device_get_file ${device} statistics/rx_bytes
}
-function device_get_tx_bytes() {
+device_get_tx_bytes() {
local device=${1}
__device_get_file ${device} statistics/tx_bytes
}
-function device_get_rx_packets() {
+device_get_rx_packets() {
local device=${1}
__device_get_file ${device} statistics/rx_packets
}
-function device_get_tx_packets() {
+device_get_tx_packets() {
local device=${1}
__device_get_file ${device} statistics/tx_packets
}
-function device_get_rx_errors() {
+device_get_rx_errors() {
local device=${1}
__device_get_file ${device} statistics/rx_errors
}
-function device_get_tx_errors() {
+device_get_tx_errors() {
local device=${1}
__device_get_file ${device} statistics/tx_errors
}
-function device_get_speed() {
+device_get_speed() {
local device=${1}
__device_get_file ${device} speed
}
-function device_get_duplex() {
+device_get_duplex() {
local device=${1}
__device_get_file ${device} duplex
}
-function device_get_link_string() {
+device_get_link_string() {
local device="${1}"
assert isset device
DHCPV4D_MAX_LEASE_TIME="86400" # 24h
DHCPV4D_MIN_LEASE_TIME=""
-function dhcpd_service() {
+dhcpd_service() {
case "${1}" in
ipv6)
print "dhcpd6.service"
return ${EXIT_OK}
}
-function dhcpd_start() {
+dhcpd_start() {
local services=$(dhcpd_service $@)
local service
done
}
-function dhcpd_stop() {
+dhcpd_stop() {
local services=$(dhcpd_service $@)
local service
done
}
-function dhcpd_restart() {
+dhcpd_restart() {
# DHCP does not support a reload, so
# we retsart it.
local services=$(dhcpd_service $@)
done
}
-function dhcpd_reload() {
+dhcpd_reload() {
dhcpd_restart $@
}
-function dhcpd_edit() {
+dhcpd_edit() {
local proto=${1}
assert isset proto
shift
dhcpd_global_settings_write ${proto}
}
-function _dhcpd_edit_ipv4() {
+_dhcpd_edit_ipv4() {
local val
while [ $# -gt 0 ]; do
fi
}
-function _dhcpd_edit_ipv6() {
+_dhcpd_edit_ipv6() {
while [ $# -gt 0 ]; do
case "${1}" in
--preferred-lifetime=*)
done
}
-function dhcpd_settings_file() {
+dhcpd_settings_file() {
local proto=${1}
assert isset proto
return ${EXIT_OK}
}
-function dhcpd_settings() {
+dhcpd_settings() {
local proto=${1}
assert isset proto
return ${EXIT_OK}
}
-function dhcpd_options_file() {
+dhcpd_options_file() {
local proto=${1}
assert isset proto
return ${EXIT_OK}
}
-function dhcpd_options_list() {
+dhcpd_options_list() {
local proto=${1}
assert isset proto
return ${EXIT_OK}
}
-function dhcpd_options() {
+dhcpd_options() {
local proto=${1}
assert isset proto
return ${EXIT_OK}
}
-function dhcpd_global_settings_list() {
+dhcpd_global_settings_list() {
local proto="${1}"
assert isset proto
dhcpd_settings "${proto}"
}
-function dhcpd_global_settings_defaults() {
+dhcpd_global_settings_defaults() {
local proto=${1}
assert isset proto
done
}
-function dhcpd_global_settings_read() {
+dhcpd_global_settings_read() {
local proto=${1}
assert isset proto
settings_read ${file} ${settings}
}
-function dhcpd_global_settings_write() {
+dhcpd_global_settings_write() {
local proto=${1}
assert isset proto
settings_write ${file} ${settings}
}
-function dhcpd_global_options_read() {
+dhcpd_global_options_read() {
local proto=${1}
assert isset proto
fi
}
-function dhcpd_subnet_path() {
+dhcpd_subnet_path() {
local proto=${1}
assert isset proto
return ${EXIT_OK}
}
-function dhcpd_subnet_exists() {
+dhcpd_subnet_exists() {
local proto=${1}
assert isset proto
[ -d "${path}" ] && return ${EXIT_TRUE} || return ${EXIT_FALSE}
}
-function dhcpd_subnet_match() {
+dhcpd_subnet_match() {
local proto=${1}
assert isset proto
return ${EXIT_FALSE}
}
-function dhcpd_new_subnet_id() {
+dhcpd_new_subnet_id() {
local proto=${1}
assert isset proto
return ${EXIT_ERROR}
}
-function dhcpd_subnet_new() {
+dhcpd_subnet_new() {
local proto=${1}
assert isset proto
shift
fi
}
-function dhcpd_subnet_edit() {
+dhcpd_subnet_edit() {
local proto=${1}
assert isset proto
shift
settings_write ${file} ${settings}
}
-function dhcpd_subnet_remove() {
+dhcpd_subnet_remove() {
local proto=${1}
assert isset proto
rm -rf ${path}
}
-function dhcpd_subnet_list() {
+dhcpd_subnet_list() {
local proto=${1}
assert isset proto
done
}
-function dhcpd_subnet_read() {
+dhcpd_subnet_read() {
local proto=${1}
assert isset proto
settings_read ${file}
}
-function dhcpd_subnet_range_path() {
+dhcpd_subnet_range_path() {
local proto=${1}
assert isset proto
return ${EXIT_OK}
}
-function dhcpd_subnet_range_settings() {
+dhcpd_subnet_range_settings() {
local proto=${1}
case "${proto}" in
return ${EXIT_OK}
}
-function dhcpd_subnet_new_range_id() {
+dhcpd_subnet_new_range_id() {
local proto=${1}
assert isset proto
return ${EXIT_ERROR}
}
-function dhcpd_subnet_range_new() {
+dhcpd_subnet_range_new() {
local proto=${1}
assert isset proto
shift
return ${EXIT_OK}
}
-function dhcpd_subnet_range_edit() {
+dhcpd_subnet_range_edit() {
local proto=${1}
assert isset proto
shift
settings_write ${file} ${settings}
}
-function dhcpd_subnet_range_remove() {
+dhcpd_subnet_range_remove() {
local path=$(dhcpd_subnet_range_path $@)
assert isset path
rm -f ${path}
}
-function dhcpd_subnet_range_list() {
+dhcpd_subnet_range_list() {
local proto=${1}
assert isset proto
return ${EXIT_OK}
}
-function dhcpd_subnet_range_read() {
+dhcpd_subnet_range_read() {
local proto=${1}
assert isset proto
settings_read ${file}
}
-function dhcpd_subnet_settings() {
+dhcpd_subnet_settings() {
local proto=${1}
case "${proto}" in
return ${EXIT_OK}
}
-function dhcpd_subnet_options_file() {
+dhcpd_subnet_options_file() {
local path=$(dhcpd_subnet_path $@)
assert isset path
print "${path}/options"
}
-function dhcpd_subnet_options_list() {
+dhcpd_subnet_options_list() {
local proto=${1}
assert isset proto
return ${EXIT_OK}
}
-function dhcpd_subnet_options_read() {
+dhcpd_subnet_options_read() {
local proto=${1}
assert isset proto
}
# Helper functions to create a DHCP configuration file.
-function _dhcpd_write_options() {
+_dhcpd_write_options() {
local proto=${1}
assert isset proto
fi
}
-function _dhcpd_read_options() {
+_dhcpd_read_options() {
local file=${1}
assert isset file
settings_read_array ${file} options ${!options_list}
}
-function _dhcpd_write_subnet() {
+_dhcpd_write_subnet() {
local proto=${1}
assert isset proto
return ${EXIT_OK}
}
-function _dhcpd_write_subnet_options() {
+_dhcpd_write_subnet_options() {
local proto=${1}
assert isset proto
_dhcpd_write_options ${proto} ${file} ${options_list} "\t"
}
-function _dhcpd_search_routers() {
+_dhcpd_search_routers() {
local proto=${1}
assert isset proto
list_join routers ", "
}
-function _dhcpd_write_subnet_range() {
+_dhcpd_write_subnet_range() {
local proto=${1}
assert isset proto
return ${EXIT_OK}
}
-function dhcpd_write_config() {
+dhcpd_write_config() {
local proto=${1}
assert isset proto
# Path to the configuration file of the DNS resolver.
RESOLV_CONF="/etc/resolv.conf"
-function dns_get_hostname() {
+dns_get_hostname() {
local address=${1}
assert isset address
)
}
-function dns_server_list() {
+dns_server_list() {
[ -r "${DNS_SERVER_CONFIG_FILE}" ] || return ${EXIT_OK}
local line
return ${EXIT_OK}
}
-function dns_server_list_sorted() {
+dns_server_list_sorted() {
[ -r "${DNS_SERVER_CONFIG_FILE}" ] || return ${EXIT_OK}
local servers=$(
return ${EXIT_OK}
}
-function dns_server_show() {
+dns_server_show() {
[ -r "${DNS_SERVER_CONFIG_FILE}" ] || return ${EXIT_OK}
local line
return ${EXIT_OK}
}
-function dns_server_add() {
+dns_server_add() {
local server=${1}
assert isset server
return ${EXIT_OK}
}
-function dns_server_exists() {
+dns_server_exists() {
local entry=${1}
assert isset entry
return ${EXIT_FALSE}
}
-function dns_server_remove() {
+dns_server_remove() {
local entry=${1}
assert isset entry
return ${EXIT_OK}
}
-function dns_server_flush() {
+dns_server_flush() {
: > ${DNS_SERVER_CONFIG_FILE}
}
-function dns_server_parse_line() {
+dns_server_parse_line() {
local arg
for arg in ${NETWORK_CONFIG_DNS_SERVER_PARAMS}; do
# Update resolv.conf(5) when initializing the network.
init_register dns_generate_resolvconf
-function dns_generate_resolvconf() {
+dns_generate_resolvconf() {
local file=${RESOLV_CONF}
log INFO "Updating resolver configuration..."
done >> ${file}
}
-function dns_get_search_domains() {
+dns_get_search_domains() {
# Add search domains.
local search_domains="$(unquote ${DNS_SEARCH_DOMAINS})"
list_unique ${search_domains}
}
-function dns_server_get_zone_name_servers() {
+dns_server_get_zone_name_servers() {
local priority proto server servers zone
for zone in $(zones_get_all); do
DUMMY_PORT_PATTERN="dN"
-function dummy_create() {
+dummy_create() {
local device=${1}
assert isset device
return ${ret}
}
-function dummy_remove() {
+dummy_remove() {
local device=${1}
assert isset device
# This function initializes all kernel parameters that need to be adjusted
# to run this firewall properly.
-function firewall_kernel_init() {
+firewall_kernel_init() {
log INFO "Configuring kernel parameters..."
local option
# High-level function which will create a ruleset for the current firewall
# configuration and load it into the kernel.
-function firewall_start() {
+firewall_start() {
local protocol="${1}"
assert isset protocol
shift
firewall_lock_release
}
-function firewall_stop() {
+firewall_stop() {
local protocol="${1}"
assert isset protocol
firewall_lock_release
}
-function firewall_show() {
+firewall_show() {
local protocol="${1}"
assert isset protocol
return ${EXIT_OK}
}
-function firewall_panic() {
+firewall_panic() {
local protocol="${1}"
assert isset protocol
shift
firewall_lock_release
}
-function firewall_lock_acquire() {
+firewall_lock_acquire() {
lock_acquire ${RUN_DIR}/.firewall_lock
# Make sure the lock is released after the firewall
IPTABLES_TMPDIR=$(mktemp -d)
}
-function firewall_lock_release() {
+firewall_lock_release() {
if isset IPTABLES_TMPDIR; then
# Remove all temporary data.
rm -rf ${IPTABLES_TMPDIR}
lock_release ${RUN_DIR}/.firewall_lock
}
-function firewall_custom_chains() {
+firewall_custom_chains() {
local protocol="${1}"
assert isset protocol
iptables "${protocol}" -t nat -A OUTPUT -j CUSTOMOUTPUT
}
-function firewall_filter_invalid_packets() {
+firewall_filter_invalid_packets() {
local protocol="${1}"
assert isset protocol
iptables "${protocol}" -A FILTER_INVALID -m conntrack --ctstate INVALID -j DROP
}
-function firewall_tcp_clamp_mss() {
+firewall_tcp_clamp_mss() {
# Do nothing if this has been disabled.
enabled FIREWALL_CLAMP_PATH_MTU || return ${EXIT_OK}
-p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu
}
-function firewall_connection_tracking() {
+firewall_connection_tracking() {
local protocol="${1}"
assert isset protocol
iptables "${protocol}" -A FORWARD -j CONNTRACK
}
-function firewall_localhost_create_chains() {
+firewall_localhost_create_chains() {
local protocol="${1}"
assert isset protocol
iptables "${protocol}" -A OUTPUT -o lo -j ACCEPT
}
-function firewall_filter_rh0_headers() {
+firewall_filter_rh0_headers() {
local protocol="${1}"
assert isset protocol
iptables "${protocol}" -A OUTPUT -j FILTER_RH0
}
-function firewall_filter_icmp() {
+firewall_filter_icmp() {
local protocol="${1}"
assert isset protocol
return ${EXIT_OK}
}
-function firewall_zone_create_chains() {
+firewall_zone_create_chains() {
local protocol="${1}"
assert isset protocol
return ${EXIT_OK}
}
-function firewall_parse_rules() {
+firewall_parse_rules() {
local file=${1}
assert isset file
shift
done < ${file}
}
-function _firewall_parse_rule_line() {
+_firewall_parse_rule_line() {
local arg
# Clear all values.
# #
###############################################################################
-function policy_zone_add() {
+policy_zone_add() {
local zone=${1}
assert isset zone
done
}
-function policy_zone_masquerade4() {
+policy_zone_masquerade4() {
local zone=${1}
assert isset zone
-j MASQUERADE --random
}
-function policy_zone_allow_all() {
+policy_zone_allow_all() {
local zone=${1}
assert isset zone
iptables -A "${chain}" -m conntrack --ctstate NEW -j ACCEPT
}
-function policy_zone_deny_all() {
+policy_zone_deny_all() {
local zone=${1}
assert isset zone
iptables -A "${chain}" -j DROP
}
-function policy_drop_all() {
+policy_drop_all() {
# Nothing to do here, because that is the
# default policy of the INPUT/OUTPUT/FORWARD chain.
:
}
-function policy_import_all_rules() {
+policy_import_all_rules() {
# This will populate all chains with the rules
# for the given zone.
# -A ${chain}_RULES_INC
}
-function policy_load() {
+policy_load() {
local zone_from=${1}
assert isset zone_from
# #
###############################################################################
-function firewall_zone_create() {
+firewall_zone_create() {
local zone=${1}
assert isset zone
return ${EXIT_OK}
}
-function firewall_zone_config() {
+firewall_zone_config() {
local zone=${1}
assert isset zone
return ${EXIT_OK}
}
-function firewall_zone_exists() {
+firewall_zone_exists() {
local file=$(firewall_zone_config $@)
[ -r "${file}" ] && return ${EXIT_TRUE} || return ${EXIT_FALSE}
}
-function firewall_zone_read() {
+firewall_zone_read() {
local zone=${1}
assert isset zone
return ${EXIT_OK}
}
-function firewall_zone_write() {
+firewall_zone_write() {
local zone=${1}
assert isset zone
return ${EXIT_OK}
}
-function firewall_zone_print() {
+firewall_zone_print() {
local zone=${1}
assert isset zone
return ${EXIT_OK}
}
-function firewall_zone_edit() {
+firewall_zone_edit() {
local zone=${1}
assert isset zone
shift
)
}
-function firewall_zone_reset() {
+firewall_zone_reset() {
local zone=${1}
assert isset zone
# #
###############################################################################
-function he_tunnelbroker_endpoint_update() {
+he_tunnelbroker_endpoint_update() {
local username
local password
local tunnel_id
# #
###############################################################################
-function hook_dir() {
+hook_dir() {
local type=${1}
if [ -n "${type}" ]; then
}
NETWORK_HOOKS_DIR_ZONES="$(hook_dir zone)"
-function hook_list() {
+hook_list() {
local type="${1}"
assert isoneof type port zone
return ${EXIT_OK}
}
-function hook_exists() {
+hook_exists() {
local type=${1}
local hook=${2}
[ ! -d "${hook}" ] && [ -x "${hook}" ]
}
-function hook_exec() {
+hook_exec() {
local type="${1}"
assert isset type
return ${ret}
}
-function hook_list() {
+hook_list() {
local type="${1}"
local dir="$(hook_dir "${type}")"
}
# The default help function.
-function hook_help() {
+hook_help() {
# If no man page has been configured, we print an error message.
if [ -z "${HOOK_MANPAGE}" ]; then
error "There is no help available for hook '${HOOK}'. Exiting."
exit $?
}
-function config_get_hook() {
+config_get_hook() {
local config=${1}
assert isset config
)
}
-function hook_zone_exists() {
+hook_zone_exists() {
hook_exists zone $@
}
-function hook_zone_exec() {
+hook_zone_exec() {
hook_exec zone $@
}
-function hook_zone_get_all() {
+hook_zone_get_all() {
hook_list zone
}
-function hook_config_exists() {
+hook_config_exists() {
hook_exists config $@
}
-function hook_config_exec() {
+hook_config_exec() {
hook_exec config $@
}
-function hook_config_get_all() {
+hook_config_get_all() {
hook_list config
}
-function hook_valid_command() {
+hook_valid_command() {
local type="${1}"
local cmd="${2}"
return ${EXIT_FALSE}
}
-function hook_valid_command_config() {
+hook_valid_command_config() {
local cmd="${1}"
case "${cmd}" in
return ${EXIT_FALSE}
}
-function hook_valid_command_port() {
+hook_valid_command_port() {
local cmd="${1}"
case "${cmd}" in
return ${EXIT_FALSE}
}
-function hook_valid_command_zone() {
+hook_valid_command_zone() {
local cmd="${1}"
case "${cmd}" in
HOSTAPD_CONTROL_INTERFACE_DIR="/run/hostapd/ctrl"
-function hostapd_config_write() {
+hostapd_config_write() {
local device=${1}
assert isset device
return ${EXIT_OK}
}
-function hostapd_start() {
+hostapd_start() {
local device=${1}
assert isset device
return ${EXIT_OK}
}
-function hostapd_stop() {
+hostapd_stop() {
local device=${1}
assert isset device
# #
###############################################################################
-function hotplug_assert_in_hotplug_event() {
+hotplug_assert_in_hotplug_event() {
assert [ -n "${IN_HOTPLUG_EVENT}" ]
}
-function hotplug_action() {
+hotplug_action() {
hotplug_assert_in_hotplug_event
echo "${ACTION}"
}
-function hotplug_propagate_all_ports() {
+hotplug_propagate_all_ports() {
hotplug_assert_in_hotplug_event
# Create configured child devices.
done
}
-function hotplug_propagate_all_zones() {
+hotplug_propagate_all_zones() {
hotplug_assert_in_hotplug_event
local zone
done
}
-function hotplug_event_port_is_interface() {
+hotplug_event_port_is_interface() {
hotplug_assert_in_hotplug_event
local port="${1}"
[ "${port}" = "${INTERFACE}" ]
}
-function hotplug_event_interface_is_slave_of_port() {
+hotplug_event_interface_is_slave_of_port() {
hotplug_assert_in_hotplug_event
local port="${1}"
list_match "${INTERFACE}" ${slaves}
}
-function hotplug_event_interface_is_port_of_zone() {
+hotplug_event_interface_is_port_of_zone() {
hotplug_assert_in_hotplug_event
local zone="${1}"
list_match "${INTERFACE}" ${ports}
}
-function hotplug_event_port_uses_phy() {
+hotplug_event_port_uses_phy() {
hotplug_assert_in_hotplug_event
local port="${1}"
# #
###############################################################################
-function http_format_args() {
+http_format_args() {
local args="$@"
list_join args "&"
}
-function http_GET() {
+http_GET() {
local username
local password
http_call "${url}"
}
-function http_call() {
+http_call() {
# Argument list for invoking curl.
local args
INIT_FUNCTIONS=""
-function init_register() {
+init_register() {
INIT_FUNCTIONS="${INIT_FUNCTIONS} $@"
}
-function init_run() {
+init_run() {
local init
for init in ${INIT_FUNCTIONS}; do
${init}
# A list of supported versions of the IP protocol
IP_SUPPORTED_PROTOCOLS=""
-function ip_split_prefix() {
+ip_split_prefix() {
local address=${1}
assert isset address
echo "${address%%/*}"
}
-function ip_get_prefix() {
+ip_get_prefix() {
local address=${1}
assert isset address
echo "${address##*/}"
}
-function ip_detect_protocol() {
+ip_detect_protocol() {
local address=${1}
assert isset address
return ${EXIT_ERROR}
}
-function ip_protocol_is_supported() {
+ip_protocol_is_supported() {
local proto=${1}
assert isset proto
listmatch ${proto} ${IP_SUPPORTED_PROTOCOLS}
}
-function ip_is_valid() {
+ip_is_valid() {
local address=${1}
assert isset address
isset proto && return ${EXIT_TRUE} || return ${EXIT_FALSE}
}
-function ip_is_network() {
+ip_is_network() {
local network=${1}
assert isset network
return ${EXIT_TRUE}
}
-function ip_prefix_is_valid() {
+ip_prefix_is_valid() {
local proto=${1}
assert isset proto
assert ip_protocol_is_supported ${proto}
}
-function ip_address_add() {
+ip_address_add() {
local device=${1}
local address=${2}
return ${EXIT_OK}
}
-function ip_address_del() {
+ip_address_del() {
local device=${1}
local address=${2}
IP_TUNNEL_MODES="sit"
-function ip_tunnel_add() {
+ip_tunnel_add() {
local device=${1}
shift
assert [ $? -eq 0 ]
}
-function ip_tunnel_del() {
+ip_tunnel_del() {
local device=${1}
assert device_exists ${device}
assert [ $? -eq 0 ]
}
-function ip_tunnel_6rd_set_prefix() {
+ip_tunnel_6rd_set_prefix() {
local device="${1}"
assert isset device
IPTABLES_TABLES="filter mangle nat"
-function iptables() {
+iptables() {
local protocol="${1}"
assert isset protocol
shift
assert_check_retval $?
}
-function iptables_chain_create() {
+iptables_chain_create() {
local protocol="${1}"
assert isset protocol
shift
}
# Calls the binary iptables command.
-function _iptables() {
+_iptables() {
local protocol="${1}"
assert isset protocol
shift
return $?
}
-function iptables_status() {
+iptables_status() {
local protocol="${1}"
assert isset protocol
return ${EXIT_OK}
}
-function iptables_rulesfile() {
+iptables_rulesfile() {
local proto=${1}
proto=${proto/ipv/}
print "${IPTABLES_TMPDIR}/${chain}${proto}"
}
-function iptables_init() {
+iptables_init() {
local protocol="${1}"
assert isset protocol
}
# Load the created ruleset into the kernel.
-function iptables_commit () {
+iptables_commit () {
local protocol="${1}"
assert isset protocol
shift
return ${EXIT_OK}
}
-function _iptables_commit_cat_rulesfile() {
+_iptables_commit_cat_rulesfile() {
local protocol="${1}"
assert isset protocol
assert [ -s "${rulesfile}" ]
}
-function _iptables_commit_load_rulesfile() {
+_iptables_commit_load_rulesfile() {
local protocol="${1}"
assert isset protocol
return ${ret}
}
-function iptables_dump() {
+iptables_dump() {
local protocol="${1}"
assert isset protocol
done < "${rulesfile}"
}
-function iptables_LOG() {
+iptables_LOG() {
local prefix="${1}"
local ret
print "${ret}"
}
-function iptables_protocol() {
+iptables_protocol() {
local PROTO
PROTO=$1
for proto in tcp udp esp ah; do
IPTABLES_MULTIPORT=1
IPTABLES_PORTRANGE=2
-function _iptables_port_range() {
+_iptables_port_range() {
grep -q ":" <<< $@
}
-function _iptables_port_multiport() {
+_iptables_port_multiport() {
grep -q "," <<< $@
}
-function _iptables_port() {
+_iptables_port() {
if _iptables_port_range "$@"; then
echo $IPTABLES_PORTRANGE
elif _iptables_port_multiport "$@"; then
fi
}
-function iptables_source_port() {
+iptables_source_port() {
[ -z "$@" ] && return
local type
type=$(_iptables_port $@)
fi
}
-function iptables_destination_port() {
+iptables_destination_port() {
[ -z "$@" ] && return
local type
type=$(_iptables_port $@)
IP_SUPPORTED_PROTOCOLS="${IP_SUPPORTED_PROTOCOLS} ipv4"
-function ipv4_is_valid() {
+ipv4_is_valid() {
ipcalc --ipv4 -c $@ >/dev/null 2>&1
case "$?" in
esac
}
-function ipv4_prefix_is_valid() {
+ipv4_prefix_is_valid() {
local prefix=${1}
isset prefix || return ${EXIT_FALSE}
return ${EXIT_TRUE}
}
-function ipv4_netmask_is_valid() {
+ipv4_netmask_is_valid() {
local netmask="${1}"
# XXX this check could be much better by checking
ipv4_is_valid "${netmask}"
}
-function ipv4_detect_duplicate() {
+ipv4_detect_duplicate() {
local device=${1}
local address=${2}
return ${EXIT_ERROR}
}
-function ipv4_update_neighbours() {
+ipv4_update_neighbours() {
local device=${1}
local address=${2}
( sleep 2; arping -q -U -c 1 -I ${device} ${address} ) >/dev/null 2>&1 </dev/null &
}
-function ipv4_get_netaddress() {
+ipv4_get_netaddress() {
local address=${1}
assert isset address
return ${EXIT_OK}
}
-function ipv4_get_prefix() {
+ipv4_get_prefix() {
local address=${1}
local broadcast=${2}
return ${EXIT_OK}
}
-function ipv4_get_netmask() {
+ipv4_get_netmask() {
local address=${1}
assert isset address
return ${EXIT_OK}
}
-function ipv4_flush_device() {
+ipv4_flush_device() {
#
# Flushes all routes, addresses from the device
# and clears the ARP cache.
return 0
}
-function ipv4_prefix2netmask() {
+ipv4_prefix2netmask() {
local prefix=${1}
shift
esac
}
-function ipv4_netmask2prefix() {
+ipv4_netmask2prefix() {
local netmask="${1}"
assert isset netmask
print "${cidr}"
}
-function ipv4_get_network() {
+ipv4_get_network() {
local network=$(ipv4_get_network_encoded $@)
ipv4_decode ${network}
}
-function ipv4_get_network_encoded() {
+ipv4_get_network_encoded() {
local net=${1}
local prefix=$(ip_get_prefix ${net})
print "%d" $(( ${addr} & ${mask} ))
}
-function ipv4_get_broadcast() {
+ipv4_get_broadcast() {
local broadcast=$(ipv4_get_broadcast_encoded $@)
ipv4_decode ${broadcast}
}
-function ipv4_get_broadcast_encoded() {
+ipv4_get_broadcast_encoded() {
local net=${1}
local prefix=$(ip_get_prefix ${net})
print "%d" $(( $(( ${addr} & ${netmask} )) | ${broadcast} ))
}
-function ipv4_encode() {
+ipv4_encode() {
local addr=${1}
local int=0
print "${int}"
}
-function ipv4_decode() {
+ipv4_decode() {
local int=${1}
local addr=$(( ${int} & 255 ))
print "${addr}"
}
-function ipv4_addr_eq() {
+ipv4_addr_eq() {
local addr1=${1}
assert isset addr1
&& return ${EXIT_TRUE} || return ${EXIT_FALSE}
}
-function ipv4_addr_gt() {
+ipv4_addr_gt() {
local addr1=${1}
assert isset addr1
&& return ${EXIT_TRUE} || return ${EXIT_FALSE}
}
-function ipv4_range() {
+ipv4_range() {
local range=${1}
local first=${1%-*}
_ipv4_range "$(ipv4_encode ${first})" "$(ipv4_encode ${last})"
}
-function _ipv4_range() {
+_ipv4_range() {
local first=${1}
local last=${2}
done
}
-function ipv4_range_explicit() {
+ipv4_range_explicit() {
local range=${1}
local first last
_ipv4_range_explicit "$(ipv4_encode ${first})" "$(ipv4_encode ${last})"
}
-function _ipv4_range_explicit() {
+_ipv4_range_explicit() {
local first=${1}
local last=${2}
done
}
-function ipv4_in_subnet() {
+ipv4_in_subnet() {
local addr=${1}
assert isset addr
return ${EXIT_FALSE}
}
-function ipv4_ttl_valid() {
+ipv4_ttl_valid() {
local ttl="${1}"
isinteger ttl || return ${EXIT_FALSE}
IP_SUPPORTED_PROTOCOLS="${IP_SUPPORTED_PROTOCOLS} ipv6"
-function ipv6_device_autoconf_enable() {
+ipv6_device_autoconf_enable() {
local device="${1}"
assert device_exists "${device}"
ipv6_device_forwarding_disable "${device}"
}
-function ipv6_device_autoconf_disable() {
+ipv6_device_autoconf_disable() {
local device="${1}"
assert device_exists "${device}"
ipv6_device_privacy_extensions_disable "${device}"
}
-function ipv6_device_forwarding_enable() {
+ipv6_device_forwarding_enable() {
local device="${1}"
sysctl_set "net.ipv6.conf.${device}.forwarding" 1
log INFO "Enabled IPv6 forwarding on '${device}'"
}
-function ipv6_device_forwarding_disable() {
+ipv6_device_forwarding_disable() {
local device="${1}"
sysctl_set "net.ipv6.conf.${device}.forwarding" 0
}
# Enable IPv6 RFC3041 privacy extensions if desired
-function ipv6_device_privacy_extensions_enable() {
+ipv6_device_privacy_extensions_enable() {
local device="${1}"
assert device_exists "${device}"
sysctl_set "net.ipv6.conf.${device}.use_tempaddr" 2
}
-function ipv6_device_privacy_extensions_disable() {
+ipv6_device_privacy_extensions_disable() {
local device="${1}"
assert device_exists "${device}"
sysctl_set "net.ipv6.conf.${device}.use_tempaddr" 0
}
-function ipv6_is_valid() {
+ipv6_is_valid() {
ipcalc --ipv6 -c $@ >/dev/null 2>&1
case "$?" in
esac
}
-function ipv6_prefix_is_valid() {
+ipv6_prefix_is_valid() {
local prefix=${1}
assert isset prefix
return ${EXIT_TRUE}
}
-function ipv6_get_prefix() {
+ipv6_get_prefix() {
ip_get_prefix "$@"
}
-function ipv6_split_prefix() {
+ipv6_split_prefix() {
ip_split_prefix "$@"
}
-function ipv6_address_add() {
+ipv6_address_add() {
local address="${1}"
assert isset address
return ${EXIT_OK}
}
-function ipv6_address_del() {
+ipv6_address_del() {
local address="${1}"
local device="${2}"
ip_address_del "${device}" "${address}"
}
-function ipv6_address_flush() {
+ipv6_address_flush() {
local device="${1}"
assert isset device
cmd_quiet ip -6 addr flush dev "${device}" scope global permanent
}
-function ipv6_address_change_lifetime() {
+ipv6_address_change_lifetime() {
local address="${1}"
assert isset address
return ${EXIT_OK}
}
-function ipv6_get_dad_status() {
+ipv6_get_dad_status() {
local address="${1}"
assert isset address
return ${EXIT_DAD_OK}
}
-function ipv6_wait_for_dad() {
+ipv6_wait_for_dad() {
local address="${1}"
assert isset address
return ${EXIT_ERROR}
}
-function ipv6_device_get_addresses() {
+ipv6_device_get_addresses() {
local device="${1}"
assert isset device
shift
list_sort ${addresses}
}
-function ipv6_implode() {
+ipv6_implode() {
local address=${1}
assert isset address
print "${ADDRESS6_IMPL}"
}
-function ipv6_explode() {
+ipv6_explode() {
local address=${1}
assert isset address
print "${ADDRESS6_EXPL}"
}
-function ipv6_addr_eq() {
+ipv6_addr_eq() {
local addr1=${1}
assert isset addr1
&& return ${EXIT_TRUE} || return ${EXIT_FALSE}
}
-function ipv6_addr_gt() {
+ipv6_addr_gt() {
local addr1=${1}
assert isset addr1
return ${EXIT_FALSE}
}
-function ipv6_hash() {
+ipv6_hash() {
local address=${1}
assert isset address
echo "${address//:/}"
}
-function ipv6_get_network() {
+ipv6_get_network() {
local addr=${1}
assert isset addr
print "${PREFIX6}/${prefix}"
}
-function ipv6_6rd_format_address() {
+ipv6_6rd_format_address() {
local isp_prefix="${1}"
assert ipv6_is_valid "${isp_prefix}"
print "${formatted_address}/${prefix}"
}
-function ipv6_6rd_format_client_address() {
+ipv6_6rd_format_client_address() {
local address="${1}"
assert isset address
# Functions for nice handling of lists.
#
-function list_append() {
+list_append() {
local list=${1}
assert isset list
shift
done
}
-function list_append_one() {
+list_append_one() {
assert [ $# -eq 2 ]
local list="${1}"
fi
}
-function list_remove() {
+list_remove() {
local list=${1}
shift
eval "${list}=\"${_list}\""
}
-function list_sort() {
+list_sort() {
local i
for i in $@; do
print "${i}"
print
}
-function list_unique() {
+list_unique() {
local items item
for item in $@; do
# Check if the item has already been processed.
done
}
-function list_match() {
+list_match() {
local match=${1}
shift
return ${EXIT_ERROR}
}
-function list_length() {
+list_length() {
local length=0
local i
}
# Count how often $1 occurs in the list.
-function list_count() {
+list_count() {
local what=${1}
shift
print "${counter}"
}
-function list_join() {
+list_join() {
local list=${1}
local delim=${2}
print "${ret:${#delim}}"
}
-function list_reverse() {
+list_reverse() {
local reversed arg
for arg in $@; do
reversed="${arg} ${reversed}"
return ${EXIT_OK}
}
-function list_head() {
+list_head() {
local arg
for arg in $@; do
print "${arg}"
# #
###############################################################################
-function lock_acquire() {
+lock_acquire() {
local lockfile="${1}"
assert isset lockfile
chmod 600 ${lockfile}
}
-function lock_release() {
+lock_release() {
local lockfile="${1}"
log DEBUG "Releasing lock '${lockfile}'."
LOG_DISABLE_STDOUT=false
fi
-function log() {
+log() {
local level=${1}
shift
local message="$@"
# #
###############################################################################
-function macro_file() {
+macro_file() {
local macro=${1}
assert isset macro
return ${EXIT_ERROR}
}
-function macro_exists() {
+macro_exists() {
local macro=${1}
assert isset macro
&& return ${EXIT_TRUE} || return ${EXIT_FALSE}
}
-function macro_read() {
+macro_read() {
local macro=${1}
assert isset macro
CHAT_ERROR=2
CHAT_TIMEOUT=3
-function modem_chat() {
+modem_chat() {
local answer="OK"
local device
local timeout=2
return ${EXIT_ERROR}
}
-function __modem_chat_process_output() {
+__modem_chat_process_output() {
local answer=${1}
local quiet=${2}
done
}
-function modem_initialize() {
+modem_initialize() {
local device="${1}"
assert isset device
shift
EXIT_SIM_PUK=2
EXIT_SIM_UNKNOWN=3
-function modem_sim_status() {
+modem_sim_status() {
local device=${1}
assert isset device
return ${EXIT_SIM_UNKNOWN}
}
-function modem_sim_unlocked() {
+modem_sim_unlocked() {
local device=${1}
assert isset device
[ ${ret} -eq ${EXIT_SIM_READY} ] && return ${EXIT_TRUE} || return ${EXIT_FALSE}
}
-function modem_sim_locked() {
+modem_sim_locked() {
modem_sim_unlocked $@ && return ${EXIT_FALSE} || return ${EXIT_TRUE}
}
-function modem_sim_unlock() {
+modem_sim_unlock() {
local device=${1}
assert isset device
return ${ret}
}
-function modem_sim_auto_unlock() {
+modem_sim_auto_unlock() {
local device="${1}"
assert isset device
# Returns the vendor of the modem.
# For example: "huawei"
-function modem_get_manufacturer() {
+modem_get_manufacturer() {
local device=${1}
assert isset device
print "${output}"
}
-function modem_get_model() {
+modem_get_model() {
local device=${1}
assert isset device
print "${output}"
}
-function modem_get_software_version() {
+modem_get_software_version() {
local device=${1}
assert isset device
print "${output}"
}
-function modem_get_sim_imsi() {
+modem_get_sim_imsi() {
local device=${1}
assert isset device
modem_chat ${device} "AT+CIMI"
}
-function modem_get_device_imei() {
+modem_get_device_imei() {
local device=${1}
assert isset device
return ${ret}
}
-function modem_is_mobile() {
+modem_is_mobile() {
local device=${1}
assert isset device
EXIT_REG_REGISTERED_ROAMING=4
EXIT_REG_UNKNOWN=5
-function modem_get_network_registration() {
+modem_get_network_registration() {
local device=${1}
assert isset device
modem_get_network_registration ${device}
}
-function modem_set_network_registration() {
+modem_set_network_registration() {
local device=${1}
assert isset device
modem_chat ${device} "AT+CREG=${mode}"
}
-function modem_scan_networks() {
+modem_scan_networks() {
local device=${1}
assert isset device
# XXX the output is not very nice to parse.
}
-function __modem_get_network_operator() {
+__modem_get_network_operator() {
local device=${1}
assert isset device
return ${EXIT_OK}
}
-function modem_get_network_operator() {
+modem_get_network_operator() {
local device=${1}
assert isset device
EXIT_OPMODE_UMTS_WITH_HSDPA_AND_HSUPA=6
EXIT_OPMODE_UNKNOWN=7
-function modem_get_network_mode() {
+modem_get_network_mode() {
local device=${1}
assert isset device
esac
}
-function __modem_get_signal_quality() {
+__modem_get_signal_quality() {
local device=${1}
assert isset device
return ${EXIT_ERROR}
}
-function modem_get_signal_quality() {
+modem_get_signal_quality() {
local device=${1}
assert isset device
return ${EXIT_OK}
}
-function modem_get_bit_error_rate() {
+modem_get_bit_error_rate() {
local device=${1}
assert isset device
# USDD stuff
-function modem_ussd_send_command() {
+modem_ussd_send_command() {
local device="${1}"
assert isset device
return ${ret}
}
-function __modem_ussd_parse_output() {
+__modem_ussd_parse_output() {
local line
while read -r line; do
# Find the expected answer.
return ${EXIT_ERROR}
}
-function modem_ussd_encode() {
+modem_ussd_encode() {
local string="${1}"
assert isset string
print "${output}"
}
-function modem_ussd_decode() {
+modem_ussd_decode() {
local string="${1}"
assert isset string
PHY_DIR="/sys/class/ieee80211"
-function phy_dir() {
+phy_dir() {
local phy=${1}
echo "${PHY_DIR}/${phy}"
}
-function phy_exists() {
+phy_exists() {
local phy=${1}
assert isset phy
[ -d "$(phy_dir ${phy})" ]
}
-function phy_list() {
+phy_list() {
local phy
for phy in $(phy_dir)/*; do
done
}
-function phy_get() {
+phy_get() {
local info="${1}"
local phy
return ${EXIT_OK}
}
-function phy_get_address() {
+phy_get_address() {
local phy=${1}
assert isset phy
print "$(<${path})"
}
-function phy_get_devices() {
+phy_get_devices() {
local phy="${1}"
assert isset phy
# #
###############################################################################
-function port_dir() {
+port_dir() {
echo "${NETWORK_CONFIG_DIR}/ports"
}
-function port_list() {
+port_list() {
local port
for port in $(port_dir)/*; do
port="$(basename "${port}")"
done
}
-function port_list_in_use() {
+port_list_in_use() {
local ports_in_use
# Collect all ports that are attached to a zone
list_sort ${ports_in_use}
}
-function port_list_free() {
+port_list_free() {
local ports_in_use="$(port_list_in_use)"
local port
return ${EXIT_OK}
}
-function port_get_hook() {
+port_get_hook() {
local port=${1}
assert isset port
config_get_hook $(port_file ${port})
}
-function port_config_dir() {
+port_config_dir() {
local port=${1}
print "${RUN_DIR}/ports/${port}"
return ${EXIT_OK}
}
-function port_settings_read() {
+port_settings_read() {
local port="${1}"
assert isset port
HOOK="${hook}"
}
-function port_settings_write() {
+port_settings_write() {
local port="${1}"
assert isset port
shift
settings_write "$(port_file "${port}")" ${args}
}
-function ports_get_all() {
+ports_get_all() {
port_list
}
-function port_file() {
+port_file() {
local port="${1}"
assert isset port
echo "$(port_dir)/${port}"
}
-function port_exists() {
+port_exists() {
local port=${1}
[ -f "${NETWORK_CONFIG_DIR}/ports/${port}" ]
}
-function port_get_hook() {
+port_get_hook() {
local port=${1}
assert isset port
config_get_hook $(port_file ${port})
}
-function port_is_attached() {
+port_is_attached() {
local port=${1}
shift
return ${EXIT_ERROR}
}
-function port_is_up() {
+port_is_up() {
device_is_up $@
}
-function port_new() {
+port_new() {
#local port=${1}
#shift
#
hook_exec port ${hook} new $@
}
-function port_destroy() {
+port_destroy() {
local port=${1}
assert isset port
rm -f $(port_file ${port})
}
-function port_create() {
+port_create() {
port_cmd "create" $@
}
-function port_remove() {
+port_remove() {
local port="${1}"
assert isset port
port_cmd "remove" "${port}"
}
-function port_edit() {
+port_edit() {
port_cmd edit $@
}
-function port_up() {
+port_up() {
port_cmd up $@
}
-function port_down() {
+port_down() {
port_cmd down $@
}
-function port_status() {
+port_status() {
port_cmd status $@
}
-function port_info() {
+port_info() {
port_cmd info $@
}
-function port_cmd() {
+port_cmd() {
local cmd=${1}
local port=${2}
shift 2
hook_exec port ${hook} ${cmd} ${port} $@
}
-function ports_get() {
+ports_get() {
local port
for port in $(port_dir)/*; do
port=$(basename ${port})
done
}
-function port_find_free() {
+port_find_free() {
local pattern=${1}
assert isset pattern
return ${EXIT_ERROR}
}
-function port_get_info() {
+port_get_info() {
local port=${1}
local key=${2}
)
}
-function port_get_parents() {
+port_get_parents() {
local port=${1}
port_get_info ${port} PORT_PARENTS
}
-function port_get_children() {
+port_get_children() {
local port=${1}
port_get_info ${port} PORT_CHILDREN
}
-function port_zone() {
+port_zone() {
# Get name of the zones, this port is configured in.
local port=${1}
shift
return ${EXIT_OK}
}
-function port_hotplug_event() {
+port_hotplug_event() {
local port="${1}"
assert isset port
port_cmd "hotplug" "${port}"
}
-function port_get_slaves() {
+port_get_slaves() {
local port="${1}"
port_settings_read "${port}" \
print "${SLAVES}"
}
-function port_device_is_slave() {
+port_device_is_slave() {
assert [ $# -eq 2 ]
local port="${1}"
list_match "${device}" ${slaves}
}
-function port_get_phy() {
+port_get_phy() {
local port="${1}"
port_settings_read "${port}" \
print "${PHY}"
}
-function port_uses_phy() {
+port_uses_phy() {
assert [ $# -eq 2 ]
local port="${1}"
[ "${port_phy}" = "${phy}" ]
}
-function ports_lowest_address() {
+ports_lowest_address() {
local address
local addresses
# This function monitors the pppd activity.
-function pppd_angel() {
+pppd_angel() {
local device="${1}"
assert isset device
done
}
-function pppd_exec() {
+pppd_exec() {
local device="${1}"
assert isset device
esac
}
-function pppd_start() {
+pppd_start() {
local device="${1}"
assert isset device
service_start "pppd@${device}.service"
}
-function pppd_stop() {
+pppd_stop() {
local device="${1}"
assert isset device
service_stop "pppd@${device}.service"
}
-function pppd_status() {
+pppd_status() {
local device="${1}"
assert isset device
service_status "pppd@${device}.service"
}
-function ppp_common_ip_pre_up() {
+ppp_common_ip_pre_up() {
local zone=${1}
shift
return ${EXIT_OK}
}
-function ppp_common_ipv4_up() {
+ppp_common_ipv4_up() {
local zone=${1}
shift
return ${EXIT_OK}
}
-function ppp_common_ipv4_down() {
+ppp_common_ipv4_down() {
local zone=${1}
shift
return ${EXIT_OK}
}
-function ppp_common_ipv6_up() {
+ppp_common_ipv6_up() {
local zone=${1}
shift
return ${EXIT_OK}
}
-function ppp_common_ipv6_down() {
+ppp_common_ipv6_down() {
local zone=${1}
shift
return ${EXIT_OK}
}
-function ppp_secret() {
+ppp_secret() {
local USER=${1}
local SECRET=${2}
local a
rm -f ${PPP_SECRETS}.tmp
}
-function ppp_accounting() {
+ppp_accounting() {
local zone=${1}
shift
--rcvd="${BYTES_RCVD}" --sent="${BYTES_SENT}"
}
-function pppd_write_config() {
+pppd_write_config() {
local file=${1}; shift
assert isset file
# #
###############################################################################
-function pppoe_server_start() {
+pppoe_server_start() {
local zone=${1}
assert isset zone
service_start "pppoe-server@${zone}.service"
}
-function pppoe_server_stop() {
+pppoe_server_stop() {
local zone=${1}
assert isset zone
service_stop "pppoe-server@${zone}.service"
}
-function pppoe_server_status() {
+pppoe_server_status() {
local zone=${1}
assert isset zone
service_status "pppoe-server@${zone}.service"
}
-function pppoe_server_options() {
+pppoe_server_options() {
local file=${1}
assert isset file
return ${EXIT_OK}
}
-function pppoe_server_poolfile() {
+pppoe_server_poolfile() {
local file=${1}
assert isset file
RADVD_CONFIGFILE="/etc/radvd.conf"
-function radvd_update() {
+radvd_update() {
# (Re-)write the configuration file
radvd_write_config
service_reload radvd
}
-function radvd_write_config() {
+radvd_write_config() {
config_header "radv daemon configuration file" > ${RADVD_CONFIGFILE}
# Write the configuration for all zones.
return ${EXIT_OK}
}
-function __radvd_config_interface() {
+__radvd_config_interface() {
local zone=${1}
assert isset zone
print
}
-function __radvd_config_dns() {
+__radvd_config_dns() {
local zone=${1}
# Do nothing, when this option is not enabled.
# Functions for static routing.
#
-function route_init() {
+route_init() {
# Apply configured static routes.
route_apply
}
init_register route_init
-function route_add() {
+route_add() {
local ${NETWORK_CONFIG_ROUTES_PARAMS}
while [ $# -gt 0 ]; do
return ${EXIT_OK}
}
-function route_remove() {
+route_remove() {
local _network=${1}
assert isset _network
return ${EXIT_OK}
}
-function route_list() {
+route_list() {
local protocol
while [ $# -gt 0 ]; do
done < ${NETWORK_CONFIG_ROUTES}
}
-function route_find_duplicate() {
+route_find_duplicate() {
local _network=${1}
[ -r "${NETWORK_CONFIG_ROUTES}" ] || return ${EXIT_FALSE}
return ${EXIT_FALSE}
}
-function route_parse_line() {
+route_parse_line() {
local arg
# Reset all possible settings.
return ${EXIT_OK}
}
-function route_apply() {
+route_apply() {
local table="static"
local type
route_rule_add --lookup="static" --priority=1000
}
-function route_entry_add() {
+route_entry_add() {
local gateway
local network
local proto
cmd_quiet "${command}"
}
-function route_table_create() {
+route_table_create() {
local table=${1}
assert isset table
return ${EXIT_OK}
}
-function _route_table_next_id() {
+_route_table_next_id() {
# The Linux kernel is able to manage 255 routing tables (1-255).
# This function returns the next free id, starting from 255.
local next_id
return ${EXIT_FALSE}
}
-function route_table_flush() {
+route_table_flush() {
local protocol
local table
return ${EXIT_OK}
}
-function route_table_exists() {
+route_table_exists() {
local _id _table
while [ $# -gt 0 ]; do
return ${EXIT_FALSE}
}
-function route_rule_add() {
+route_rule_add() {
local priority
local protocols=${IP_SUPPORTED_PROTOCOLS}
local lookup
done
}
-function route_rule_exists() {
+route_rule_exists() {
local from
local lookup
local proto
return ${EXIT_FALSE}
}
-function _route_rule_exists_parse() {
+_route_rule_exists_parse() {
# Reset all variables.
_lookup=
_from=
# #
###############################################################################
-function routing_has_default() {
+routing_has_default() {
ip route | grep -q "^default"
}
-function routing_default_update() {
+routing_default_update() {
local routes
local zones=$(zones_get_nonlocal)
}
# XXX deprecated function
-function routing_table_exists() {
+routing_table_exists() {
route_table_exists $@
}
# XXX deprecated function
-function routing_table_create() {
+routing_table_create() {
route_table_create $@
}
-function routing_db_path() {
+routing_db_path() {
local zone=${1}
local proto=${2}
echo "${ROUTING_DB_DIR}/${zone}/${proto}"
}
-function routing_db_exists() {
+routing_db_exists() {
[ -d "$(routing_db_path $@)" ]
}
-function routing_db_create() {
+routing_db_create() {
routing_db_exists $@ && return ${EXIT_OK}
mkdir -p $(routing_db_path $@)
}
-function routing_db_remove() {
+routing_db_remove() {
rm -rf $(routing_db_path $@)
}
-function routing_db_set() {
+routing_db_set() {
local zone=${1}
local proto=${2}
local parameter=${3}
echo "${value}" > $(routing_db_path ${zone} ${proto})/${parameter}
}
-function routing_db_get() {
+routing_db_get() {
local zone=${1}
local proto=${2}
local parameter=${3}
cat $(routing_db_path ${zone} ${proto})/${parameter} 2>/dev/null
}
-function routing_db_from_ppp() {
+routing_db_from_ppp() {
local zone=${1}
local proto=${2}
routing_db_set ${zone} ${proto} remote-address ${PPP_MACREMOTE,,}
}
-function routing_update() {
+routing_update() {
local zone=${1}
assert isset zone
# This is a list of baudrates that are supported.
SERIAL_BAUDRATES="921600 460800 230400 115200 57600 38400 19200 9600"
-function serial_list() {
+serial_list() {
local device
for device in /dev/ttyUSB*; do
if serial_exists "${device}"; then
done
}
-function serial_exists() {
+serial_exists() {
local device=${1}
[ -c "${device}" ]
}
-function serial_is_locked() {
+serial_is_locked() {
local device=${1}
assert isset device
return ${EXIT_FALSE}
}
-function serial_is_unlocked() {
+serial_is_unlocked() {
serial_is_locked ${device} \
&& return ${EXIT_FALSE} || return ${EXIT_TRUE}
}
-function serial_is_modem() {
+serial_is_modem() {
local device=${1}
assert isset device
esac
}
-function serial_get_bus_type() {
+serial_get_bus_type() {
local device="${1}"
assert isset device
# #
###############################################################################
-function service_start() {
+service_start() {
local name=${1}
assert isset name
return ${ret}
}
-function service_stop() {
+service_stop() {
local name="${1}"
assert isset name
systemctl stop "${name}"
}
-function service_restart() {
+service_restart() {
local name="${1}"
assert isset name
systemctl restart "${name}"
}
-function service_reload() {
+service_reload() {
local name="${1}"
assert isset name
fi
}
-function service_status() {
+service_status() {
local name="${1}"
assert isset name
# This function calls the "enable" command from systemd,
# to mark services to be automatically started during
# boot up.
-function service_enable() {
+service_enable() {
local name="${1}"
assert isset name
# This function calls the "disable" command of systemd,
# to drop the autostart ability of the service during the
# boot up.
-function service_disable() {
+service_disable() {
local name="${1}"
assert isset name
# This function uses the systemd command "is-enabled" to check,
# if a service has been enabled or not.
-function service_is_enabled() {
+service_is_enabled() {
local name="${1}"
assert isset name
return $?
}
-function service_is_active() {
+service_is_active() {
local name="${1}"
assert isset name
return $?
}
-function service_get_exitcode() {
+service_get_exitcode() {
local name=${1}
assert isset name
# #
###############################################################################
-function settings_read() {
+settings_read() {
local file="${1}"
assert isset file
shift
done < ${file}
}
-function settings_read_array() {
+settings_read_array() {
local file=${1}
assert isset file
shift
}
# Strip leading and trailing "s.
-function settings_strip() {
+settings_strip() {
local var="$@"
# Do nothing for strings that contain spaces.
unquote "${var}"
}
-function settings_write() {
+settings_write() {
local settings_file="${1}"
assert isset settings_file
shift
done
}
-function settings_remove() {
+settings_remove() {
local settings_file="${1}"
local abspath="$(readlink -e "${settings_file}")"
rm -f "${settings_file}"
}
-function settings_print() {
+settings_print() {
local param
for param in $(listsort $@); do
done
}
-function settings_check() {
+settings_check() {
local check_func="${1}"
# Execute the check function
return ${EXIT_ERROR}
}
-function settings_set() {
+settings_set() {
while [ $# -gt 0 ]; do
case "${1}" in
*=*)
done
}
-function network_settings_read() {
+network_settings_read() {
local options="${NETWORK_SETTINGS_FILE_PARAMS}"
# If the DEBUG variable has already been set,
settings_read "${NETWORK_SETTINGS_FILE}" ${options}
}
-function network_settings_write() {
+network_settings_write() {
settings_write "${NETWORK_SETTINGS_FILE}" ${NETWORK_SETTINGS_FILE_PARAMS}
# Update DNS configuration.
dns_generate_resolvconf
}
-function network_settings_print() {
+network_settings_print() {
settings_print ${NETWORK_SETTINGS_FILE_PARAMS}
}
-function network_settings_list() {
+network_settings_list() {
print "${NETWORK_SETTINGS_FILE_PARAMS}"
}
-function firewall_settings_read() {
+firewall_settings_read() {
settings_read "${FIREWALL_SETTINGS_FILE}" "${FIREWALL_SETTINGS_PARAMS}"
}
-function firewall_settings_write() {
+firewall_settings_write() {
settings_write "${FIREWALL_SETTINGS_FILE}" "${FIREWALL_SETTINGS_PARAMS}"
}
-function firewall_settings_print() {
+firewall_settings_print() {
settings_print "${FIREWALL_SETTINGS_PARAMS}"
}
# Allowed modes of the spanning tree protocol.
STP_ALLOWED_MODES="rstp stp"
-function stp_enable() {
+stp_enable() {
local bridge=${1}
assert isset bridge
print 1 > ${SYS_CLASS_NET}/${bridge}/bridge/stp_state
}
-function stp_disable() {
+stp_disable() {
local bridge=${1}
assert isset bridge
print 0 > ${SYS_CLASS_NET}/${bridge}/bridge/stp_state
}
-function stp_is_enabled() {
+stp_is_enabled() {
local bridge=${1}
assert isset bridge
esac
}
-function stp_is_userspace() {
+stp_is_userspace() {
local bridge=${1}
assert isset bridge
esac
}
-function stp_get_name() {
+stp_get_name() {
local proto=${1}
case "${proto}" in
return ${EXIT_OK}
}
-function stp_bridge_set_protocol() {
+stp_bridge_set_protocol() {
local bridge=${1}
assert isset bridge
assert [ $? -eq 0 ]
}
-function stp_bridge_get_protocol() {
+stp_bridge_get_protocol() {
local bridge=${1}
assert isset bridge
return ${EXIT_OK}
}
-function stp_bridge_get_id() {
+stp_bridge_get_id() {
local bridge=${1}
assert isset bridge
return $?
}
-function stp_bridge_get_forward_delay() {
+stp_bridge_get_forward_delay() {
local bridge=${1}
assert isset bridge
return ${EXIT_OK}
}
-function stp_bridge_set_forward_delay() {
+stp_bridge_set_forward_delay() {
local bridge=${1}
assert isset bridge
return ${EXIT_OK}
}
-function stp_bridge_get_hello_time() {
+stp_bridge_get_hello_time() {
local bridge=${1}
assert isset bridge
return ${EXIT_OK}
}
-function stp_bridge_set_hello_time() {
+stp_bridge_set_hello_time() {
local bridge=${1}
assert isset bridge
return ${EXIT_OK}
}
-function stp_bridge_get_max_age() {
+stp_bridge_get_max_age() {
local bridge=${1}
assert isset bridge
return ${EXIT_OK}
}
-function stp_bridge_set_max_age() {
+stp_bridge_set_max_age() {
local bridge=${1}
assert isset bridge
return ${EXIT_OK}
}
-function stp_bridge_get_priority() {
+stp_bridge_get_priority() {
local bridge=${1}
assert isset bridge
return ${EXIT_OK}
}
-function stp_bridge_set_priority() {
+stp_bridge_set_priority() {
local bridge=${1}
assert isset bridge
return ${EXIT_OK}
}
-function stp_bridge_get_designated_root() {
+stp_bridge_get_designated_root() {
local bridge=${1}
assert isset bridge
fi
}
-function stp_bridge_get_root_path_cost() {
+stp_bridge_get_root_path_cost() {
local bridge=${1}
assert isset bridge
return ${EXIT_OK}
}
-function stp_bridge_get_root_port_id() {
+stp_bridge_get_root_port_id() {
local bridge=${1}
assert isset bridge
return ${EXIT_OK}
}
-function stp_bridge_get_root_port() {
+stp_bridge_get_root_port() {
local bridge=${1}
assert isset bridge
return ${EXIT_ERROR}
}
-function stp_bridge_is_root() {
+stp_bridge_is_root() {
local bridge=${1}
assert isset bridge
return ${EXIT_FALSE}
}
-function stp_bridge_get_topology_change_count() {
+stp_bridge_get_topology_change_count() {
local bridge=${1}
assert isset bridge
return ${EXIT_OK}
}
-function stp_bridge_get_topology_change_timer() {
+stp_bridge_get_topology_change_timer() {
local bridge=${1}
assert isset bridge
return ${EXIT_OK}
}
-function stp_bridge_get_topology_change_detected() {
+stp_bridge_get_topology_change_detected() {
local bridge=${1}
assert isset bridge
fi
}
-function stp_port_get_state() {
+stp_port_get_state() {
local bridge=${1}
assert isset bridge
return ${EXIT_OK}
}
-function stp_port_get_id() {
+stp_port_get_id() {
local bridge=${1}
assert isset bridge
return ${EXIT_OK}
}
-function stp_port_get_cost() {
+stp_port_get_cost() {
local bridge=${1}
assert isset bridge
return ${EXIT_ERROR}
}
-function stp_port_set_cost() {
+stp_port_set_cost() {
assert [ $# -eq 3 ]
local bridge="${1}"
fi
}
-function stp_port_get_designated_root() {
+stp_port_get_designated_root() {
local bridge=${1}
assert isset bridge
return ${EXIT_ERROR}
}
-function __stp_div_100() {
+__stp_div_100() {
local val=${1}
local split=$((${#val} - 2))
SYSCTL_PATH="/proc/sys"
-function sysctl_key_to_path() {
+sysctl_key_to_path() {
local key="${1}"
assert isset key
return ${EXIT_OK}
}
-function sysctl_key_exists() {
+sysctl_key_exists() {
local key="${1}"
assert isset key
return ${EXIT_ERROR}
}
-function sysctl_get() {
+sysctl_get() {
local key="${1}"
assert isset key
return ${EXIT_OK}
}
-function sysctl_set() {
+sysctl_set() {
local key="${1}"
assert isset key
return ${EXIT_OK}
}
-function sysctl_set_bool() {
+sysctl_set_bool() {
local key="${1}"
local value="${2}"
sysctl_set "${key}" "${value}"
}
-function sysctl_set_recursively() {
+sysctl_set_recursively() {
local basekey="${1}"
assert isset basekey
# #
###############################################################################
-function usb_device_find_by_tty() {
+usb_device_find_by_tty() {
local tty="${1}"
assert isset tty
return ${EXIT_OK}
}
-function usb_device_list_interfaces() {
+usb_device_list_interfaces() {
local path="${1}"
assert [ -d "${path}" ]
return ${EXIT_OK}
}
-function usb_device_get_interface_type() {
+usb_device_get_interface_type() {
local interface="${1}"
assert isset interface
fread "${interface}/type"
}
-function usb_device_has_interface_type_interrupt() {
+usb_device_has_interface_type_interrupt() {
local device="${1}"
assert isset device
###############################################################################
# A simple print statement
-function print() {
+print() {
local fmt=${1}; shift
printf -- "${fmt}\n" "$@"
# The args() function takes a number of arguments like
# var1="abc d" var2="abc" var3="abcd e"
# and splits them into several arguments, devided by newline
-function args() {
+args() {
echo "$@" | xargs printf "%s\n"
}
-function unquote() {
+unquote() {
local var="$@"
if [ "${var:0:1}" = "\"" ]; then
print "${var}"
}
-function quote() {
+quote() {
print "\"%s\"" "$@"
}
-function strip() {
+strip() {
local value="$@"
# remove leading whitespace characters
}
# Print a pretty error message
-function error() {
+error() {
echo -e " ${CLR_RED_B}ERROR${CLR_RESET} : $@" >&2
}
-function error_log() {
+error_log() {
log ERROR "$@"
}
# Print a pretty warn message
-function warning() {
+warning() {
echo -e " ${CLR_YELLOW_B}WARNING${CLR_RESET}: $@" >&2
}
-function warning_log() {
+warning_log() {
log WARNING "$@"
}
# The next three functions are kept for backwards
# compatibility. The need to be dropped at some time.
-function listsort() {
+listsort() {
list_sort $@
}
-function listmatch() {
+listmatch() {
list_match $@
}
-function listlength() {
+listlength() {
list_length $@
}
# Speedup function to avoid a call of the basename binary
-function basename() {
+basename() {
echo "${1##*/}"
}
-function format() {
+format() {
local key=${1}
assert isset key
printf -v "${key}" "${format}" "$@"
}
-function assign() {
+assign() {
local key=${1}
assert isset key
shift
format "${key}" "%s" "$@"
}
-function fread() {
+fread() {
local file=${1}
assert isset file
print "$(<${file})"
}
-function fwrite() {
+fwrite() {
local file=${1}
assert isset file
shift
print "%s" "$@" >> ${file} 2>/dev/null
}
-function enabled() {
+enabled() {
local param=${1}
list_match "${!param}" yes on true 1
}
-function mac_generate() {
+mac_generate() {
# Get a bunch of random hex digits
# and remove all dashes from the input.
local random=$(</proc/sys/kernel/random/uuid)
echo "${output}"
}
-function mac_format() {
+mac_format() {
local mac=${1}
assert isset mac
print "${output}"
}
-function mac_is_valid() {
+mac_is_valid() {
local mac=${1}
[[ ${mac} =~ ^([0-9a-f]{2}\:){5}[0-9a-f]{2}$ ]]
}
-function uuid() {
+uuid() {
echo $(</proc/sys/kernel/random/uuid)
}
-function isset() {
+isset() {
local var=${1}
[ -n "${!var}" ]
}
-function isoneof() {
+isoneof() {
local var=${!1}
shift
list_match "${var}" "$@"
}
-function isbool() {
+isbool() {
local var=${1}
isoneof ${var} 0 1 no yes on off
}
-function isinteger() {
+isinteger() {
local var=${!1}
[[ ${var} =~ ^[0-9]+$ ]]
}
-function ismac() {
+ismac() {
local mac=${!1}
mac_is_valid ${mac}
}
-function isipaddress() {
+isipaddress() {
local addr=${!1}
ip_is_valid ${addr}
}
-function backtrace() {
+backtrace() {
local start=1
echo # Empty line
done
}
-function assert() {
+assert() {
local assertion="$@"
if ! ${assertion}; then
# This function checks, if the given argument is an assert error
# exit code. If this is the case, the script will halt immediately.
-function assert_check_retval() {
+assert_check_retval() {
local ret=${1}
if [ ${ret} -eq ${EXIT_ERROR_ASSERT} ]; then
return ${ret}
}
-function exec_cmd() {
+exec_cmd() {
local cmd=$@
log DEBUG "Running command: ${cmd}"
return ${ret}
}
-function cmd() {
+cmd() {
local cmd=$@
log DEBUG "Running command: ${cmd}"
return ${ret}
}
-function cmd_quiet() {
+cmd_quiet() {
cmd $@ &>/dev/null
}
-function cmd_exec() {
+cmd_exec() {
local cmd=$@
log DEBUG "Exec'ing command: ${cmd}"
exit ${EXIT_ERROR}
}
-function cmd_not_implemented() {
+cmd_not_implemented() {
assert false "not implemented"
}
# Increase security of the read command
-function read() {
+read() {
builtin read -r $@
}
-function seq() {
+seq() {
if [ $# -eq 2 ]; then
eval echo {${1}..${2}}
elif [ $# -eq 3 ]; then
fi
}
-function which() {
+which() {
type -P $@
}
# Prints the number of seconds since epoch.
-function timestamp() {
+timestamp() {
date -u "+%s"
}
-function beautify_time() {
+beautify_time() {
local value=${1}
local unit
echo "${value}${unit}"
}
-function beautify_bytes() {
+beautify_bytes() {
local value=${1}
local unit
echo "${value}${unit}"
}
-function module_load() {
+module_load() {
local module=${1}
if ! grep -q "^${module}" /proc/modules; then
fi
}
-function binary_exists() {
+binary_exists() {
local binary=${1}
if [ -n "$(type -p ${binary})" ]; then
return ${EXIT_ERROR}
}
-function function_exists() {
+function_exists() {
local function="${1}"
if [ "$(type -t "${function}")" = "function" ]; then
return ${EXIT_FALSE}
}
-function process_kill() {
+process_kill() {
local process=${1}
if ! isinteger process; then
done
}
-function dec() {
+dec() {
local hex=${1}
if [ "${hex:0:2}" != "0x" ]; then
printf "%d\n" "${hex}"
}
-function chr() {
+chr() {
local char="${1}"
[ ${char} -lt 256 ] || return ${EXIT_ERROR}
printf "\\$(( ${char} / 64 * 100 + ${char} % 64 / 8 * 10 + ${char} % 8 ))\n"
}
-function ord() {
+ord() {
LC_CTYPE="C" printf "%d\n" "'${1}"
}
-function hex() {
+hex() {
printf "%X\n" "${1}"
}
-function network_is_running() {
+network_is_running() {
# Check, if the network service is running.
service_is_active network
}
-function contains_spaces() {
+contains_spaces() {
local var="$@"
# Eliminate spaces.
return ${EXIT_FALSE}
}
-function string_split() {
+string_split() {
local string="$@"
local pos=0
return ${EXIT_OK}
}
-function string_reverse() {
+string_reverse() {
local string="$@"
local output
return ${EXIT_OK}
}
-function dec2bin() {
+dec2bin() {
local number="${1}"
local output
print "${output}"
}
-function bin2dec() {
+bin2dec() {
local string="${1}"
local number=0
return ${EXIT_OK}
}
-function char2bin() {
+char2bin() {
local dec="$(ord "${1}")"
dec2bin "${dec}"
}
-function bin2char() {
+bin2char() {
local dec="$(bin2dec "$@")"
chr "${dec}"
}
-function bin2hex() {
+bin2hex() {
local dec="$(bin2dec "$@")"
dec2hex "${dec}"
}
-function hex2bin() {
+hex2bin() {
local dec="$(hex2dec "$@")"
dec2bin "${dec}"
}
-function hex2dec() {
+hex2dec() {
local hex="${1}"
# Prepend 0x if necessary.
printf "%d\n" "${hex}"
}
-function dec2hex() {
+dec2hex() {
printf "%02x\n" "${1}"
}
VLAN_PORT_INTERFIX="v"
-function vlan_init() {
+vlan_init() {
ebtables-restore <<EOF
*filter
:INPUT ACCEPT
EOF
}
-function vlan_create() {
+vlan_create() {
local device=${1}
assert isset device
return ${ret}
}
-function vlan_remove() {
+vlan_remove() {
local device=${1}
assert isset device
device_delete ${device}
}
-function vlan_get_parent() {
+vlan_get_parent() {
local device=${1}
assert isset device
return ${EXIT_ERROR}
}
-function vlan_get_id() {
+vlan_get_id() {
local device=${1}
assert isset device
return ${EXIT_ERROR}
}
-function vlan_get_by_parent_and_vid() {
+vlan_get_by_parent_and_vid() {
local parent=${1}
assert isset parent
WIRELESS_REGULATORY_DOMAIN="00"
NETWORK_SETTINGS_FILE_PARAMS="${NETWORK_SETTINGS_FILE_PARAMS} WIRELESS_REGULATORY_DOMAIN"
-function wireless_create() {
+wireless_create() {
local device=${1}
assert isset device
shift
return ${ret}
}
-function wireless_remove() {
+wireless_remove() {
local device=${1}
assert isset device
return ${ret}
}
-function wireless_get_reg_domain() {
+wireless_get_reg_domain() {
# Returns the country code for the wireless device.
# Defaults to 00 = world if unset.
print "${WIRELESS_REGULATORY_DOMAIN:-00}"
}
-function wireless_init_reg_domain() {
+wireless_init_reg_domain() {
local country_code="$(wireless_get_reg_domain)"
wireless_set_reg_domain "${country_code}" --no-reset
}
-function wireless_set_reg_domain() {
+wireless_set_reg_domain() {
local country_code
local reset="true"
iw reg set "${country_code}"
}
-function wireless_channel_to_frequency() {
+wireless_channel_to_frequency() {
# http://en.wikipedia.org/wiki/List_of_WLAN_channels
local channel=${1}
return ${EXIT_ERROR}
}
-function wireless_set_channel() {
+wireless_set_channel() {
local device=${1}
assert isset device
cmd_quiet iw dev ${device} set channel ${channel}
}
-function wireless_ibss_join() {
+wireless_ibss_join() {
local device=${1}
assert isset device
shift
"${frequency}" fixed-freq "${bssid}"
}
-function wireless_ibss_leave() {
+wireless_ibss_leave() {
local device=${1}
assert isset device
cmd_quiet iw dev "${device}" ibss leave
}
-function wireless_is_radar_frequency() {
+wireless_is_radar_frequency() {
local frequency="${1}"
assert isset frequency
[[ ${frequency} -ge 5260 ]] && [[ ${frequency} -le 5700 ]]
}
-function wireless_monitor() {
+wireless_monitor() {
local device="${1}"
assert isset device
shift
WPA_SUPPLICANT_SOCKET_DIR="${RUN_DIR}/wpa_supplicant/ctrl"
-function wpa_supplicant_config_write() {
+wpa_supplicant_config_write() {
local device=${1}
assert isset device
return ${EXIT_OK}
}
-function wpa_supplicant_config_dir() {
+wpa_supplicant_config_dir() {
local device=${1}
assert isset device
echo "${RUN_DIR}/wpa_supplicant/${device}"
}
-function wpa_supplicant_start() {
+wpa_supplicant_start() {
local device=${1}
assert isset device
service_start "wpa_supplicant@${device}.service"
}
-function wpa_supplicant_stop() {
+wpa_supplicant_stop() {
local device=${1}
assert isset device
service_stop "wpa_supplicant@${device}.service"
}
-function wpa_supplicant_client() {
+wpa_supplicant_client() {
local device=${1}
assert isset device
shift
cmd wpa_cli -p${WPA_SUPPLICANT_SOCKET_DIR} -i${device} ${cmd}
}
-function wpa_cli_status() {
+wpa_cli_status() {
local device=${1}
assert isset device
wpa_supplicant_client ${device} status verbose
}
-function wpa_cli_status_get() {
+wpa_cli_status_get() {
local device=${1}
assert isset device
return ${EXIT_ERROR}
}
-function wpa_cli_bss() {
+wpa_cli_bss() {
local device=${1}
assert isset device
wpa_supplicant_client ${device} bss ${bss}
}
-function wpa_cli_bss_get() {
+wpa_cli_bss_get() {
local device=${1}
assert isset device
return ${EXIT_ERROR}
}
-function wpa_cli_bss_get_frequency() {
+wpa_cli_bss_get_frequency() {
local device=${1}
assert isset device
wpa_cli_bss_get ${device} ${bssid} freq
}
-function wpa_cli_bss_get_noise() {
+wpa_cli_bss_get_noise() {
local device=${1}
assert isset device
wpa_cli_bss_get ${device} ${bssid} noise
}
-function wpa_cli_bss_get_quality() {
+wpa_cli_bss_get_quality() {
local device=${1}
assert isset device
wpa_cli_bss_get ${device} ${bssid} qual
}
-function wpa_cli_bss_get_flags() {
+wpa_cli_bss_get_flags() {
local device=${1}
assert isset device
# #
###############################################################################
-function zone_dir() {
+zone_dir() {
local zone=${1}
echo "${NETWORK_ZONE_DIR}/zones/${zone}"
}
-function zone_exists() {
+zone_exists() {
local zone=${1}
assert isset zone
[ -d "$(zone_dir ${zone})" ]
}
-function zone_match() {
+zone_match() {
local match
local i
echo "${match:1:${#match}}"
}
-function zone_name_is_valid() {
+zone_name_is_valid() {
local zone=${1}
# Don't accept empty strings.
[[ ${zone} =~ $(zone_match) ]]
}
-function zone_is_local() {
+zone_is_local() {
local zone=${1}
[[ "${zone:0:${#ZONE_LOCAL}}" = "${ZONE_LOCAL}" ]]
}
-function zone_is_nonlocal() {
+zone_is_nonlocal() {
local zone=${1}
[[ "${zone:0:${#ZONE_NONLOCAL}}" = "${ZONE_NONLOCAL}" ]]
}
-function zone_get_hook() {
+zone_get_hook() {
local zone=${1}
assert isset zone
config_get_hook $(zone_dir ${zone})/settings
}
-function zone_start() {
+zone_start() {
# This function will bring up the zone
# 'asynchronously' with help of systemd.
service_start "network@${zone}.service"
}
-function zone_start_auto() {
+zone_start_auto() {
local zone="${1}"
assert zone_exists "${zone}"
return ${EXIT_OK}
}
-function zone_stop() {
+zone_stop() {
# This function will bring down the zone
# 'asynchronously' with help of systemd.
service_stop "network@${zone}.service"
}
-function zone_reload() {
+zone_reload() {
local zone="${1}"
assert zone_exists "${zone}"
service_reload "network@${zone}.service"
}
-function zone_hotplug_event() {
+zone_hotplug_event() {
local zone="${1}"
assert isset zone
zone_cmd "hotplug" "${zone}"
}
-function zone_enable() {
+zone_enable() {
# This function will enable the zone
# with help of systemd.
return ${ret}
}
-function zone_disable() {
+zone_disable() {
# This function will disable the zone
# with help of systemd.
return ${ret}
}
-function zone_is_enabled() {
+zone_is_enabled() {
local zone="${1}"
assert isset zone
return ${EXIT_FALSE}
}
-function zone_is_active() {
+zone_is_active() {
local zone="${1}"
assert isset zone
return ${EXIT_FALSE}
}
-function zone_is_enabled_or_active() {
+zone_is_enabled_or_active() {
local zone="${1}"
assert isset zone
zone_is_enabled "${zone}" || zone_is_active "${zone}"
}
-function zone_cmd() {
+zone_cmd() {
local cmd="${1}"
local port="${2}"
shift 2
hook_exec zone "${hook}" "${cmd}" "${zone}" $@
}
-function zone_new() {
+zone_new() {
local zone=${1}
local hook=${2}
shift 2
zone_start "${zone}"
}
-function zone_edit() {
+zone_edit() {
local zone=${1}
shift
}
-function zone_destroy() {
+zone_destroy() {
local zone="${1}"
assert zone_exists "${zone}"
log INFO "Zone '${zone}' has been tagged for removal."
}
-function zone_has_destroy_tag() {
+zone_has_destroy_tag() {
local zone="${1}"
assert zone_exists "${zone}"
# This function will remove the given zone
# RIGHT NOW. Use zone_destroy to remove it
# at the next status change.
-function zone_destroy_now() {
+zone_destroy_now() {
local zone="${1}"
assert zone_exists "${zone}"
rm -rf "$(zone_dir "${zone}")"
}
-function zone_up() {
+zone_up() {
local zone=${1}
shift
zone_db ${zone} started
}
-function zone_down() {
+zone_down() {
local zone=${1}
shift
fi
}
-function zone_status() {
+zone_status() {
local zone="${1}"
assert isset zone
shift
fi
}
-function zone_get_ports() {
+zone_get_ports() {
local zone=${1}
assert isset zone
done
}
-function zone_get_ports_num() {
+zone_get_ports_num() {
local zone="${1}"
assert isset zone
return ${EXIT_OK}
}
-function zone_has_port() {
+zone_has_port() {
# Check, if the given port is configured
# in this zone.
[ -e "$(zone_dir ${zone})/ports/${port}" ]
}
-function zone_config() {
+zone_config() {
local zone="${1}"
local cmd="${2}"
shift 2
esac
}
-function zone_config_cmd() {
+zone_config_cmd() {
assert [ $# -gt 2 ]
local cmd="${1}"
hook_zone_exec "${hook}" "config_${cmd}" "${zone}" "$@"
}
-function zone_config_create() {
+zone_config_create() {
zone_config_cmd "create" "$@"
}
-function zone_config_edit() {
+zone_config_edit() {
zone_config_cmd "edit" "$@"
}
-function zone_config_remove() {
+zone_config_remove() {
zone_config_cmd "remove" "$@"
}
-function zone_config_show() {
+zone_config_show() {
zone_config_cmd "show" "$@"
}
-function zone_show() {
+zone_show() {
local zone=${1}
echo "${zone}"
echo
}
-function zones_show() {
+zones_show() {
local zone
for zone in $(zones_get $@); do
done
}
-function zones_get_all() {
+zones_get_all() {
local zone
for zone in $(zone_dir)/*; do
zone=$(basename ${zone})
done
}
-function zones_get_local() {
+zones_get_local() {
local zone
for zone in $(zones_get_all); do
zone_is_local ${zone} && echo "${zone}"
done
}
-function zones_get_nonlocal() {
+zones_get_nonlocal() {
local zone
for zone in $(zones_get_all); do
zone_is_nonlocal ${zone} && echo "${zone}"
done
}
-function zones_get() {
+zones_get() {
local local=1
local remote=1
fi
}
-function zone_ports_list() {
+zone_ports_list() {
local zone=${1}
local port
done
}
-function zone_port_attach() {
+zone_port_attach() {
local zone="${1}"
assert isset zone
return ${ret}
}
-function zone_port_edit() {
+zone_port_edit() {
local zone="${1}"
assert isset zone
hook_zone_exec "${hook}" "port_edit" "${zone}" "${port}" "$@"
}
-function zone_port_detach() {
+zone_port_detach() {
local zone="${1}"
assert isset zone
return ${ret}
}
-function zone_port_cmd() {
+zone_port_cmd() {
local cmd="${1}"
assert isset cmd
hook_zone_exec "${hook}" "${cmd}" "${zone}" "${port}" $@
}
-function zone_port_create() {
+zone_port_create() {
zone_port_cmd "port_create" $@
}
-function zone_port_remove() {
+zone_port_remove() {
zone_port_cmd "port_remove" $@
}
-function zone_port_up() {
+zone_port_up() {
zone_port_cmd "port_up" $@
}
-function zone_port_down() {
+zone_port_down() {
zone_port_cmd "port_down" $@
}
# and therefore do not dispatch a hotplug event when
# port_create is called.
-function zone_port_start() {
+zone_port_start() {
local zone="${1}"
local port="${2}"
return ${EXIT_OK}
}
-function zone_port_stop() {
+zone_port_stop() {
local zone="${1}"
local port="${2}"
zone_port_remove "${zone}" "${port}"
}
-function zone_port_status() {
+zone_port_status() {
zone_port_cmd "port_status" $@
}
-function zone_ports_cmd() {
+zone_ports_cmd() {
local cmd="${1}"
assert isset cmd
done
}
-function zone_ports_create() {
+zone_ports_create() {
zone_ports_cmd "port_create" $@
}
-function zone_ports_remove() {
+zone_ports_remove() {
zone_ports_cmd "port_remove" $@
}
-function zone_ports_up() {
+zone_ports_up() {
zone_ports_cmd "port_up" $@
}
-function zone_ports_down() {
+zone_ports_down() {
zone_ports_cmd "port_down" $@
}
-function zone_ports_status() {
+zone_ports_status() {
zone_ports_cmd "port_status" $@
}
-function zone_configs_cmd() {
+zone_configs_cmd() {
assert [ $# -ge 2 ]
local cmd="${1}"
done
}
-function zone_configs_up() {
+zone_configs_up() {
zone_configs_cmd "up" $@
}
-function zone_configs_down() {
+zone_configs_down() {
zone_configs_cmd "down" $@
}
-function zone_configs_status() {
+zone_configs_status() {
zone_configs_cmd "status" $@
}
-function zone_configs_list() {
+zone_configs_list() {
local zone=${1}
local config
done
}
-function zone_config_get_hook() {
+zone_config_get_hook() {
assert [ $# -eq 2 ]
local zone="${1}"
print "${HOOK}"
}
-function zone_has_ip() {
+zone_has_ip() {
device_has_ip $@
}
-function zone_db() {
+zone_db() {
local zone=${1}
local action=${2}
shift 2
esac
}
-function zone_is_up() {
+zone_is_up() {
local zone=${1}
device_is_up ${zone}
}
-function zone_is_down() {
+zone_is_down() {
! zone_is_up $@
}
-function zone_get_supported_port_hooks() {
+zone_get_supported_port_hooks() {
local zone=${1}
local hook=$(zone_get_hook ${zone})
hook_zone_ports_get_all ${hook}
}
-function zone_get_supported_config_hooks() {
+zone_get_supported_config_hooks() {
hook_config_get_all
}
-function zone_file() {
+zone_file() {
local zone=${1}
assert isset zone
echo "$(zone_dir ${zone})/settings"
}
-function zone_settings_read() {
+zone_settings_read() {
local zone=${1}
assert isset zone
shift
HOOK="${hook}"
}
-function zone_settings_write() {
+zone_settings_write() {
local zone="${1}"
assert isset zone
settings_write "$(zone_file ${zone})" ${args}
}
-function zone_settings_set() {
+zone_settings_set() {
local zone=${1}
shift
local args="$@"
)
}
-function zone_settings_get() {
+zone_settings_get() {
local zone=${1}
local key=${2}
)
}
-function zone_config_settings_read() {
+zone_config_settings_read() {
assert [ $# -ge 2 ]
local zone="${1}"
settings_read "${path}" ${args}
}
-function zone_config_settings_write() {
+zone_config_settings_write() {
assert [ $# -ge 2 ]
local zone="${1}"
settings_write "${path}" ${args}
}
-function zone_port_settings_read() {
+zone_port_settings_read() {
assert [ $# -ge 2 ]
local zone="${1}"
settings_read "${path}" ${args}
}
-function zone_port_settings_write() {
+zone_port_settings_write() {
assert [ $# -ge 2 ]
local zone="${1}"
settings_write "${path}" ${args}
}
-function zone_port_settings_remove() {
+zone_port_settings_remove() {
assert [ $# -eq 2 ]
local zone="${1}"
# into the system and got its correct name.
# The function is intended to create child ports and things
# like that.
-function hook_hotplug() {
+hook_hotplug() {
# If the hook does not handle the hotplug event, it
# must return EXIT_NOT_HANDLED.
exit ${EXIT_NOT_HANDLED}
# The first argument is the port which should be tested
# against the second argument which is the device that
# has been plugged in.
-function hook_hotplug_rename() {
+hook_hotplug_rename() {
exit ${EXIT_FALSE}
}
-function hook_add() {
+hook_add() {
cmd_not_implemented
}
-function hook_info() {
+hook_info() {
local port="${1}"
assert isset port
shift
exit ${ERROR_OK}
}
-function hook_status() {
+hook_status() {
local port="${1}"
assert isset port
# Create any virtual devices, but don't bring them up
# Must tolerate that the device may already exist
-function hook_create() {
+hook_create() {
cmd_not_implemented
}
# Must tolerate that the device may not exist
-function hook_remove() {
+hook_remove() {
cmd_not_implemented
}
# Just bring up the device
-function hook_default_up() {
+hook_default_up() {
local port="${1}"
assert isset port
done
}
-function hook_up() {
+hook_up() {
hook_default_up $@
}
-function hook_default_down() {
+hook_default_down() {
local port="${1}"
assert isset port
done
}
-function hook_down() {
+hook_down() {
hook_default_down $@
}
# #
###############################################################################
-function hook_info() {
+hook_info() {
echo "HOOK=\"${HOOK}\""
}
-function hook_hotplug() {
+hook_hotplug() {
# If the hook does not handle the hotplug event, it
# must return EXIT_NOT_HANDLED.
exit ${EXIT_NOT_HANDLED}
}
-function hook_new() {
+hook_new() {
local zone="${1}"
assert isset zone
shift
exit ${EXIT_OK}
}
-function hook_edit() {
+hook_edit() {
hook_new $@
}
-function hook_remove() {
+hook_remove() {
cmd_not_implemented
}
-function hook_status() {
+hook_status() {
local zone="${1}"
assert isset zone
exit ${STATUS_DOWN}
}
-function hook_up() {
+hook_up() {
cmd_not_implemented
}
-function hook_down() {
+hook_down() {
cmd_not_implemented
}
-function hook_discover() {
+hook_discover() {
# This hook does not support a discovery
exit ${DISCOVER_NOT_SUPPORTED}
}
# Do nothing
-function hook_parse_cmdline() {
+hook_parse_cmdline() {
return ${EXIT_OK}
}
-function hook_port() {
+hook_port() {
local zone="${1}"
assert isset zone
exit ${ret}
}
-function hook_port_attach() {
+hook_port_attach() {
return ${EXIT_NOT_SUPPORTED}
}
-function hook_port_detach() {
+hook_port_detach() {
return ${EXIT_NOT_SUPPORTED}
}
-function hook_port_edit() {
+hook_port_edit() {
return ${EXIT_NOT_SUPPORTED}
}
-function hook_port_status() {
+hook_port_status() {
return ${EXIT_NOT_SUPPORTED}
}
-function hook_default_port_create() {
+hook_default_port_create() {
assert [ $# -ge 2 ]
local zone="${1}"
port_create "${port}"
}
-function hook_port_create() {
+hook_port_create() {
hook_default_port_create $@
}
-function hook_default_port_remove() {
+hook_default_port_remove() {
assert [ $# -ge 2 ]
local zone="${1}"
port_remove "${port}"
}
-function hook_port_remove() {
+hook_port_remove() {
hook_default_port_remove $@
}
-function hook_port_up() {
+hook_port_up() {
cmd_not_implemented
}
-function hook_port_down() {
+hook_port_down() {
cmd_not_implemented
}
-function hook_config() {
+hook_config() {
local zone="${1}"
assert isset zone
esac
}
-function hook_config_cmd() {
+hook_config_cmd() {
local cmd="${1}"
assert isset cmd
hook_config_exec "${hook_config}" "${cmd}" "${zone}" "$@"
}
-function hook_config_create() {
+hook_config_create() {
assert [ $# -ge 2 ]
hook_config_cmd "create" "$@"
}
-function hook_config_edit() {
+hook_config_edit() {
hook_config_cmd "edit" "$@"
}
-function hook_config_remove() {
+hook_config_remove() {
hook_config_cmd "remove" "$@"
}
-function hook_config_show() {
+hook_config_show() {
cmd_not_implemented
}
-function hook_ppp_write_config() {
+hook_ppp_write_config() {
cmd_not_implemented
# Arguments: <zone> <filename>
}
-function hook_ppp_ip_pre_up() {
+hook_ppp_ip_pre_up() {
local zone="${1}"
assert isset zone
shift
exit $?
}
-function hook_ppp_ipv4_up() {
+hook_ppp_ipv4_up() {
local zone="${1}"
assert isset zone
shift
exit $?
}
-function hook_ppp_ipv4_down() {
+hook_ppp_ipv4_down() {
local zone="${1}"
assert isset zone
shift
exit $?
}
-function hook_ppp_ipv6_up() {
+hook_ppp_ipv6_up() {
local zone="${1}"
assert isset zone
shift
exit $?
}
-function hook_ppp_ipv6_down() {
+hook_ppp_ipv6_down() {
local zone="${1}"
assert isset zone
shift
# Read network settings
network_settings_read
-function main() {
+main() {
local zone="${1}"
assert isset zone
# Default settings.
DELAY=0
-function hook_check() {
+hook_check() {
assert isset DELAY
assert isinteger DELAY
}
-function hook_create() {
+hook_create() {
local zone=${1}
shift
exit ${EXIT_OK}
}
-function hook_up() {
+hook_up() {
local zone=${1}
local config=${2}
shift 2
exit ${EXIT_OK}
}
-function hook_down() {
+hook_down() {
local zone=${1}
local config=${2}
shift 2
exit ${EXIT_OK}
}
-function hook_status() {
+hook_status() {
local zone=${1}
local config=${2}
shift 2
HOOK_SETTINGS="HOOK ADDRESS PREFIX GATEWAY"
-function hook_check() {
+hook_check() {
assert isset ADDRESS
assert isinteger PREFIX
fi
}
-function hook_create() {
+hook_create() {
local zone="${1}"
assert zone_exists "${zone}"
shift
exit ${EXIT_OK}
}
-function hook_up() {
+hook_up() {
local zone=${1}
local config=${2}
shift 2
exit ${EXIT_OK}
}
-function hook_down() {
+hook_down() {
local zone=${1}
local config=${2}
shift 2
exit ${EXIT_OK}
}
-function hook_status() {
+hook_status() {
local zone="${1}"
assert isset zone
# Privacy Extensions are disabled by default
PRIVACY_EXTENSIONS="off"
-function hook_check_config_settings() {
+hook_check_config_settings() {
assert isbool PRIVACY_EXTENSIONS
}
-function hook_create() {
+hook_create() {
local zone="${1}"
shift
exit ${EXIT_OK}
}
-function hook_up() {
+hook_up() {
local zone=${1}
shift
exit ${EXIT_OK}
}
-function hook_down() {
+hook_down() {
local zone=${1}
local config=${2}
shift 2
exit ${EXIT_OK}
}
-function hook_status() {
+hook_status() {
local zone=${1}
local config=${2}
shift 2
HOOK_CONFIG_SETTINGS="HOOK"
-function hook_create() {
+hook_create() {
local zone="${1}"
shift
exit ${EXIT_OK}
}
-function hook_up() {
+hook_up() {
local zone="${1}"
local config="${2}"
shift 2
exit ${EXIT_OK}
}
-function hook_down() {
+hook_down() {
local zone="${1}"
local config="${2}"
shift 2
exit ${EXIT_OK}
}
-function hook_status() {
+hook_status() {
local zone="${1}"
local config="${2}"
shift 2
HOOK_SETTINGS="HOOK ADDRESS PREFIX GATEWAY"
-function hook_check() {
+hook_check() {
assert isset ADDRESS
assert isinteger PREFIX
fi
}
-function hook_create() {
+hook_create() {
local zone=${1}
shift
exit ${EXIT_OK}
}
-function hook_up() {
+hook_up() {
local zone=${1}
local config=${2}
shift 2
exit ${EXIT_OK}
}
-function hook_down() {
+hook_down() {
local zone=${1}
local config=${2}
shift 2
exit ${EXIT_OK}
}
-function hook_status() {
+hook_status() {
local zone=${1}
local config=${2}
shift 2
# 0 = unlimited.
MAX_SESSIONS=0
-function hook_check() {
+hook_check() {
assert isset MTU
assert isset SUBNET
assert isset MAX_SESSIONS
}
-function hook_create() {
+hook_create() {
local zone=${1}
shift
exit ${EXIT_OK}
}
-function hook_up() {
+hook_up() {
local zone=${1}
local config=${2}
shift 2
exit ${EXIT_OK}
}
-function hook_down() {
+hook_down() {
local zone=${1}
local config=${2}
shift 2
exit ${EXIT_OK}
}
-function hook_status() {
+hook_status() {
local zone=${1}
local config=${2}
shift 2
ADDRESS=$(mac_generate)
SLAVES=
-function hook_check_settings() {
+hook_check_settings() {
assert isset ADDRESS
assert ismac ADDRESS
}
-function hook_new() {
+hook_new() {
while [ $# -gt 0 ]; do
case "${1}" in
--address=*)
exit ${EXIT_OK}
}
-function hook_edit() {
+hook_edit() {
local port=${1}
assert isset port
shift
exit ${EXIT_OK}
}
-function hook_create() {
+hook_create() {
local port="${1}"
assert isset port
exit ${EXIT_OK}
}
-function hook_remove() {
+hook_remove() {
local port="${1}"
assert isset port
exit ${EXIT_OK}
}
-function hook_hotplug() {
+hook_hotplug() {
local port="${1}"
assert isset port
exit ${EXIT_NOT_HANDLED}
}
-function hook_status() {
+hook_status() {
local port=${1}
assert isset port
MIIMON=100
MODE="balance-rr"
-function hook_check_settings() {
+hook_check_settings() {
assert isset ADDRESS
assert ismac ADDRESS
assert isinteger MIIMON
}
-function hook_new() {
+hook_new() {
hook_edit $@
}
-function hook_edit() {
+hook_edit() {
local port=${1}
assert isset port
shift
exit ${EXIT_OK}
}
-function hook_create() {
+hook_create() {
local port="${1}"
assert isset port
exit ${EXIT_OK}
}
-function hook_remove() {
+hook_remove() {
local port="${1}"
assert isset port
fi
}
-function hook_up() {
+hook_up() {
local port="${1}"
assert isset port
done
}
-function hook_down() {
+hook_down() {
local port="${1}"
assert isset port
hook_default_down "${port}"
}
-function hook_hotplug() {
+hook_hotplug() {
local port="${1}"
assert isset port
HOOK_SETTINGS="HOOK ADDRESS"
-function hook_check_settings() {
+hook_check_settings() {
assert ismac ADDRESS
}
-function hook_new() {
+hook_new() {
while [ $# -gt 0 ]; do
case "${1}" in
--address=*)
exit ${EXIT_OK}
}
-function hook_edit() {
+hook_edit() {
local port=${1}
assert isset port
shift
exit ${EXIT_OK}
}
-function hook_create() {
+hook_create() {
local port="${1}"
assert isset port
exit ${EXIT_OK}
}
-function hook_remove() {
+hook_remove() {
local port="${1}"
assert isset port
dummy_remove "${port}"
}
-function hook_up() {
+hook_up() {
local port="${1}"
assert isset port
exit ${EXIT_OK}
}
-function hook_down() {
+hook_down() {
local port="${1}"
assert isset port
exit ${EXIT_OK}
}
-function hook_hotplug_rename() {
+hook_hotplug_rename() {
local port=${1}
assert isset port
HOOK_SETTINGS="HOOK ADDRESS DEVICE"
-function hook_check_settings() {
+hook_check_settings() {
assert ismac DEVICE
if isset ADDRESS; then
fi
}
-function hook_new() {
+hook_new() {
local port=${1}
assert isset port
shift
exit ${EXIT_OK}
}
-function hook_create() {
+hook_create() {
# Nothing to do here. Real ethernet devices cannot
# be created. They are just there.
exit ${EXIT_OK}
}
-function hook_remove() {
+hook_remove() {
exit ${EXIT_OK}
}
-function hook_hotplug_rename() {
+hook_hotplug_rename() {
local port=${1}
assert isset port
PORT_PARENTS_VAR="PARENT"
-function hook_check_settings() {
+hook_check_settings() {
assert isset PARENT_DEVICE
assert isinteger TAG
done
}
-function hook_new() {
+hook_new() {
while [ $# -gt 0 ]; do
case "${1}" in
--parent-device=*)
exit ${EXIT_OK}
}
-function hook_edit() {
+hook_edit() {
local port=${1}
assert isset port
shift
exit ${EXIT_OK}
}
-function hook_create() {
+hook_create() {
local port="${1}"
assert isset port
exit ${EXIT_OK}
}
-function hook_remove() {
+hook_remove() {
local port="${1}"
assert isset port
PHY=
SSID=
-function hook_check_settings() {
+hook_check_settings() {
assert isset ADDRESS
assert ismac ADDRESS
assert isset CHANNEL
assert isset SSID
}
-function hook_new() {
+hook_new() {
while [ $# -gt 0 ]; do
case "${1}" in
--address=*)
exit ${EXIT_OK}
}
-function hook_edit() {
+hook_edit() {
local port=${1}
assert isset port
shift
exit ${EXIT_OK}
}
-function hook_create() {
+hook_create() {
local port="${1}"
assert isset port
exit ${EXIT_OK}
}
-function hook_remove() {
+hook_remove() {
local port="${1}"
assert isset port
exit ${EXIT_OK}
}
-function hook_up() {
+hook_up() {
local port=${1}
assert isset port
exit ${EXIT_OK}
}
-function hook_down() {
+hook_down() {
local port="${1}"
assert isset port
exit ${EXIT_OK}
}
-function hook_hotplug() {
+hook_hotplug() {
local port="${1}"
assert isset port
exit ${EXIT_OK}
}
-function hook_find_parent() {
+hook_find_parent() {
local port=${1}
assert isset port
MODE="g"
SSID=
-function hook_check_settings() {
+hook_check_settings() {
assert isset ADDRESS
assert ismac ADDRESS
assert isset BROADCAST_SSID
fi
}
-function hook_new() {
+hook_new() {
while [ $# -gt 0 ]; do
case "${1}" in
--broadcast-ssid=*)
exit ${EXIT_OK}
}
-function hook_edit() {
+hook_edit() {
local port=${1}
shift
exit ${EXIT_OK}
}
-function hook_create() {
+hook_create() {
local port="${1}"
assert isset port
exit ${EXIT_OK}
}
-function hook_remove() {
+hook_remove() {
local port="${1}"
assert isset port
exit ${EXIT_OK}
}
-function hook_up() {
+hook_up() {
local port="${1}"
assert isset port
hostapd_start "${port}"
}
-function hook_down() {
+hook_down() {
local port="${1}"
assert isset port
hostapd_stop "${port}"
}
-function hook_hotplug() {
+hook_hotplug() {
local port="${1}"
assert isset port
# The public IPv4 address of the tunnel client.
PUBLIC_ADDRESS=""
-function hook_check_settings() {
+hook_check_settings() {
assert isset SIX_RD_PREFIX
assert isset PUBLIC_ADDRESS
assert isset SERVER_ADDRESS
fi
}
-function hook_parse_cmdline() {
+hook_parse_cmdline() {
local value
while [ $# -gt 0 ]; do
done
}
-function hook_up() {
+hook_up() {
local zone="${1}"
assert isset zone
exit ${EXIT_OK}
}
-function hook_down() {
+hook_down() {
local zone=${1}
assert isset zone
exit ${EXIT_OK}
}
-function hook_status() {
+hook_status() {
local zone=${1}
assert isset zone
USERNAME=
PASSWORD=
-function hook_check_settings() {
+hook_check_settings() {
assert isset SERVER_ADDRESS
assert isset LOCAL_ADDRESS
assert isset LOCAL_ADDRESS6
fi
}
-function hook_parse_cmdline() {
+hook_parse_cmdline() {
local value
while [ $# -gt 0 ]; do
done
}
-function hook_up() {
+hook_up() {
local zone=${1}
assert isset zone
exit ${EXIT_OK}
}
-function hook_down() {
+hook_down() {
local zone=${1}
assert isset zone
exit ${EXIT_OK}
}
-function hook_status() {
+hook_status() {
local zone=${1}
assert isset zone
TUNNEL_ID=
REQUIRE_TLS="true"
-function hook_check_settings() {
+hook_check_settings() {
assert isset USERNAME
assert isset PASSWORD
assert isset SERVER
fi
}
-function hook_parse_cmdline() {
+hook_parse_cmdline() {
local value
while [ $# -gt 0 ]; do
done
}
-function hook_up() {
+hook_up() {
local zone=${1}
assert isset zone
exit ${EXIT_OK}
}
-function hook_down() {
+hook_down() {
local zone=${1}
assert isset zone
exit ${EXIT_OK}
}
-function hook_status() {
+hook_status() {
local zone=${1}
assert isset zone
STP_MAXAGE=20
STP_PRIORITY=512
-function hook_check_settings() {
+hook_check_settings() {
assert ismac MAC
assert isbool STP
assert isoneof STP_MODE stp rstp
assert isinteger MTU
}
-function hook_parse_cmdline() {
+hook_parse_cmdline() {
while [ $# -gt 0 ]; do
case "${1}" in
--stp=*)
done
}
-function hook_up() {
+hook_up() {
local zone=${1}
assert isset zone
exit ${EXIT_OK}
}
-function hook_hotplug() {
+hook_hotplug() {
local zone="${1}"
assert isset zone
exit ${EXIT_OK}
}
-function hook_down() {
+hook_down() {
local zone="${1}"
assert isset zone
exit ${EXIT_OK}
}
-function hook_status() {
+hook_status() {
local zone="${1}"
assert isset zone
exit ${EXIT_OK}
}
-function hook_check_port_settings() {
+hook_check_port_settings() {
if isset COST; then
assert isinteger COST
fi
fi
}
-function hook_port_attach() {
+hook_port_attach() {
# Excepting at least two arguments here
assert [ $# -ge 2 ]
exit ${EXIT_OK}
}
-function hook_port_detach() {
+hook_port_detach() {
assert [ $# -eq 2 ]
local zone="${1}"
exit ${EXIT_OK}
}
-function hook_port_edit() {
+hook_port_edit() {
hook_port_attach $@
}
-function hook_port_up() {
+hook_port_up() {
assert [ $# -eq 2 ]
local zone="${1}"
exit ${EXIT_OK}
}
-function hook_port_down() {
+hook_port_down() {
assert [ $# -eq 2 ]
local zone="${1}"
exit ${EXIT_OK}
}
-function hook_port_status() {
+hook_port_status() {
assert [ $# -eq 2 ]
local zone="${1}"
IMSI=
HOOK_SETTINGS="${HOOK_SETTINGS} IMSI"
-function hook_check_settings() {
+hook_check_settings() {
assert isset DEVICE
assert isset PHONE_NUMBER
isset AUTH && assert isoneof AUTH ${MODEM_ALLOWED_AUTH_METHODS}
}
-function hook_parse_cmdline() {
+hook_parse_cmdline() {
local value
while [ $# -gt 0 ]; do
done
}
-function hook_up() {
+hook_up() {
local zone=${1}
assert isset zone
exit ${EXIT_OK}
}
-function hook_down() {
+hook_down() {
local zone=${1}
assert isset zone
exit ${EXIT_OK}
}
-function hook_status() {
+hook_status() {
local zone=${1}
assert isset zone
exit ${EXIT_OK}
}
-function hook_ppp_write_config() {
+hook_ppp_write_config() {
local zone=${1}
assert isset zone
# Use IPv6 prefix delegation.
PREFIX_DELEGATION="true"
-function hook_check_settings() {
+hook_check_settings() {
assert isset USERNAME
assert isset PASSWORD
assert isset PREFIX_DELEGATION
}
-function hook_parse_cmdline() {
+hook_parse_cmdline() {
while [ $# -gt 0 ]; do
case "${1}" in
--access-concentrator=*)
done
}
-function hook_up() {
+hook_up() {
local zone=${1}
assert isset zone
exit ${EXIT_OK}
}
-function hook_down() {
+hook_down() {
local zone=${1}
assert isset zone
exit ${EXIT_OK}
}
-function hook_hotplug() {
+hook_hotplug() {
local zone="${1}"
case "$(hotplug_action)" in
exit ${EXIT_NOT_HANDLED}
}
-function hook_discover() {
+hook_discover() {
local device=${1}
# This obviously only works on ethernet (or compatible) devices
exit ${DISCOVER_OK}
}
-function hook_status() {
+hook_status() {
local zone=${1}
assert isset zone
exit ${EXIT_OK}
}
-function hook_ppp_write_config() {
+hook_ppp_write_config() {
local zone=${1}
assert isset zone
exit ${EXIT_OK}
}
-function __hook_get_port() {
+__hook_get_port() {
local zone="${1}"
local port
return ${EXIT_ERROR}
}
-function hook_port_attach() {
+hook_port_attach() {
# Excepting at least two arguments here
assert [ $# -ge 2 ]
exit ${EXIT_OK}
}
-function hook_port_detach() {
+hook_port_detach() {
assert [ $# -eq 2 ]
local zone="${1}"
exit ${EXIT_OK}
}
-function hook_ppp_ipv6_up() {
+hook_ppp_ipv6_up() {
local zone="${1}"
ppp_common_ipv6_up "${zone}"
exit ${EXIT_OK}
}
-function hook_ppp_ipv6_down() {
+hook_ppp_ipv6_down() {
local zone="${1}"
ppp_common_ipv6_down "${zone}"
KEY=
ENCRYPTION_MODE=
-function hook_check_settings() {
+hook_check_settings() {
assert isset SSID
if isset ADDRESS; then
fi
}
-function hook_parse_cmdline() {
+hook_parse_cmdline() {
while [ $# -gt 0 ]; do
case "${1}" in
--phy=*|--parent-device=*)
PHY=$(phy_get_address ${PHY})
}
-function hook_up() {
+hook_up() {
local zone=${1}
assert isset zone
exit ${EXIT_OK}
}
-function hook_down() {
+hook_down() {
local zone=${1}
shift
exit ${EXIT_OK}
}
-function hook_status() {
+hook_status() {
local zone=${1}
assert isset zone
# Read network settings
network_settings_read
-function cli_settings() {
+cli_settings() {
if cli_help_requested $@; then
cli_show_man network-settings
exit ${EXIT_OK}
fi
}
-function cli_device() {
+cli_device() {
if cli_help_requested $@; then
cli_show_man network-device
exit ${EXIT_OK}
return ${EXIT_OK}
}
-function cli_device_status() {
+cli_device_status() {
local device="${1}"
assert isset device
LOG_DISABLE_STDOUT=${log_disable_stdout}
}
-function cli_device_status_serial() {
+cli_device_status_serial() {
local device=${1}
assert device_is_serial ${device}
cli_space
}
-function cli_device_status_phy() {
+cli_device_status_phy() {
local phy="${1}"
assert phy_exists "${phy}"
return ${EXIT_OK}
}
-function cli_device_discover() {
+cli_device_discover() {
local device=${1}
shift
[ "${up}" = "1" ] || device_set_down ${device}
}
-function cli_device_serial_unlock() {
+cli_device_serial_unlock() {
if cli_help_requested $@; then
cli_show_man network-device
exit ${EXIT_OK}
exit $?
}
-function cli_device_send_ussd_command() {
+cli_device_send_ussd_command() {
local device="${1}"
assert isset device
shift
exit $?
}
-function cli_device_monitor() {
+cli_device_monitor() {
local device="${1}"
assert isset device
exit $?
}
-function cli_device_list() {
+cli_device_list() {
local device
for device in $(device_list); do
cli_device_status "${device}"
exit ${EXIT_OK}
}
-function cli_hostname() {
+cli_hostname() {
if cli_help_requested $@; then
cli_show_man network
exit ${EXIT_OK}
exit ${EXIT_OK}
}
-function cli_port() {
+cli_port() {
if cli_help_requested $@; then
cli_show_man network-port
exit ${EXIT_OK}
fi
}
-function cli_zone() {
+cli_zone() {
if cli_help_requested $@; then
cli_show_man network-zone
exit ${EXIT_OK}
# Removes a zone either immediately, if it is currently down,
# or adds a tag that the removal will be done when the zone
# is brought down the next time.
-function cli_zone_destroy() {
+cli_zone_destroy() {
if cli_help_requested $@; then
cli_show_man network-zone
exit ${EXIT_OK}
exit ${EXIT_OK}
}
-function cli_zone_port() {
+cli_zone_port() {
if cli_help_requested $@; then
cli_show_man network-zone-port
exit ${EXIT_OK}
exit ${EXIT_OK}
}
-function cli_list_hooks() {
+cli_list_hooks() {
local type=${1}
shift
done | sort -u
}
-function cli_route() {
+cli_route() {
if cli_help_requested $@; then
cli_show_man network-route
exit ${EXIT_OK}
exit ${EXIT_OK}
}
-function cli_dhcpd() {
+cli_dhcpd() {
local proto=${1}
shift
exit ${EXIT_OK}
}
-function cli_dhcpd_show() {
+cli_dhcpd_show() {
local proto=${1}
assert isset proto
fi
}
-function cli_dhcpd_subnet() {
+cli_dhcpd_subnet() {
local proto=${1}
shift
exit ${EXIT_OK}
}
-function cli_dhcpd_subnet_range() {
+cli_dhcpd_subnet_range() {
local proto=${1}
assert isset proto
shift
esac
}
-function cli_dhcpd_subnet_show() {
+cli_dhcpd_subnet_show() {
local proto=${1}
assert isset proto
cli_space
}
-function cli_dhcpd_subnet_options() {
+cli_dhcpd_subnet_options() {
local proto=${1}
assert isset proto
shift
done
}
-function cli_start() {
+cli_start() {
if cli_help_requested $@; then
cli_show_man network
exit ${EXIT_OK}
wait # until everything is settled
}
-function cli_stop() {
+cli_stop() {
if cli_help_requested $@; then
cli_show_man network
exit ${EXIT_OK}
wait # until everything is settled
}
-function cli_restart() {
+cli_restart() {
if cli_help_requested $@; then
cli_show_man network
exit ${EXIT_OK}
cli_start $@
}
-function cli_status() {
+cli_status() {
if cli_help_requested $@; then
cli_show_man network
exit ${EXIT_OK}
LOG_DISABLE_STDOUT=${log_disable_stdout}
}
-function cli_reset() {
+cli_reset() {
if cli_help_requested $@; then
cli_show_man network
exit ${EXIT_OK}
# Help function: will show the default man page to the user.
# Optionally, there are two arguments taken, the type of hook
# and which hook should be shown.
-function cli_help() {
+cli_help() {
local type=${1}
local what=${2}
hook_exec ${type} ${what} help
}
-function cli_dns_server() {
+cli_dns_server() {
if cli_help_requested $@; then
cli_show_man network-dns-server
exit ${EXIT_OK}
exit ${EXIT_OK}
}
-function cli_raw() {
+cli_raw() {
local cmd="${1}"
assert isset cmd
shift
# Helper function to write beatiful lines to
# the chat scripts.
-function println() {
+println() {
printf "%-30s %s\n" "$@" >> ${file}
}
# Setup the locking.
LOCKFILE="${RUN_DIR}/.rename_lock"
-function cleanup() {
+cleanup() {
lock_release ${LOCKFILE}
}
trap cleanup EXIT TERM KILL