#!/system/bin/sh
# Using tap interface and iptables network for portable qemu on android
# Author: feonwan@gmail.com
# Modified: 2014-10-29

#create tun/tap device
if [ ! -e /dev/net/tun ]; then
  mkdir -p /dev/net
  busybox mknod /dev/net/tun c 10 200
  chmod 666 /dev/net/tun
fi

# create and configure virtual tap interface
busybox ifconfig -a | grep apqnet >/dev/null
if [ $? -ne 0 ]; then
  ifn=`./tunctl -b -t apqnet`
  if [ "$ifn" == "" ]; then
    echo "错误: 无法创建tap接口！"
    exit 3
  fi
else
  echo "tap接口已存在。"
fi
