#!/bin/bash ############################################################################### # # # IPFire.org - A linux based firewall # # Copyright (C) 2010 Michael Tremer & Christian Schmidt # # # # 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 . # # # ############################################################################### # # XXX This hook is rather unusable because the parent device cannot be used # anymore in a bridge. # . /usr/lib/network/header-port HOOK_SETTINGS="HOOK ADDRESS PARENT" function hook_check() { assert isset PARENT assert ismac ADDRESS } function hook_create() { while [ $# -gt 0 ]; do case "${1}" in --parent-device=*) PARENT=$(cli_get_val ${1}) ;; --address=*) ADDRESS=$(cli_get_val ${1}) ;; *) warning "Unknown argument '${1}'" ;; esac shift done local port=$(port_find_free "${PARENT}${MACVLAN_PORT_INTERFIX}N") assert isset port if config_write $(port_file ${port}) ${HOOK_SETTINGS}; then log INFO "New macvlan port '${port}' has been created." fi exit ${EXIT_OK} } function hook_edit() { local port=${1} assert isset port shift config_read $(port_file ${port}) while [ $# -gt 0 ]; do case "${1}" in --address=*) ADDRESS=$(cli_get_val ${1}) ;; *) warning "Unknown argument '${1}'" ;; esac shift done config_write $(port_file ${port}) ${HOOK_SETTINGS} exit ${EXIT_OK} } function hook_up() { local port=${1} assert isset port config_read $(port_file ${port}) # Create device if not already exists. if ! device_exists ${port}; then macvlan_create "${port}" "${PARENT}" "${ADDRESS}" fi exit ${EXIT_OK} } function hook_down() { local port=${1} assert isset port config_read $(port_file ${port}) if ! device_exists ${port}; then exit ${EXIT_OK} fi macvlan_remove ${port} exit ${EXIT_OK} }