#!/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 qlpnet >/dev/null
if [ $? -ne 0 ]; then
  ifn=`./tunctl -b -t qlpnet`
  if [ "$ifn" == "" ]; then
    echo "Error: cannot create tap interface!"
    exit 3
  fi
fi
