create_ap

create a nat-ed wifi ap
git clone git://git.2f30.org/create_ap.git
Log | Files | Refs | LICENSE

commit 5b2d7984db9a17213c387addf7a3675ea8c97b46
parent ddd6bfad458080748d529658e7c9ca0b579d7166
Author: oblique <psyberbits@gmail.com>
Date:   Thu Sep 18 20:44:22 +0300

get_new_macaddr: add 1 to the mac address instead of starting from 0x14

If someone have 2 adapters with the same hardware, there is a possibility
the first 5 bytes of their mac address to be the same.
I this case we will have mac address collision if we change both of them to
XX:XX:XX:XX:XX:14, one way to avoid this is to add 1 to their last byte.

Fix #47

Diffstat:
create_ap | 5+++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/create_ap b/create_ap @@ -209,8 +209,9 @@ get_virt_iface_name() { get_new_macaddr() { OLDMAC=$(get_macaddr "$1") - for i in {20..255}; do - NEWMAC="${OLDMAC%:*}:$(printf %02x $i)" + LAST_BYTE=$(printf %d 0x${OLDMAC##*:}) + for i in {1..255}; do + NEWMAC="${OLDMAC%:*}:$(printf %02x $(( ($LAST_BYTE + $i) % 256 )))" (ip link | grep "ether ${NEWMAC}" > /dev/null 2>&1) || break done echo $NEWMAC