[maemo-developers] icd and openvpn

From: nivwiz at gmail.com nivwiz at gmail.com
Date: Tue Mar 23 10:30:02 EET 2010
Hi all,
In order to run upnp and avahi over a cellular internet connection (3G) I am
running openvpn in bridging mode.
After I establish a connection device , tap0, I issue a dhcp request.
to do this I have added a --up script option to openvpn arguments.
here is the script :


   1. cat /etc/init.d/udhcpc
   2. #!/bin/sh
   3. #
   4. # openvpn custom dhcp cilient Start and stop
   5. #
   6.
   7. #PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

   8. DAEMON=/sbin/udhcpc

   9. NAME=udhcpc
   10. DESC="Openvpn dhcp client"

   11. # $2 is passed by openvpn with the device created ie tap0
   12. SCRIPT=/etc/openvpn/udhcp.script
   13. PIDFILE=/var/run/$NAME.$DEVICE.pid
   14.
   15. test -x $DAEMON || test -x $SCRIPT || exit 0
   16. if [ -z "$2" ] ; then
   17.         DEVICE=tap0
   18. else
   19.         DEVICE=$2
   20. fi
   21. # --now Exit with failure if a lease cannot be obtained.
   22. if [ -z "$DAEMON_OPTS" ] ; then
   23.   DAEMON_OPTS="--now --no-zeroconf -i $DEVICE -s $SCRIPT
   --pidfile=$PIDFILE"
   24. fi
   25.
   26. set -e
   27.
   28. case "$1" in
   29.   start)
   30.         echo -n "Starting $DESC for $DEVICE: "
   31.         echo " params: $DAEMON_OPTS "
   32.         while [ ! -d /sys/class/net/$DEVICE ] ; do
   33.                 echo " $DEVICE missing so can't issue dhcp req"
   34.                 sleep 2
   35.         done
   36.         ifconfig $DEVICE
   37.         echo " going to req dhcp for `cat
   /sys/class/net/$DEVICE/address`"
   38.         $DAEMON $DAEMON_OPTS
   39.         while [ $? -ne 0 ] ; do
   40.                 echo sleepNow
   41.                 sleep 2
   42.                 $DAEMON $DAEMON_OPTS
   43.         done
   44.         echo "$NAME."

   45.         ;;
   46.   starts)
   47.         start-stop-daemon --start \
   48.         --pidfile /var/run/$NAME.$DEVICE.pid \
   49.         --exec $DAEMON -- $DAEMON_OPTS
   50.         echo "$NAME."
   51.         ;;
   52.   stop)
   53.         echo -n "Stopping $DESC: "
   54.         kill `cat $PIDFILE` || true
   55.         /bin/rm $PIDFILE
   56.         echo "$NAME."
   57.         ;;
   58.   stops)
   59.         echo -n "Stopping $DESC: "
   60.         start-stop-daemon --stop --quiet \
   61.         --pidfile /var/run/$NAME.$DEVICE.pid \
   62.                 --exec $DAEMON
   63.         echo "$NAME."
   64.         ;;
   65.   reload|restart|force-reload)
   66.         #
   67.         #       If the "reload" option is implemented, move the
   "force-reload"
   68.         #       option to the "reload" entry above. If not,
   "force-reload" is
   69.         #       just the same as "restart".
   70.         #
   71.         echo -n "Restarting $DESC: "
   72.         start-stop-daemon --stop --quiet --pidfile \
   73.                 /var/run/$NAME.$DEVICE.pid --exec $DAEMON
   74.         sleep 1
   75.         start-stop-daemon --start --quiet \
   76.         --pidfile /var/run/$NAME.$DEVICE.pid \
   77.                 --background --make-pidfile \
   78.             --exec $DAEMON -- $DAEMON_OPTS
   79.         echo "$NAME."
   80.         ;;
   81.   *)
   82.         N=/etc/init.d/$NAME
   83.         # echo "Usage: $N {start|stop|restart|reload|force-reload}"
   >&2
   84.         echo "Usage: $N {start|stop|restart|force-reload}" >&2
   85.         exit 1
   86.         ;;
   87. esac
   88.
   89. exit 0






and the output:

   1. Tue Mar 23 10:03:11 2010 TUN/TAP device tap0 opened
   2. Tue Mar 23 10:03:11 2010 TUN/TAP TX queue length set to 100
   3. Tue Mar 23 10:03:11 2010 /etc/init.d/udhcpc start tap0 1500 1574
   init
   4. Starting Openvpn dhcp client for tap0:  params: --now --no-zeroconf -i
   tap0 -s /etc/openvpn/udhcp.script --pidfile=/var/run/udhcpc..pid
   5. tap0      Link encap:Ethernet  HWaddr FE:3D:5B:EB:B1:7B
   6.           BROADCAST MULTICAST  MTU:1500  Metric:1
   7.           RX packets:0 errors:0 dropped:0 overruns:0 frame:0
   8.           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
   9.           collisions:0 txqueuelen:100
   10.           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
   11.
   12.  going to req dhcp for fe:3d:5b:eb:b1:7b
   13. udhcpc (v0.9.9-pre) started
   14. Sending discover...
   15. Sending discover...
   16. Sending discover...
   17. Sending discover...
   18. No lease, failing.
   19. Tue Mar 23 10:03:24 2010 script failed: external program exited with
   error status: 1
   20. Tue Mar 23 10:03:24 2010 Exiting


so as you see it doesnt work.
can I use icd to solve this?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.maemo.org/pipermail/maemo-developers/attachments/20100323/d7b091c7/attachment.htm>
More information about the maemo-developers mailing list