#!/bin/sh

#
# Copyright (c) 2013 Qualcomm Atheros, Inc.
# All Rights Reserved.
# Qualcomm Atheros Confidential and Proprietary.
#

## Closes all the P2P VAPs and reboots the system

VAPLIST=`iwconfig | grep wlan | cut -b 1-5`

##
## ALL VAPs must be down before ANY can be destroyed
## Do this in two stages
##

    for i in $VAPLIST
    do
        echo "downing $i"
        ifconfig $i down || { echo "ifconfig $i down FAILED"; exit 1; }
    done

    sleep 1
    for i in $VAPLIST
    do
        echo "killing $i"
        wlanconfig $i destroy || { echo "wlanconfig $i destroy FAILED "; exit 1; }
    done

    sleep 3
    /etc/rc.d/rc.wlan down
    sleep 1

    reboot
