LOG_FILE="/tmp/fiicore_wired_clients.log"

#clear the stats file
if [ -e $LOG_FILE ]; then
   #echo "clear the LOG_FILE"
   > $LOG_FILE
fi

for i in 1 2 3
do
if [ -d "/sys/class/net/br0/brif/eth0.$i/" ]; then
        brport=$(printf "%d\n" $(cat /sys/class/net/br0/brif/eth0.$i/port_no))
        [[ ! -z "$brport" ]] &&
        {
                brctl showmacs br0 | grep no | awk -v var="$brport" '{if ($1 == var) print $2;}' | while read line; do
                #echo $line
                active_wire=$(ip neigh show dev br0 nud reachable | grep $line | awk '{print $3}')
                [[ ! -z "$active_wire" ]] && echo $brport $active_wire >> $LOG_FILE
                done
        }
fi
done
