X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=libeap%2Fwpa_supplicant%2Fexamples%2Fp2p-action.sh;h=797d43a0088a552fe653f60b0eb39784a01afc5e;hb=4f319dde67a76fe0aaf33f6d2788968012584ada;hp=38fd8d65d9c6e983f6fe3f9aea5244296f2ffda2;hpb=49c65b803b43e159e38f6a16505bad54de153916;p=mech_eap.git diff --git a/libeap/wpa_supplicant/examples/p2p-action.sh b/libeap/wpa_supplicant/examples/p2p-action.sh index 38fd8d6..797d43a 100755 --- a/libeap/wpa_supplicant/examples/p2p-action.sh +++ b/libeap/wpa_supplicant/examples/p2p-action.sh @@ -27,14 +27,33 @@ if [ "$CMD" = "P2P-GROUP-STARTED" ]; then rm /var/run/dhclient.leases-$GIFNAME kill_daemon dnsmasq /var/run/dnsmasq.pid-$GIFNAME ifconfig $GIFNAME 192.168.42.1 up - dnsmasq -x /var/run/dnsmasq.pid-$GIFNAME \ + if ! dnsmasq -x /var/run/dnsmasq.pid-$GIFNAME \ -i $GIFNAME \ - -F192.168.42.11,192.168.42.99 + -F192.168.42.11,192.168.42.99; then + # another dnsmasq instance may be running and blocking us; try to + # start with -z to avoid that + dnsmasq -x /var/run/dnsmasq.pid-$GIFNAME \ + -i $GIFNAME \ + -F192.168.42.11,192.168.42.99 --listen-address 192.168.42.1 -z -p 0 + fi fi if [ "$4" = "client" ]; then kill_daemon dhclient /var/run/dhclient-$GIFNAME.pid rm /var/run/dhclient.leases-$GIFNAME kill_daemon dnsmasq /var/run/dnsmasq.pid-$GIFNAME + ipaddr=`echo "$*" | sed 's/.* ip_addr=\([^ ]*\).*/\1/'` + ipmask=`echo "$*" | sed 's/.* ip_mask=\([^ ]*\).*/\1/'` + goipaddr=`echo "$*" | sed 's/.* go_ip_addr=\([^ ]*\).*/\1/'` + if echo "$ipaddr$ipmask$goipaddr" | grep -q ' '; then + ipaddr="" + ipmask="" + goipaddr="" + fi + if [ -n "$ipaddr" ]; then + sudo ifconfig $GIFNAME "$ipaddr" netmask "$ipmask" + sudo ip ro re default via "$goipaddr" + exit 0 + fi dhclient -pf /var/run/dhclient-$GIFNAME.pid \ -lf /var/run/dhclient.leases-$GIFNAME \ -nw \