Assign unique peer address

This commit is contained in:
Bob Mottram 2016-07-21 20:44:20 +01:00
parent 2fa22c4d04
commit 7702692aec
1 changed files with 154 additions and 137 deletions

View File

@ -141,6 +141,22 @@ function verify {
rm $tempfile
}
function assign_peer_address {
for i in {1..6}; do
number=$RANDOM
let "number %= 255"
octet=$(echo "obase=16;$number" | bc)
if [ ${#octet} -lt 2 ]; then
octet="0${octet}"
fi
if [ $i -gt 1 ]; then
echo -n ":"
fi
echo -n "${octet}"
done
echo ''
}
function start {
if [ -z "$IFACE" ] ; then
echo 'error: unable to find wifi interface, not enabling batman-adv mesh'
@ -161,6 +177,7 @@ function start {
ifconfig $IFACE down
ifconfig $IFACE mtu 1532
ifconfig $IFACE hw ether $(assign_peer_address)
iwconfig $IFACE enc off
iwconfig $IFACE mode ad-hoc essid $WIFI_SSID channel $CHANNEL
sleep 1