# https://confluence.zooxlabs.com/confluence/display/VEH/Conti+Radar+Firmware+Setup+and+Information

echo Run this script with no flags if you are setting up.
echo Run this script with --clean if you are cleaning up.
sleep 0.5
if [ $# -eq 1 ] && [ "$1" == "--clean" ]; then
    sudo route del -net 192.168.1.0 netmask 255.255.255.0 dev eth0 2>/dev/null
    sudo ifup eth0:0 2>/dev/null # turn the previous interface back on
    exit 0
fi
# turn off a conflicting interface
sudo ifdown eth0:0 2>/dev/null
# add the route to the dot 1 subnet
sudo route -n add -net 192.168.1.0 netmask 255.255.255.0 dev eth0 2>/dev/null
sudo arp -s 192.168.1.2 02:08:02:03:00:00 -i eth0 > /dev/null 2>&1
for i in {0..9}
do
    IP="192.168.3.3"$i
    MAC="02:08:02:03:00:0"$i
    sudo arp -s $IP $MAC -i eth0 > /dev/null 2>&1
done

# IP="$(sudo tcpdump host 192.168.3.30 \
# #                 or host 192.168.3.31 \
# #                 or host 192.168.3.32 \
# #                 or host 192.168.3.33 \
# #                 or host 192.168.3.34 \
# #                 or host 192.168.3.35 \
# #                 or host 192.168.3.36 \
# #                 or host 192.168.3.37 \
# #                 or host 192.168.3.38 \
# #                 or host 192.168.3.39 \
# #                 or host 192.168.1.2 2>/dev/null \
# #                 | awk 'NR==1 {print $3; exit}')"
# # IP="$(echo $IP | cut -d"." -f1-4)"
# # echo Radar with IP $IP found.
