Revision: 558
          http://vde.svn.sourceforge.net/vde/?rev=558&view=rev
Author:   danielel
Date:     2013-03-20 10:26:31 +0000 (Wed, 20 Mar 2013)
Log Message:
-----------
Added support for BIONIC libc to allow compilation on android toolchain.
(TODO: find an alternate solution to mkstemps() calls in vde_cryptcab to comply 
to bionic)

Modified Paths:
--------------
    trunk/vde-2/configure.ac
    trunk/vde-2/src/Makefile.am
    trunk/vde-2/src/lib/libvdeplug.c
    trunk/vde-2/src/vde_l3/vde_l3.c
    trunk/vde-2/src/vde_plug2tap.c
    trunk/vde-2/src/vde_switch/port.c
    trunk/vde-2/src/vde_switch/tuntap.c
    trunk/vde-2/src/vdetaplib/libvdetap.c

Modified: trunk/vde-2/configure.ac
===================================================================
--- trunk/vde-2/configure.ac    2013-03-07 20:55:56 UTC (rev 557)
+++ trunk/vde-2/configure.ac    2013-03-20 10:26:31 UTC (rev 558)
@@ -45,6 +45,9 @@
 AC_CHECK_HEADERS([openssl/blowfish.h], [],
   [add_cryptcab_support=no ; warn_cryptcab=yes])
 
+AC_CHECK_HEADERS([sysexits.h], [],
+  [add_over_ns_support=no ; warn_over_ns=yes])
+
 # Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
 AC_C_INLINE
@@ -94,7 +97,11 @@
 # Define VDE_LINUX or VDE_DARWIN
 case "$build_os" in
   linux*)
-    AC_DEFINE([VDE_LINUX], 1, [If defined, this is a Linux system])
+    if expr "$host_os" : ".*android" > /dev/null; then
+      AC_DEFINE([VDE_BIONIC], 1, [If defined, this is a Linux/bionic system])
+    else
+      AC_DEFINE([VDE_LINUX], 1, [If defined, this is a Linux system])
+    fi
   ;;
   darwin*)
     AC_DEFINE([VDE_DARWIN], 1, [If defined, this is a Darwin system])
@@ -127,6 +134,12 @@
     [Disable libcrypto-dependend vde_cryptcab compilation]),
   [if test $enableval = "no" ; then add_cryptcab_support=no ; warn_cryptcab=no 
; fi])
 
+# Disable vde_over_ns? (not working on android, maybe unwanted)
+AC_ARG_ENABLE([vde_over_ns],
+  AS_HELP_STRING([--disable-vde_over_ns],
+    [Disable vde_over_ns compilation]),
+  [if test $enableval = "no" ; then add_over_ns_support=no ; warn_over_ns=no ; 
fi])
+
 # Disable vde_router? (depends on lpthread, maybe unwanted)
 AC_ARG_ENABLE([router],
   AS_HELP_STRING([--disable-router],
@@ -221,6 +234,7 @@
 
 
 AM_CONDITIONAL(ENABLE_CRYPTCAB, test "$add_cryptcab_support" = yes)
+AM_CONDITIONAL(ENABLE_VDE_OVER_NS, test "$add_over_ns_support" = yes)
 AM_CONDITIONAL(ENABLE_ROUTER, test "$enable_router" = yes)
 AM_CONDITIONAL(ENABLE_PYTHON, test "$enable_python" = yes)
 AM_CONDITIONAL(ENABLE_PCAP, test "$add_pcap" = yes)
@@ -324,6 +338,14 @@
   fi
 fi
 
+if ! test x$add_over_ns_support = "xyes" ; then
+  if test x$warn_over_ns = "xyes" ; then
+    AC_MSG_WARN([VDE vde_over_ns support has been disabled because your libc
+    sysexits.h could not be found.])
+    AS_ECHO
+  fi
+fi
+
 if ! test x$enable_router = "xyes" ; then
   if test x$warn_router = "xyes" ; then
     AC_MSG_WARN([VDE Router support has been disabled because libpthread is

Modified: trunk/vde-2/src/Makefile.am
===================================================================
--- trunk/vde-2/src/Makefile.am 2013-03-07 20:55:56 UTC (rev 557)
+++ trunk/vde-2/src/Makefile.am 2013-03-20 10:26:31 UTC (rev 558)
@@ -2,7 +2,6 @@
        common \
        lib \
        vde_switch \
-       vde_over_ns \
        vde_l3 \
        slirpvde
 
@@ -31,6 +30,10 @@
   SUBDIRS += vde_cryptcab
 endif
 
+if ENABLE_VDE_OVER_NS
+  SUBDIRS += vde_over_ns
+endif
+
 if ENABLE_ROUTER
   SUBDIRS += vde_router
 endif

Modified: trunk/vde-2/src/lib/libvdeplug.c
===================================================================
--- trunk/vde-2/src/lib/libvdeplug.c    2013-03-07 20:55:56 UTC (rev 557)
+++ trunk/vde-2/src/lib/libvdeplug.c    2013-03-20 10:26:31 UTC (rev 558)
@@ -189,10 +189,10 @@
                }
        } else {
                char *split;
-               if((split = strstr(given_sockname,"->")) != NULL && 
rindex(split,':') != NULL)
+               if((split = strstr(given_sockname,"->")) != NULL && 
strrchr(split,':') != NULL)
                        flags |= VDEFLAG_UDP_SOCKET;
                else if(given_sockname[strlen(given_sockname)-1] == ']' 
-                               && (split=rindex(given_sockname,'[')) != NULL) {
+                               && (split=strrchr(given_sockname,'[')) != NULL) 
{
                        *split=0;
                        split++;
                        port=atoi(split);
@@ -282,14 +282,14 @@
                hints.ai_socktype=SOCK_DGRAM;
                *dst=0;
                dst+=2;
-               dstport=rindex(dst,':');
+               dstport=strrchr(dst,':');
                if (dstport==NULL) {
                        errno=EINVAL;
                        goto abort;
                }
                *dstport=0;
                dstport++;
-               srcport=rindex(src,':');
+               srcport=strrchr(src,':');
                if (srcport==NULL) {
                        srcport=src;
                        src=NULL;

Modified: trunk/vde-2/src/vde_l3/vde_l3.c
===================================================================
--- trunk/vde-2/src/vde_l3/vde_l3.c     2013-03-07 20:55:56 UTC (rev 557)
+++ trunk/vde-2/src/vde_l3/vde_l3.c     2013-03-20 10:26:31 UTC (rev 558)
@@ -40,7 +40,7 @@
 #define MAXCMD 255
 #define DEBUG 0
 
-#if defined(VDE_FREEBSD) || defined(VDE_DARWIN)
+#if defined(VDE_FREEBSD) || defined(VDE_DARWIN) || defined(VDE_BIONIC)
 #define ICMP_DEST_UNREACH 3
 #define ICMP_PROT_UNREACH 2
 #endif

Modified: trunk/vde-2/src/vde_plug2tap.c
===================================================================
--- trunk/vde-2/src/vde_plug2tap.c      2013-03-07 20:55:56 UTC (rev 557)
+++ trunk/vde-2/src/vde_plug2tap.c      2013-03-20 10:26:31 UTC (rev 558)
@@ -29,7 +29,7 @@
 
 #define BUFSIZE 2048
 
-#ifdef VDE_LINUX
+#if defined VDE_LINUX || defined VDE_BIONIC
 #include <net/if.h>
 #include <linux/if_tun.h>
 #endif
@@ -112,7 +112,7 @@
                { SIGUSR2, "SIGUSR2", 1 },
                { SIGPROF, "SIGPROF", 1 },
                { SIGVTALRM, "SIGVTALRM", 1 },
-#ifdef VDE_LINUX
+#if defined VDE_LINUX || defined VDE_BIONIC
                { SIGPOLL, "SIGPOLL", 1 },
 #ifdef SIGSTKFLT
                { SIGSTKFLT, "SIGSTKFLT", 1 },
@@ -172,6 +172,29 @@
 }
 #endif
 
+#ifdef VDE_BIONIC
+int open_tap(char *dev)
+{
+       struct ifreq ifr;
+       int fd;
+
+       if((fd = open("/dev/tun", O_RDWR)) < 0){
+               printlog(LOG_ERR,"Failed to open /dev/tun %s",strerror(errno));
+               return(-1);
+       }
+       memset(&ifr, 0, sizeof(ifr));
+       ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
+       strncpy(ifr.ifr_name, dev, sizeof(ifr.ifr_name) - 1);
+       /*printf("dev=\"%s\", ifr.ifr_name=\"%s\"\n", ifr.ifr_name, dev);*/
+       if(ioctl(fd, TUNSETIFF, (void *) &ifr) < 0){
+               printlog(LOG_ERR,"TUNSETIFF failed %s",strerror(errno));
+               close(fd);
+               return(-1);
+       }
+       return(fd);
+}
+#endif
+
 #if defined(VDE_DARWIN) || defined(VDE_FREEBSD)
 int open_tap(char *dev)
 {

Modified: trunk/vde-2/src/vde_switch/port.c
===================================================================
--- trunk/vde-2/src/vde_switch/port.c   2013-03-07 20:55:56 UTC (rev 557)
+++ trunk/vde-2/src/vde_switch/port.c   2013-03-20 10:26:31 UTC (rev 558)
@@ -188,6 +188,9 @@
        }
 }
 
+#ifdef VDE_BIONIC
+  static inline int user_belongs_to_group(uid_t uid, gid_t gid) { return 0; }
+#else
 /* 1 if user belongs to the group, 0 otherwise) */
 static int user_belongs_to_group(uid_t uid, gid_t gid)
 {
@@ -216,6 +219,7 @@
                }
        }
 }
+#endif
 
 
 /* Access Control check:

Modified: trunk/vde-2/src/vde_switch/tuntap.c
===================================================================
--- trunk/vde-2/src/vde_switch/tuntap.c 2013-03-07 20:55:56 UTC (rev 557)
+++ trunk/vde-2/src/vde_switch/tuntap.c 2013-03-20 10:26:31 UTC (rev 558)
@@ -29,7 +29,7 @@
 
 #ifdef HAVE_TUNTAP
 
-#ifdef VDE_LINUX
+#if defined(VDE_LINUX) || defined(VDE_BIONIC)
 #include <net/if.h>
 #include <linux/if_tun.h>
 #endif
@@ -179,6 +179,29 @@
 }
 #endif
 
+#ifdef VDE_BIONIC
+int open_tap(char *dev)
+{
+       struct ifreq ifr;
+       int fd;
+
+       if((fd = open("/dev/tun", O_RDWR)) < 0){
+               printlog(LOG_ERR,"Failed to open /dev/tun %s",strerror(errno));
+               return(-1);
+       }
+       memset(&ifr, 0, sizeof(ifr));
+       ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
+       strncpy(ifr.ifr_name, dev, sizeof(ifr.ifr_name) - 1);
+       /*printf("dev=\"%s\", ifr.ifr_name=\"%s\"\n", ifr.ifr_name, dev);*/
+       if(ioctl(fd, TUNSETIFF, (void *) &ifr) < 0){
+               printlog(LOG_ERR,"TUNSETIFF failed %s",strerror(errno));
+               close(fd);
+               return(-1);
+       }
+       return(fd);
+}
+#endif
+
 #if defined(VDE_DARWIN) || defined(VDE_FREEBSD)
 int open_tap(char *dev)
 {

Modified: trunk/vde-2/src/vdetaplib/libvdetap.c
===================================================================
--- trunk/vde-2/src/vdetaplib/libvdetap.c       2013-03-07 20:55:56 UTC (rev 
557)
+++ trunk/vde-2/src/vdetaplib/libvdetap.c       2013-03-20 10:26:31 UTC (rev 
558)
@@ -154,7 +154,11 @@
                return "";
 }
 
+#ifdef VDE_BIONIC
+int ioctl(int fd, int command, ...)
+#else
 int ioctl(int fd, unsigned long int command, ...)
+#endif
 {
        va_list ap;
        char *data;

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
vde-users mailing list
vde-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vde-users

Reply via email to