pkgsrc-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

net/openvpn DragonFly support



Hi!

The attached patch enables openvpn to function properly under DragonFly BSD. 
The changes should not affect other OSs since they are DragonFly specific.
Index: distinfo
===================================================================
RCS file: /cvsroot/pkgsrc/net/openvpn/distinfo,v
retrieving revision 1.9
diff -d -u -r1.9 distinfo
--- distinfo    5 Jul 2006 15:50:05 -0000       1.9
+++ distinfo    11 Dec 2006 12:21:22 -0000
@@ -3,8 +3,9 @@
 SHA1 (openvpn-2.0.7.tar.gz) = 74a4d19e42ca226f50ab5bdba16aa4a130c5e431
 RMD160 (openvpn-2.0.7.tar.gz) = b89f6df5ff08326f4e07e6cd4abda633627ef9e4
 Size (openvpn-2.0.7.tar.gz) = 665129 bytes
-SHA1 (patch-ab) = 05c9df0a7a71cb1cfa4a2f132df02cac822ba3ba
-SHA1 (patch-ac) = 7a225a0b88dcf0039cd40f72a10564c72f41b2f1
-SHA1 (patch-ad) = ee577ad5c5621bbfa05d522e85e467e937929f6e
-SHA1 (patch-ae) = b6f8f869b5c727120df8dd433e54ffe3537e0006
-SHA1 (patch-af) = ae697790e648c4d351c8c99e21ff79a56c572ddf
+SHA1 (patch-ab) = 9268bca82b7b9f0f4e18b2d272e1fd0f723ca53c
+SHA1 (patch-ac) = dbeb3c51d86454af9c013b32270ce0604a27ebf4
+SHA1 (patch-ad) = edb1109d5b405345837dda9a7b5631eaff3ac6e7
+SHA1 (patch-ae) = 1441384d20a1361cfc8b493b74b9e24970251196
+SHA1 (patch-af) = 03aac9bf0eea4cca035ad9be2840d25c9b68f919
+SHA1 (patch-ag) = 833d46e5ad559f5a93fceee41fbdba65136b50e6
Index: patches/patch-ab
===================================================================
RCS file: /cvsroot/pkgsrc/net/openvpn/patches/patch-ab,v
retrieving revision 1.4
diff -d -u -r1.4 patch-ab
--- patches/patch-ab    11 Apr 2006 20:09:52 -0000      1.4
+++ patches/patch-ab    11 Dec 2006 12:21:22 -0000
@@ -13,3 +13,32 @@
  #ifdef HAVE_NET_IF_TUN_H
  #include <net/if_tun.h>
  #endif
+--- syshead.h.orig     2006-12-11 10:32:08.000000000 +0100
++++ syshead.h  2006-12-11 10:37:17.000000000 +0100
+@@ -252,6 +252,26 @@
+ 
+ #endif /* TARGET_FREEBSD */
+ 
++#ifdef TARGET_DRAGONFLY
++
++#ifdef HAVE_SYS_UIO_H
++#include <sys/uio.h>
++#endif
++
++#ifdef HAVE_NETINET_IN_SYSTM_H
++#include <netinet/in_systm.h>
++#endif
++
++#ifdef HAVE_NETINET_IP_H
++#include <netinet/ip.h>
++#endif
++
++#ifdef HAVE_NET_TUN_IF_TUN_H
++#include <net/tun/if_tun.h>
++#endif
++
++#endif /* TARGET_DRAGONFLY */
++
+ #ifdef TARGET_NETBSD
+ 
+ #ifdef HAVE_NET_IF_TAP_H
Index: patches/patch-ac
===================================================================
RCS file: /cvsroot/pkgsrc/net/openvpn/patches/patch-ac,v
retrieving revision 1.3
diff -d -u -r1.3 patch-ac
--- patches/patch-ac    11 Apr 2006 20:09:52 -0000      1.3
+++ patches/patch-ac    11 Dec 2006 12:21:22 -0000
@@ -41,3 +41,126 @@
                {
                  openvpn_snprintf (tunname, sizeof (tunname),
                                    "/dev/%s%d", dev, i);
+--- tun.c.orig 2006-12-11 10:38:09.000000000 +0100
++++ tun.c      2006-12-11 10:41:24.000000000 +0100
+@@ -767,6 +767,30 @@
+       system_check (command_line, es, S_FATAL, "FreeBSD ifconfig failed");
+       tt->did_ifconfig = true;
+ 
++#elif defined(TARGET_DRAGONFLY)
++
++      /* example: ifconfig tun2 10.2.0.2 10.2.0.1 mtu 1450 netmask 
255.255.255.255 up */
++      if (tun)
++        openvpn_snprintf (command_line, sizeof (command_line),
++                          IFCONFIG_PATH " %s %s %s mtu %d netmask 
255.255.255.255 up",
++                          actual,
++                          ifconfig_local,
++                          ifconfig_remote_netmask,
++                          tun_mtu
++                          );
++      else
++        openvpn_snprintf (command_line, sizeof (command_line),
++                          IFCONFIG_PATH " %s %s netmask %s mtu %d up",
++                          actual,
++                          ifconfig_local,
++                          ifconfig_remote_netmask,
++                          tun_mtu
++                          );
++
++      msg (M_INFO, "%s", command_line);
++      system_check (command_line, es, S_FATAL, "FreeBSD ifconfig failed");
++      tt->did_ifconfig = true;
++
+ #elif defined (WIN32)
+       {
+       const char *netmask;
+@@ -1641,6 +1665,89 @@
+     return read (tt->fd, buf, len);
+ }
+ 
++#elif defined(TARGET_DRAGONFLY)
++
++static inline int
++freebsd_modify_read_write_return (int len)
++{
++  if (len > 0)
++    return len > sizeof (u_int32_t) ? len - sizeof (u_int32_t) : 0;
++  else
++    return len;
++}
++
++void
++open_tun (const char *dev, const char *dev_type, const char *dev_node, bool 
ipv6, struct tuntap *tt)
++{
++  open_tun_generic (dev, dev_type, dev_node, ipv6, true, true, tt);
++
++  if (tt->fd >= 0)
++    {
++      int i = 0;
++
++      /* Disable extended modes */
++      ioctl (tt->fd, TUNSLMODE, &i);
++      i = 1;
++      ioctl (tt->fd, TUNSIFHEAD, &i);
++    }
++}
++
++void
++close_tun (struct tuntap *tt)
++{
++  if (tt)
++    {
++      close_tun_generic (tt);
++      free (tt);
++    }
++}
++
++int
++write_tun (struct tuntap* tt, uint8_t *buf, int len)
++{
++  if (tt->type == DEV_TYPE_TUN)
++    {
++      u_int32_t type;
++      struct iovec iv[2];
++      struct ip *iph;
++
++      iph = (struct ip *) buf;
++
++      if (tt->ipv6 && iph->ip_v == 6)
++        type = htonl (AF_INET6);
++      else
++        type = htonl (AF_INET);
++
++      iv[0].iov_base = (char *)&type;
++      iv[0].iov_len = sizeof (type);
++      iv[1].iov_base = buf;
++      iv[1].iov_len = len;
++
++      return freebsd_modify_read_write_return (writev (tt->fd, iv, 2));
++    }
++  else
++    return write (tt->fd, buf, len);
++}
++
++int
++read_tun (struct tuntap* tt, uint8_t *buf, int len)
++{
++  if (tt->type == DEV_TYPE_TUN)
++    {
++      u_int32_t type;
++      struct iovec iv[2];
++
++      iv[0].iov_base = (char *)&type;
++      iv[0].iov_len = sizeof (type);
++      iv[1].iov_base = buf;
++      iv[1].iov_len = len;
++
++      return freebsd_modify_read_write_return (readv (tt->fd, iv, 2));
++    }
++  else
++    return read (tt->fd, buf, len);
++}
++
+ #elif defined(WIN32)
+ 
+ int
Index: patches/patch-ad
===================================================================
RCS file: /cvsroot/pkgsrc/net/openvpn/patches/patch-ad,v
retrieving revision 1.1
diff -d -u -r1.1 patch-ad
--- patches/patch-ad    11 Apr 2006 20:09:52 -0000      1.1
+++ patches/patch-ad    11 Dec 2006 12:21:22 -0000
@@ -12,3 +12,27 @@
  /* Define to 1 if you have the <net/if_tun.h> header file. */
  #undef HAVE_NET_IF_TUN_H
  
+--- config.h.in.orig   2006-12-11 11:15:42.000000000 +0100
++++ config.h.in        2006-12-11 11:16:11.000000000 +0100
+@@ -433,6 +433,9 @@
+ /* Are we running on FreeBSD? */
+ #undef TARGET_FREEBSD
+ 
++/* Are we running on DragonFly */
++#undef TARGET_DRAGONFLY
++
+ /* Are we running on Linux? */
+ #undef TARGET_LINUX
+ 
+--- config.h.in.orig   2006-12-11 13:08:09.000000000 +0100
++++ config.h.in        2006-12-11 13:04:35.000000000 +0100
+@@ -207,6 +207,9 @@
+ /* Define to 1 if you have the <net/if_tun.h> header file. */
+ #undef HAVE_NET_IF_TUN_H
+ 
++/* Define to 1 if you have the <net/tun/if_tun.h> header file. */
++#undef HAVE_NET_TUN_IF_TUN_H
++
+ /* Define to 1 if you have the `nice' function. */
+ #undef HAVE_NICE
+ 
Index: patches/patch-ae
===================================================================
RCS file: /cvsroot/pkgsrc/net/openvpn/patches/patch-ae,v
retrieving revision 1.1
diff -d -u -r1.1 patch-ae
--- patches/patch-ae    11 Apr 2006 20:09:52 -0000      1.1
+++ patches/patch-ae    11 Dec 2006 12:21:22 -0000
@@ -7,7 +7,19 @@
                 stdarg.h unistd.h signal.h stdio.h string.h dnl
                 strings.h ctype.h errno.h syslog.h pwd.h grp.h dnl
 -               net/if_tun.h net/if.h stropts.h sys/sockio.h dnl
-+               net/if_tap.h net/if_tun.h net/if.h stropts.h sys/sockio.h dnl
++               net/if_tap.h net/if_tun.h net/tun/if_tun.h net/if.h stropts.h 
sys/sockio.h dnl
                 netinet/in.h netinet/in_systm.h netinet/ip.h dnl
                 netinet/if_ether.h netinet/tcp.h resolv.h arpa/inet.h dnl
                 netdb.h sys/uio.h linux/if_tun.h linux/sockios.h dnl
+--- configure.ac.orig  2006-12-11 10:26:42.000000000 +0100
++++ configure.ac       2006-12-11 10:27:14.000000000 +0100
+@@ -222,6 +222,9 @@
+ *freebsd*)
+       AC_DEFINE(TARGET_FREEBSD, 1, [Are we running on FreeBSD?])
+       ;;
++*dragonfly*)
++        AC_DEFINE(TARGET_DRAGONFLY, 1, [Are we running on DragonFly?])
++        ;;
+ *netbsd*)
+       AC_DEFINE(TARGET_NETBSD, 1, [Are we running NetBSD?])
+       ;;
Index: patches/patch-af
===================================================================
RCS file: /cvsroot/pkgsrc/net/openvpn/patches/patch-af,v
retrieving revision 1.1
diff -d -u -r1.1 patch-af
--- patches/patch-af    11 Apr 2006 20:09:52 -0000      1.1
+++ patches/patch-af    11 Dec 2006 12:21:22 -0000
@@ -7,7 +7,23 @@
  
  
 -for ac_header in sys/time.h sys/socket.h sys/ioctl.h sys/stat.h               
 sys/mman.h fcntl.h sys/file.h stdlib.h stdint.h                 stdarg.h 
unistd.h signal.h stdio.h string.h             strings.h ctype.h errno.h 
syslog.h pwd.h grp.h                  net/if_tun.h net/if.h stropts.h 
sys/sockio.h            netinet/in.h netinet/in_systm.h netinet/ip.h            
netinet/if_ether.h netinet/tcp.h resolv.h arpa/inet.h           netdb.h 
sys/uio.h linux/if_tun.h linux/sockios.h                linux/types.h 
sys/poll.h sys/epoll.h
-+for ac_header in sys/time.h sys/socket.h sys/ioctl.h sys/stat.h               
 sys/mman.h fcntl.h sys/file.h stdlib.h stdint.h                 stdarg.h 
unistd.h signal.h stdio.h string.h             strings.h ctype.h errno.h 
syslog.h pwd.h grp.h                  net/if_tap.h net/if_tun.h net/if.h 
stropts.h sys/sockio.h               netinet/in.h netinet/in_systm.h 
netinet/ip.h            netinet/if_ether.h netinet/tcp.h resolv.h arpa/inet.h   
        netdb.h sys/uio.h linux/if_tun.h linux/sockios.h                
linux/types.h sys/poll.h sys/epoll.h
++for ac_header in sys/time.h sys/socket.h sys/ioctl.h sys/stat.h               
 sys/mman.h fcntl.h sys/file.h stdlib.h stdint.h                 stdarg.h 
unistd.h signal.h stdio.h string.h             strings.h ctype.h errno.h 
syslog.h pwd.h grp.h                  net/if_tap.h net/if_tun.h 
net/tun/if_tun.h net/if.h stropts.h sys/sockio.h              netinet/in.h 
netinet/in_systm.h netinet/ip.h            netinet/if_ether.h netinet/tcp.h 
resolv.h arpa/inet.h           netdb.h sys/uio.h linux/if_tun.h linux/sockios.h 
               linux/types.h sys/poll.h sys/epoll.h
  do
  as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
  if eval "test \"\${$as_ac_Header+set}\" = set"; then
+--- configure.orig     2006-12-11 10:56:40.000000000 +0100
++++ configure  2006-12-11 10:57:02.000000000 +0100
+@@ -2282,6 +2282,13 @@
+ _ACEOF
+ 
+       ;;
++*dragonfly*)
++
++cat >>confdefs.h <<\_ACEOF
++#define TARGET_DRAGONFLY 1
++_ACEOF
++
++        ;;
+ *netbsd*)
+ 
+ cat >>confdefs.h <<\_ACEOF
--- /dev/null   2006-12-11 13:20:28.000000000 +0100
+++ patches/patch-ag    2006-12-11 10:54:26.000000000 +0100
@@ -0,0 +1,46 @@
+--- route.c.orig       2006-12-11 10:43:59.000000000 +0100
++++ route.c    2006-12-11 10:49:45.000000000 +0100
+@@ -759,6 +759,17 @@
+   msg (D_ROUTE, "%s", BSTR (&buf));
+   status = system_check (BSTR (&buf), es, 0, "ERROR: FreeBSD route add 
command failed");
+ 
++#elif defined(TARGET_DRAGONFLY)
++
++  buf_printf (&buf, ROUTE_PATH " add");
++  buf_printf (&buf, " -net %s %s %s",
++              network,
++              gateway,
++              netmask);
++
++  msg (D_ROUTE, "%s", BSTR (&buf));
++  status = system_check (BSTR (&buf), es, 0, "ERROR: DragonFly route add 
command failed");
++
+ #elif defined(TARGET_DARWIN)
+ 
+   buf_printf (&buf, ROUTE_PATH " add");
+@@ -882,6 +893,16 @@
+   msg (D_ROUTE, "%s", BSTR (&buf));
+   system_check (BSTR (&buf), es, 0, "ERROR: FreeBSD route delete command 
failed");
+ 
++#elif defined(TARGET_DRAGONFLY)
++
++  buf_printf (&buf, ROUTE_PATH " delete -net %s %s %s",
++              network,
++              gateway,
++              netmask);
++
++  msg (D_ROUTE, "%s", BSTR (&buf));
++  system_check (BSTR (&buf), es, 0, "ERROR: DragonFly route delete command 
failed");
++
+ #elif defined(TARGET_DARWIN)
+ 
+   buf_printf (&buf, ROUTE_PATH " delete -net %s %s %s",
+@@ -1308,7 +1329,7 @@
+   return ret;
+ }
+ 
+-#elif defined(TARGET_FREEBSD)
++#elif defined(TARGET_FREEBSD) || defined(TARGET_DRAGONFLY)
+ 
+ #include <sys/types.h>
+ #include <sys/socket.h>


Home | Main Index | Thread Index | Old Index