CMDNAME=`basename $0`

while getopts s:p: OPT
do
  case $OPT in
    "s" ) FLG_S="TRUE" ; VALUE_S="$OPTARG" ;;
    "p" ) FLG_P="TRUE" ; VALUE_P="$OPTARG" ;;
      * ) echo "Usage: $CMDNAME [-s BAUDRATE] [-p PORT] [-c VALUE]" 1>&2
          exit 1 ;;
  esac
done

if [ "$FLG_S" = "TRUE" ]; then
  echo "Baudrate = $VALUE_S"
fi

if [ "$FLG_P" = "TRUE" ]; then
  echo "Port = $VALUE_P"
fi

ps -a | grep slattach | awk '{print $1}' | xargs kill

slattach -L -s $VALUE_S -p slip $VALUE_P&
sleep 1s
ifconfig sl0 192.168.5.1 dstaddr 192.168.5.3
ifconfig sl0 netmask 255.255.255.0

sleep 1s
ifconfig