dist_network_SCRIPTS = \
src/functions/functions.at \
src/functions/functions.auth \
- src/functions/functions.batman-adv \
src/functions/functions.bonding \
src/functions/functions.bridge \
src/functions/functions.cli \
src/hooks/configs/pppoe-server
dist_hooks_ports_SCRIPTS = \
- src/hooks/ports/batman-adv \
src/hooks/ports/bonding \
src/hooks/ports/dummy \
src/hooks/ports/ethernet \
man/network-dns-server.8 \
man/network-performance-tuning.8 \
man/network-port.8 \
- man/network-port-batman-adv.8 \
- man/network-port-batman-adv-port.8 \
man/network-quick-start.8 \
man/network-route.8 \
man/network-route-static.8 \
+++ /dev/null
-<?xml version="1.0"?>
-<!DOCTYPE refentry PUBLIC "-//OASIS/DTD DocBook XML V4.2//EN"
- "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
-
-<refentry id="network-port-batman-adv-port">
- <refentryinfo>
- <title>network-port-batman-adv-port</title>
- <productname>network</productname>
-
- <authorgroup>
- <author>
- <contrib>Developer</contrib>
- <firstname>Michael</firstname>
- <surname>Tremer</surname>
- <email>michael.tremer@ipfire.org</email>
- </author>
- </authorgroup>
- </refentryinfo>
-
- <refmeta>
- <refentrytitle>network-port-batman-adv-port</refentrytitle>
- <manvolnum>8</manvolnum>
- </refmeta>
-
- <refnamediv>
- <refname>network-port-batman-adv-port</refname>
- <refpurpose>Network Configuration Control Program</refpurpose>
- </refnamediv>
-
- <refsynopsisdiv>
- <cmdsynopsis>
- <command>network port create batman-adv-port ...</command>
- </cmdsynopsis>
-
- <cmdsynopsis>
- <command>network <arg choice="plain">PORT</arg> edit ...</command>
- </cmdsynopsis>
- </refsynopsisdiv>
-
- <refsect1>
- <title>Description</title>
-
- <para>
- This hook configures a wireless device that is then used as a port
- in the <emphasis>batman-adv</emphasis> hook.
- </para>
- </refsect1>
-
- <refsect1>
- <title>Options</title>
-
- <para>
- The following options are understood:
- </para>
-
- <variablelist>
- <varlistentry>
- <term>
- <option>--address=<replaceable>ADDRESS</replaceable></option>
- </term>
-
- <listitem>
- <para>
- Define the MAC address of the interface. If no address
- is defined, a random one will be generated.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- <option>--channel=<replaceable>NUMBER</replaceable></option>
- </term>
-
- <listitem>
- <para>
- Set the channel number of the channel that should be used
- for the wireless network.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- <option>--phy=<replaceable>PHY</replaceable></option>
- </term>
-
- <listitem>
- <para>
- Use this wireless phy to create the interface.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- <option>--ssid=<replaceable>SSID</replaceable></option>
- </term>
-
- <listitem>
- <para>
- Define the ESSID of the wireless network.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- <option>--mesh-id=<replaceable>MESH-ID</replaceable></option>
- </term>
-
- <listitem>
- <para>
- Define the mesh id or BSSID of the wireless network.
- </para>
- </listitem>
- </varlistentry>
- </variablelist>
- </refsect1>
-
- <refsect1>
- <title>See Also</title>
-
- <para>
- <citerefentry>
- <refentrytitle>network</refentrytitle>
- <manvolnum>8</manvolnum>
- </citerefentry>,
- <citerefentry>
- <refentrytitle>network-port</refentrytitle>
- <manvolnum>8</manvolnum>
- </citerefentry>,
- <citerefentry>
- <refentrytitle>network-port-batman-adv</refentrytitle>
- <manvolnum>8</manvolnum>
- </citerefentry>
- </para>
- </refsect1>
-</refentry>
+++ /dev/null
-<?xml version="1.0"?>
-<!DOCTYPE refentry PUBLIC "-//OASIS/DTD DocBook XML V4.2//EN"
- "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
-
-<refentry id="network-port-batman-adv">
- <refentryinfo>
- <title>network-port-batman-adv</title>
- <productname>network</productname>
-
- <authorgroup>
- <author>
- <contrib>Developer</contrib>
- <firstname>Michael</firstname>
- <surname>Tremer</surname>
- <email>michael.tremer@ipfire.org</email>
- </author>
- </authorgroup>
- </refentryinfo>
-
- <refmeta>
- <refentrytitle>network-port-batman-adv</refentrytitle>
- <manvolnum>8</manvolnum>
- </refmeta>
-
- <refnamediv>
- <refname>network-port-batman-adv</refname>
- <refpurpose>Network Configuration Control Program</refpurpose>
- </refnamediv>
-
- <refsynopsisdiv>
- <cmdsynopsis>
- <command>network port create batman-adv ...</command>
- </cmdsynopsis>
-
- <cmdsynopsis>
- <command>network <arg choice="plain">PORT</arg> edit ...</command>
- </cmdsynopsis>
- </refsynopsisdiv>
-
- <refsect1>
- <title>Description</title>
-
- <para>
- The batman-adv hook creates a batman-adv soft interface, which is
- used to bridge several hard interfaces (wireless adapters, etc.).
- </para>
- </refsect1>
-
- <refsect1>
- <title>Options</title>
-
- <para>
- The following options are understood:
- </para>
-
- <variablelist>
- <varlistentry>
- <term>
- <option>--address=<replaceable>ADDRESS</replaceable></option>
- </term>
-
- <listitem>
- <para>
- Define the MAC address of the interface. If no address
- is defined, a random one will be generated.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- <option>--slaves=<replaceable>SLAVES</replaceable></option>
- (only on create)
- </term>
-
- <listitem>
- <para>
- Define a lits of port, which should be used as slaves.
- All slaves must be <emphasis>batman-adv-port</emphasis>
- ports.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- <option>--add-slave=<replaceable>SLAVE</replaceable></option>
- (only on edit)
- </term>
-
- <listitem>
- <para>
- Adds an additional slave port.
- </para>
- </listitem>
- </varlistentry>
-
- <varlistentry>
- <term>
- <option>--del-slave=<replaceable>SLAVE</replaceable></option>
- (only on edit)
- </term>
-
- <listitem>
- <para>
- Removes a slave port.
- </para>
- </listitem>
- </varlistentry>
- </variablelist>
- </refsect1>
-
- <refsect1>
- <title>See Also</title>
-
- <para>
- <citerefentry>
- <refentrytitle>network</refentrytitle>
- <manvolnum>8</manvolnum>
- </citerefentry>,
- <citerefentry>
- <refentrytitle>network-port</refentrytitle>
- <manvolnum>8</manvolnum>
- </citerefentry>,
- <citerefentry>
- <refentrytitle>network-port-batman-adv-port</refentrytitle>
- <manvolnum>8</manvolnum>
- </citerefentry>
- </para>
- </refsect1>
-</refentry>
+++ /dev/null
-#!/bin/bash
-###############################################################################
-# #
-# IPFire.org - A linux based firewall #
-# Copyright (C) 2013 IPFire Network Development Team #
-# #
-# This program is free software: you can redistribute it and/or modify #
-# it under the terms of the GNU General Public License as published by #
-# the Free Software Foundation, either version 3 of the License, or #
-# (at your option) any later version. #
-# #
-# This program is distributed in the hope that it will be useful, #
-# but WITHOUT ANY WARRANTY; without even the implied warranty of #
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
-# GNU General Public License for more details. #
-# #
-# You should have received a copy of the GNU General Public License #
-# along with this program. If not, see <http://www.gnu.org/licenses/>. #
-# #
-###############################################################################
-
-batman_adv_add() {
- local device="${1}"
- assert isset device
-
- # Make sure the kernel module is loaded
- module_load "batman-adv"
-
- local cmd="ip link add name ${device} type batadv"
- cmd_quiet "${cmd}"
- local ret=$?
-
- if [ ${ret} -eq ${EXIT_OK} ]; then
- log DEBUG "batman-adv device '${device}' has been created"
- else
- log ERROR "batman-adv device '${device}' could not be created: ${ret}"
- fi
-
- return ${ret}
-}
-
-batman_adv_delete() {
- local device="${1}"
- assert isset device
-
- device_delete "${device}"
-}
-
-batman_adv_attach() {
- local device=${1}
- assert isset device
-
- local port=${2}
- assert isset port
-
- device_set_master "${port}" "${device}"
-}
-
-batman_adv_detach() {
- local port=${1}
- assert isset port
-
- device_remove_master "${port}"
-}
-
-batman_adv_get_aggregated_ogms() {
- local device=${1}
- assert isset device
-
- local value="$(__device_get_file "${device}" "mesh/aggregated_ogms")"
- case "${value}" in
- enabled)
- return ${EXIT_TRUE}
- ;;
- disabled)
- return ${EXIT_FALSE}
- ;;
- esac
-
- return ${EXIT_ERROR}
-}
-
-batman_adv_get_ap_isolation() {
- local device=${1}
- assert isset device
-
- local value="$(__device_get_file "${device}" "mesh/ap_isolation")"
- case "${value}" in
- enabled)
- return ${EXIT_TRUE}
- ;;
- disabled)
- return ${EXIT_FALSE}
- ;;
- esac
-
- return ${EXIT_ERROR}
-}
-
-batman_adv_get_bonding_mode() {
- local device=${1}
- assert isset device
-
- local value="$(__device_get_file "${device}" "mesh/bonding")"
- case "${value}" in
- enabled)
- return ${EXIT_TRUE}
- ;;
- disabled)
- return ${EXIT_FALSE}
- ;;
- esac
-
- return ${EXIT_ERROR}
-}
-
-batman_adv_get_distributed_arp_table() {
- local device=${1}
- assert isset device
-
- local value="$(__device_get_file "${device}" "mesh/distributed_arp_table")"
- case "${value}" in
- enabled)
- return ${EXIT_TRUE}
- ;;
- disabled)
- return ${EXIT_FALSE}
- ;;
- esac
-
- return ${EXIT_ERROR}
-}
-
-batman_adv_get_bridge_loop_avoidance() {
- local device=${1}
- assert isset device
-
- local value="$(__device_get_file "${device}" "mesh/bridge_loop_avoidance")"
- case "${value}" in
- enabled)
- return ${EXIT_TRUE}
- ;;
- disabled)
- return ${EXIT_FALSE}
- ;;
- esac
-
- return ${EXIT_ERROR}
-}
-
-batman_adv_get_fragmentation() {
- local device=${1}
- assert isset device
-
- local value="$(__device_get_file "${device}" "mesh/fragmentation")"
- case "${value}" in
- enabled)
- return ${EXIT_TRUE}
- ;;
- disabled)
- return ${EXIT_FALSE}
- ;;
- esac
-
- return ${EXIT_ERROR}
-}
-
-batman_adv_get_gateway_mode() {
- local device=${1}
- assert isset device
-
- local value="$(__device_get_file "${device}" "mesh/gw_mode")"
- case "${value}" in
- on)
- return ${EXIT_TRUE}
- ;;
- off)
- return ${EXIT_FALSE}
- ;;
- esac
-
- return ${EXIT_ERROR}
-}
-
-batman_adv_get_gateway_bandwidth() {
- local device=${1}
- assert isset device
-
- __device_get_file "${device}" "mesh/gw_bandwidth"
-}
-
-batman_adv_get_gateway_selection_class() {
- local device=${1}
- assert isset device
-
- __device_get_file "${device}" "mesh/gw_sel_class"
-}
-
-batman_adv_get_hop_penalty() {
- local device=${1}
- assert isset device
-
- __device_get_file "${device}" "mesh/hop_penalty"
-}
-
-batman_adv_get_originator_interval() {
- local device=${1}
- assert isset device
-
- __device_get_file "${device}" "mesh/orig_interval"
-}
-
-batman_adv_get_routing_algorithm() {
- local device=${1}
- assert isset device
-
- __device_get_file "${device}" "mesh/routing_algo"
-}
print "$(<${path})"
}
-# Check if the device is a batman-adv bridge
-device_is_batman_adv() {
- [ -d "${SYS_CLASS_NET}/${1}/mesh" ]
-}
-
-# Check if the device is a batman-adv slave port
-device_is_batman_adv_slave() {
- local device="${1}"
-
- if [ -d "${SYS_CLASS_NET}/${device}/batman_adv" ]; then
- local status="$(<${SYS_CLASS_NET}/${device}/batman_adv/iface_status)"
-
- case "${status}" in
- "active")
- return ${EXIT_TRUE}
- ;;
- *)
- return ${EXIT_FALSE}
- ;;
- esac
- fi
-
- return ${EXIT_FALSE}
-}
-
# Check if the device is a bonding device
device_is_bonding() {
[ -d "/sys/class/net/${1}/bonding" ]
elif device_is_ppp ${device}; then
echo "ppp"
- elif device_is_batman_adv ${device}; then
- echo "batman-adv"
-
elif device_is_loopback ${device}; then
echo "loopback"
+++ /dev/null
-#!/bin/bash
-###############################################################################
-# #
-# IPFire.org - A linux based firewall #
-# Copyright (C) 2013 Michael Tremer #
-# #
-# This program is free software: you can redistribute it and/or modify #
-# it under the terms of the GNU General Public License as published by #
-# the Free Software Foundation, either version 3 of the License, or #
-# (at your option) any later version. #
-# #
-# This program is distributed in the hope that it will be useful, #
-# but WITHOUT ANY WARRANTY; without even the implied warranty of #
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
-# GNU General Public License for more details. #
-# #
-# You should have received a copy of the GNU General Public License #
-# along with this program. If not, see <http://www.gnu.org/licenses/>. #
-# #
-###############################################################################
-
-. /usr/lib/network/header-port
-
-HOOK_SETTINGS="HOOK ADDRESS SLAVES"
-
-PORT_CHILDREN_VAR="SLAVES"
-
-ADDRESS=$(mac_generate)
-SLAVES=
-
-hook_check_settings() {
- assert isset ADDRESS
- assert ismac ADDRESS
-}
-
-hook_new() {
- while [ $# -gt 0 ]; do
- case "${1}" in
- --address=*)
- ADDRESS="$(cli_get_val "${1}")"
- ;;
- --slaves=*)
- SLAVES="$(cli_get_val "${1}")"
- ;;
- *)
- warning "Ignoring unknown argument '${1}'"
- ;;
- esac
- shift
- done
-
- local port=$(port_find_free ${PORT_PATTERN_BATMAN_ADV})
- assert isset port
-
- port_settings_write "${port}" ${HOOK_SETTINGS}
-
- exit ${EXIT_OK}
-}
-
-hook_edit() {
- local port=${1}
- assert isset port
- shift
-
- port_settings_read "${port}"
-
- while [ $# -gt 0 ]; do
- case "${1}" in
- --address=*)
- ADDRESS="$(cli_get_val "${1}")"
- ;;
- --add-slave=*)
- SLAVES="${SLAVES} $(cli_get_val "${1}")"
- ;;
- --del-slave=*)
- local slave="$(cli_get_val "${1}")"
-
- local s slaves
- for s in ${SLAVES}; do
- [ "${slave}" = "${s}" ] && continue
- slaves="${slaves} ${s}"
- done
- SLAVES="${slaves}"
- ;;
- *)
- warning "Unknown argument '${1}'"
- ;;
- esac
- shift
- done
-
- port_settings_write "${port}" ${HOOK_SETTINGS}
-
- exit ${EXIT_OK}
-}
-
-hook_create() {
- local port="${1}"
- assert isset port
-
- port_settings_read "${port}" ${HOOK_SETTINGS}
-
- # Create a new batman-adv device
- batman_adv_add "${port}" || exit ${?}
-
- # Set the address.
- device_set_address "${port}" "${ADDRESS}"
-
- exit ${EXIT_OK}
-}
-
-hook_remove() {
- local port="${1}"
- assert isset port
-
- port_settings_read "${port}" ${HOOK_SETTINGS}
-
- # Remove the batman-adv device
- batman_adv_delete "${port}"
-
- exit ${EXIT_OK}
-}
-
-hook_hotplug() {
- local port="${1}"
- assert isset port
-
- case "$(hotplug_action)" in
- add)
- # Handle events of the same interface
- if hotplug_event_port_is_interface "${port}"; then
- # Bring up all slaves
- # They will be attached by their own hotplug event
- local slave
- for slave in $(port_get_slaves "${port}"); do
- port_create "${slave}"
- done
-
- exit ${EXIT_OK}
-
- # Handle slave devices that have just been created and
- # attach them.
- elif hotplug_event_interface_is_slave_of_port "${port}"; then
- batman_adv_attach "${port}" "${INTERFACE}"
-
- # If the batman-adv is already up, we will bring
- # up the slave we just added as well.
- if port_is_up "${port}"; then
- port_up "${INTERFACE}"
- fi
- fi
-
- exit ${EXIT_OK}
- ;;
-
- remove)
- if hotplug_event_port_is_interface "${port}"; then
- # Bring down all slaves when the batman device went down
- local slave
- for slave in $(port_get_slaves "${port}"); do
- port_remove "${slave}"
- done
-
- exit ${EXIT_OK}
- fi
- ;;
- esac
- exit ${EXIT_NOT_HANDLED}
-}
-
-hook_status() {
- local port=${1}
- assert isset port
-
- cli_device_headline "${port}" --long
-
- cli_headline 2 "B.A.T.M.A.N."
-
- # Routing algorithm
- cli_print_fmt1 2 "Routing Algorithm" \
- "$(batman_adv_get_routing_algorithm "${port}")"
-
- # Space
- cli_space
-
- # Originator interval
- cli_print_fmt1 2 "Originator Interval" \
- "$(batman_adv_get_originator_interval "${port}") ms"
-
- # Aggregated originator messages
- batman_adv_get_aggregated_ogms "${port}"
- cli_print_fmt1 2 "Aggregated Originator Messages" "$(cli_print_bool $?)"
-
- # AP isolation
- batman_adv_get_ap_isolation "${port}"
- cli_print_fmt1 2 "Access Point Isolation" "$(cli_print_bool $?)"
-
- # Bonding mode
- batman_adv_get_bonding_mode "${port}"
- cli_print_fmt1 2 "Bonding Mode" "$(cli_print_bool $?)"
-
- # Bridge loop avoidance
- batman_adv_get_bridge_loop_avoidance "${port}"
- cli_print_fmt1 2 "Bridge Loop Avoidance" "$(cli_print_bool $?)"
-
- # Distributed ARP table
- batman_adv_get_distributed_arp_table "${port}"
- cli_print_fmt1 2 "Distributed ARP Table" "$(cli_print_bool $?)"
-
- # Fragmentation
- batman_adv_get_fragmentation "${port}"
- cli_print_fmt1 2 "Fragmentation" "$(cli_print_bool $?)"
-
- # Hop penalty
- cli_print_fmt1 2 "Hop Penalty" \
- "$(batman_adv_get_hop_penalty "${port}")"
- cli_space
-
- # Gateway
- cli_headline 3 "Gateway"
-
- # Gateway mode
- batman_adv_get_gateway_mode "${port}"
- local gw_enabled=$?
-
- cli_print_fmt1 3 "Enabled" "$(cli_print_bool ${gw_enabled})"
-
- if [ ${gw_enabled} -eq ${EXIT_TRUE} ]; then
- cli_print_fmt1 3 "Bandwidth" \
- "$(batman_adv_get_gateway_bandwidth "${port}")"
- cli_print_fmt1 3 "Selection Class" \
- "$(batman_adv_get_gateway_selection_class "${port}")"
- fi
-
- cli_space
-
- exit ${EXIT_OK}
-}
exit ${EXIT_OK}
}
-
-hook_find_parent() {
- local port=${1}
- assert isset port
-
- local p child hook
- for p in $(ports_get); do
- hook=$(port_get_hook "${p}")
-
- if [ "${hook}" = "batman-adv" ]; then
- for child in $(port_get_children "${p}"); do
- [ "${child}" = "${port}" ] || continue
-
- print "${p}"
- return ${EXIT_OK}
- done
- fi
- done
-
- return ${EXIT_ERROR}
-}