P2P: wpa_cli action calls for P2P group started/removed events

This commit is contained in:
Jouni Malinen 2010-07-18 14:30:26 -07:00 committed by Jouni Malinen
parent 57faa1cee8
commit 42f0101b4d
2 changed files with 60 additions and 0 deletions

View File

@ -0,0 +1,56 @@
#!/bin/sh
IFNAME=$1
CMD=$2
kill_daemon() {
NAME=$1
PF=$2
if [ ! -r $PF ]; then
return
fi
PID=`cat $PF`
if [ $PID -gt 0 ]; then
if ps $PID | grep -q $NAME; then
kill $PID
fi
fi
rm $PF
}
if [ "$CMD" = "P2P-GROUP-STARTED" ]; then
GIFNAME=$3
if [ "$4" = "GO" ]; then
kill_daemon dhclient /var/run/dhclient-$GIFNAME.pid
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 \
-i $GIFNAME \
-F192.168.42.11,192.168.42.99
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
dhclient -pf /var/run/dhclient-$GIFNAME.pid \
-lf /var/run/dhclient.leases-$GIFNAME \
-nw \
$GIFNAME
fi
fi
if [ "$CMD" = "P2P-GROUP-REMOVED" ]; then
GIFNAME=$3
if [ "$4" = "GO" ]; then
kill_daemon dnsmasq /var/run/dnsmasq.pid-$GIFNAME
ifconfig $GIFNAME 0.0.0.0
fi
if [ "$4" = "client" ]; then
kill_daemon dhclient /var/run/dhclient-$GIFNAME.pid
rm /var/run/dhclient.leases-$GIFNAME
ifconfig $GIFNAME 0.0.0.0
fi
fi

View File

@ -2544,6 +2544,10 @@ static void wpa_cli_action_process(const char *msg)
wpa_cli_connected = 0;
wpa_cli_exec(action_file, ctrl_ifname, "DISCONNECTED");
}
} else if (str_match(pos, P2P_EVENT_GROUP_STARTED)) {
wpa_cli_exec(action_file, ctrl_ifname, pos);
} else if (str_match(pos, P2P_EVENT_GROUP_REMOVED)) {
wpa_cli_exec(action_file, ctrl_ifname, pos);
} else if (str_match(pos, WPA_EVENT_TERMINATING)) {
printf("wpa_supplicant is terminating - stop monitoring\n");
wpa_cli_quit = 1;