15 if [ $PID -gt 0 ]; then
16 if ps $PID | grep -q $NAME; then
23 if [ "$CMD" = "P2P-GROUP-STARTED" ]; then
25 if [ "$4" = "GO" ]; then
26 kill_daemon udhcpc /var/run/udhcpc-$GIFNAME.pid
27 ifconfig $GIFNAME 192.168.42.1 up
28 udhcpd /etc/udhcpd-p2p.conf
30 if [ "$4" = "client" ]; then
31 kill_daemon udhcpc /var/run/udhcpc-$GIFNAME.pid
32 kill_daemon udhcpd /var/run/udhcpd-$GIFNAME.pid
33 udhcpc -i $GIFNAME -p /var/run/udhcpc-$GIFNAME.pid \
38 if [ "$CMD" = "P2P-GROUP-REMOVED" ]; then
40 if [ "$4" = "GO" ]; then
41 kill_daemon udhcpd /var/run/udhcpd-$GIFNAME.pid
42 ifconfig $GIFNAME 0.0.0.0
44 if [ "$4" = "client" ]; then
45 kill_daemon udhcpc /var/run/udhcpc-$GIFNAME.pid
46 ifconfig $GIFNAME 0.0.0.0
50 if [ "$CMD" = "P2P-CROSS-CONNECT-ENABLE" ]; then
53 # enable NAT/masquarade $GIFNAME -> $UPLINK
54 iptables -P FORWARD DROP
55 iptables -t nat -A POSTROUTING -o $UPLINK -j MASQUERADE
56 iptables -A FORWARD -i $UPLINK -o $GIFNAME -m state --state RELATED,ESTABLISHED -j ACCEPT
57 iptables -A FORWARD -i $GIFNAME -o $UPLINK -j ACCEPT
58 sysctl net.ipv4.ip_forward=1
61 if [ "$CMD" = "P2P-CROSS-CONNECT-DISABLE" ]; then
64 # disable NAT/masquarade $GIFNAME -> $UPLINK
65 sysctl net.ipv4.ip_forward=0
66 iptables -t nat -D POSTROUTING -o $UPLINK -j MASQUERADE
67 iptables -D FORWARD -i $UPLINK -o $GIFNAME -m state --state RELATED,ESTABLISHED -j ACCEPT
68 iptables -D FORWARD -i $GIFNAME -o $UPLINK -j ACCEPT