70 lines
1.2 KiB
Bash
70 lines
1.2 KiB
Bash
_genfile="${route_policy_file}"
|
|
if [ -z "${_genfile}" ]
|
|
then
|
|
_genfile="/dev/fd/1"
|
|
fi
|
|
|
|
__install_route_policy()
|
|
{
|
|
iface=$1;shift 1
|
|
network=$1;shift 1
|
|
table=$1;shift 1
|
|
|
|
echo "match out on ${iface} from !fd00::/8 to ${network} rtable ${table}" >> $1
|
|
echo "match in on ${iface} from ${network} to !fd00::/8 rtable ${table}" >> $1
|
|
}
|
|
|
|
__install_route_policy_v4()
|
|
{
|
|
iface=$1;shift 1
|
|
network=$1;shift 1
|
|
table=$1;shift 1
|
|
|
|
echo "match out on ${iface} to ${network} rtable ${table}" >> $1
|
|
echo "match in on ${iface} from ${network} rtable ${table}" >> $1
|
|
}
|
|
|
|
_install_route_policy()
|
|
{
|
|
iface=$1;shift 1
|
|
split=`echo $1 | sed -e 's/->/ /g'`;shift 1
|
|
|
|
__install_route_policy $iface ${split} $*
|
|
}
|
|
|
|
_install_route_policy_v4()
|
|
{
|
|
iface=$1;shift 1
|
|
split=`echo $1 | sed -e 's/->/ /g'`;shift 1
|
|
|
|
__install_route_policy_v4 $iface ${split} $*
|
|
}
|
|
|
|
install_route_policy()
|
|
{
|
|
_install_route_policy internal $* ${_genfile}
|
|
}
|
|
|
|
install_route_policy_v4()
|
|
{
|
|
_install_route_policy_v4 internal $* ${_genfile}
|
|
}
|
|
|
|
|
|
add_route_policy()
|
|
{
|
|
route_policies="${route_policies} $1->$2"
|
|
}
|
|
|
|
add_route_policy_v4()
|
|
{
|
|
route_policies_v4="${route_policies_v4} $1->$2"
|
|
}
|
|
|
|
clear_all_policies()
|
|
{
|
|
echo -n > $_genfile
|
|
}
|
|
|
|
# vim: ft=sh
|