#!/bin/sh
cd ${0%${0##*/}}.
. ./conf.sh

IP=$1
DOWNSTREAM_SPEED=$2
UPSTREAM_SPEED=$3

date  >> ./log/manad.out
echo `/sbin/iptables -I $WIFI_CHAIN_NAME 1 -t nat -j ACCEPT -s $IP` >> ./log/manad.out 2>&1
echo `/sbin/iptables -I $WIFI_CHAIN_NAME 1 -t nat -j ACCEPT -d $IP` >> ./log/manad.out 2>&1

#RST packets for dropping estаblished connections and for reading traffic counts( in ip_counts.sh).   
echo `/sbin/iptables -I FORWARD 1 -j ACCEPT -s $IP` >> ./log/manad.out 2>&1
echo `/sbin/iptables -I FORWARD 1 -j ACCEPT -d $IP` >> ./log/manad.out 2>&1


if [ $USE_MANAD -eq 1 ]; then
./tell_manad.pl "add $IP $DOWNSTREAM_SPEED $UPSTREAM_SPEED" $MANAD_PORT
fi

#use it for shaping
#./shape.sh $IP $PARAM1 $PARAM2
