#!/bin/bash
# $Header: /var/local/cvs/debian/ifupdown-scripts-zg2/scripts/ifupdown-scripts-zg2.d/atmarp,v 1.1 2004/09/12 18:00:04 mh Exp $

# IFACE      = Logical interface name
# MODE       = { start | stop }
# METHOD     = manual, otherwise exit
# IF_ATMARPn = ATM arp information (IP ATMVCI)

. /etc/network/ifupdown-scripts-zg2.d/common-functions

# only do something for ATM interfaces

[ "$IF_TYPE" == "atm" ] || exit 0

# only do something if interface is being started

case "$MODE" in
  start)
    # iterate through all ATMARP entries and load their contents into atmarpd
    for R in `set | awk 'BEGIN { FS="=";} /^IF_ATMARP/ { print $1; }'`; do
      eval S=\$$R

      IP="${S%% *}"
      S="${S#* }"
      ATM="${S%% *}"
      QOS=""
      if [ "$ATM" != "$S" ]; then
      	QOS="qos ${S##* }"
      fi
      ATM="${ATM//\//.}"
      verbose "atmarp -s $IP $ATM $QOS"
      atmarp -s $IP $ATM $QOS
      add_down "atmarp" "-d $IP"
    done
    ;;
  stop)
    exec_down "atmarp" "atmarp"
esac

# end of file
