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: releng/10.2/etc/rc.d/static_arp 202130 2010-01-11 23:32:36Z delphij $
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
47196550Sdelphij	if [ -n "${static_arp_pairs}" ]; then
48196550Sdelphij		echo -n 'Binding static ARP pair(s):'
49196550Sdelphij		for e in ${static_arp_pairs}; do
50196550Sdelphij			echo -n " ${e}"
51196550Sdelphij			eval arp_args=\$static_arp_${e}
52196550Sdelphij			arp -S ${arp_args} >/dev/null 2>&1
53196550Sdelphij		done
54196550Sdelphij		echo '.'
55196550Sdelphij	fi
56196550Sdelphij}
57196550Sdelphij
58196550Sdelphijstatic_arp_stop()
59196550Sdelphij{
60196552Sdelphij	local e arp_args
61196552Sdelphij
62196550Sdelphij	if [ -n "${static_arp_pairs}" ]; then
63196550Sdelphij		echo -n 'Unbinding static ARP pair(s):'
64196550Sdelphij		for e in ${static_arp_pairs}; do
65196550Sdelphij			echo -n " ${e}"
66196550Sdelphij			eval arp_args=\$static_arp_${e}
67196550Sdelphij			arp -d ${arp_args%%[ 	]*} > /dev/null 2>&1
68196550Sdelphij		done
69196550Sdelphij		echo '.'
70196550Sdelphij	fi
71196550Sdelphij}
72196550Sdelphij
73196550Sdelphijload_rc_config $name
74196550Sdelphijrun_rc_command "$1"
75