static_arp revision 197697
1196550Sdelphij#!/bin/sh 2196550Sdelphij# 3196550Sdelphij# Copyright (c) 2009 Xin LI <delphij@FreeBSD.org> 4196550Sdelphij# All rights reserved. 5196550Sdelphij# 6196550Sdelphij# Redistribution and use in source and binary forms, with or without 7196550Sdelphij# modification, are permitted provided that the following conditions 8196550Sdelphij# are met: 9196550Sdelphij# 1. Redistributions of source code must retain the above copyright 10196550Sdelphij# notice, this list of conditions and the following disclaimer. 11196550Sdelphij# 2. Redistributions in binary form must reproduce the above copyright 12196550Sdelphij# notice, this list of conditions and the following disclaimer in the 13196550Sdelphij# documentation and/or other materials provided with the distribution. 14196550Sdelphij# 15196550Sdelphij# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16196550Sdelphij# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17196550Sdelphij# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18196550Sdelphij# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19196550Sdelphij# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20196550Sdelphij# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21196550Sdelphij# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22196550Sdelphij# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23196550Sdelphij# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24196550Sdelphij# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25196550Sdelphij# SUCH DAMAGE. 26196550Sdelphij# 27196550Sdelphij# Configure static ARP table 28196550Sdelphij# 29196550Sdelphij# $FreeBSD: head/etc/rc.d/static_arp 197697 2009-10-02 02:24:25Z hrs $ 30196550Sdelphij# 31196550Sdelphij 32196550Sdelphij# PROVIDE: static_arp 33196550Sdelphij# REQUIRE: netif 34196550Sdelphij# KEYWORD: nojail 35196550Sdelphij 36196550Sdelphij. /etc/rc.subr 37197697Shrs. /etc/network.subr 38196550Sdelphij 39196550Sdelphijname="static_arp" 40196550Sdelphijstart_cmd="static_arp_start" 41196550Sdelphijstop_cmd="static_arp_stop" 42196550Sdelphij 43196550Sdelphijstatic_arp_start() 44196550Sdelphij{ 45196552Sdelphij local e arp_args 46196552Sdelphij 47197697Shrs afexists inet || return 0 48197697Shrs 49196550Sdelphij if [ -n "${static_arp_pairs}" ]; then 50196550Sdelphij echo -n 'Binding static ARP pair(s):' 51196550Sdelphij for e in ${static_arp_pairs}; do 52196550Sdelphij echo -n " ${e}" 53196550Sdelphij eval arp_args=\$static_arp_${e} 54196550Sdelphij arp -S ${arp_args} >/dev/null 2>&1 55196550Sdelphij done 56196550Sdelphij echo '.' 57196550Sdelphij fi 58196550Sdelphij} 59196550Sdelphij 60196550Sdelphijstatic_arp_stop() 61196550Sdelphij{ 62196552Sdelphij local e arp_args 63196552Sdelphij 64197697Shrs afexists inet || return 0 65197697Shrs 66196550Sdelphij if [ -n "${static_arp_pairs}" ]; then 67196550Sdelphij echo -n 'Unbinding static ARP pair(s):' 68196550Sdelphij for e in ${static_arp_pairs}; do 69196550Sdelphij echo -n " ${e}" 70196550Sdelphij eval arp_args=\$static_arp_${e} 71196550Sdelphij arp -d ${arp_args%%[ ]*} > /dev/null 2>&1 72196550Sdelphij done 73196550Sdelphij echo '.' 74196550Sdelphij fi 75196550Sdelphij} 76196550Sdelphij 77196550Sdelphijload_rc_config $name 78196550Sdelphijrun_rc_command "$1" 79