Only in openvpn-2.2.2: .deps
Only in openvpn-2.2.2: base64.o
Only in openvpn-2.2.2: buffer.o
Only in openvpn-2.2.2: build.log
Only in openvpn-2.2.2: client2.ovpn
Only in openvpn-2.2.2: conf.cmd
Only in openvpn-2.2.2: config.h
Only in openvpn-2.2.2: config.log
Only in openvpn-2.2.2: config.status
Only in openvpn-2.2.2: configure.h
Only in openvpn-2.2.2: configure.lineno
Only in openvpn-2.2.2: configure.log
Only in openvpn-2.2.2: crypto.o
Only in openvpn-2.2.2: cryptoapi.o
Only in openvpn-2.2.2: dhcp.o
Only in openvpn-2.2.2: error.o
Only in openvpn-2.2.2: event.o
diff -ur openvpn-2.2.2-o/fdmisc.c openvpn-2.2.2/fdmisc.c
--- openvpn-2.2.2-o/fdmisc.c	2011-04-26 18:03:04.000000000 +0930
+++ openvpn-2.2.2/fdmisc.c	2019-09-21 18:48:30.000000000 +0930
@@ -37,6 +37,10 @@
   u_long arg = 1;
   if (ioctlsocket (fd, FIONBIO, &arg))
     return false;
+#elif __OS2__
+ u_long arg = 1;
+ if (ioctl (fd, FIONBIO, &arg))
+     return false;
 #else
   if (fcntl (fd, F_SETFL, O_NONBLOCK) < 0)
     return false;
@@ -48,7 +52,7 @@
 bool
 set_cloexec_action (int fd)
 {
-#ifndef WIN32
+#if !defined(WIN32) && !defined(__OS2)
   if (fcntl (fd, F_SETFD, FD_CLOEXEC) < 0)
     return false;
 #endif
Only in openvpn-2.2.2: fdmisc.o
Only in openvpn-2.2.2: forward.o
Only in openvpn-2.2.2: fragment.o
Only in openvpn-2.2.2: gremlin.o
Only in openvpn-2.2.2: helper.o
Only in openvpn-2.2.2: httpdigest.o
Only in openvpn-2.2.2: ieproxy.o
Only in openvpn-2.2.2/images: Makefile
diff -ur openvpn-2.2.2-o/init.c openvpn-2.2.2/init.c
--- openvpn-2.2.2-o/init.c	2011-12-14 03:28:56.000000000 +1030
+++ openvpn-2.2.2/init.c	2019-09-21 18:48:30.000000000 +0930
@@ -267,6 +267,7 @@
 next_connection_entry (struct context *c)
 {
 #ifdef ENABLE_CONNECTION
+
   struct connection_list *l = c->options.connection_list;
   if (l)
     {
@@ -1887,7 +1888,9 @@
        * Initialize the OpenSSL library's global
        * SSL context.
        */
+
       c->c1.ks.ssl_ctx = init_ssl (options);
+
       if (!c->c1.ks.ssl_ctx)
 	{
 #if P2MP
@@ -3033,9 +3036,12 @@
 init_instance_handle_signals (struct context *c, const struct env_set *env, const unsigned int flags)
 {
   pre_init_signal_catch ();
+
   init_instance (c, env, flags);
+
   post_init_signal_catch ();
 
+
   /*
    * This is done so that signals thrown during
    * initialization can bring us back to
Only in openvpn-2.2.2: init.c.orig
Only in openvpn-2.2.2: init.o
Only in openvpn-2.2.2/install-win32: Makefile
Only in openvpn-2.2.2/install-win32: settings
Only in openvpn-2.2.2: interval.o
Only in openvpn-2.2.2: list.o
Only in openvpn-2.2.2: lladdr.o
Only in openvpn-2.2.2: log
Only in openvpn-2.2.2: lzo.o
Only in openvpn-2.2.2: manage.o
Only in openvpn-2.2.2: mbuf.o
Only in openvpn-2.2.2: misc.o
Only in openvpn-2.2.2: mroute.o
Only in openvpn-2.2.2: mss.o
Only in openvpn-2.2.2: mtcp.o
Only in openvpn-2.2.2: mtu.o
Only in openvpn-2.2.2: mudp.o
Only in openvpn-2.2.2: multi.o
Only in openvpn-2.2.2: Makefile
Only in openvpn-2.2.2: ntlm.o
Only in openvpn-2.2.2: occ.o
Only in openvpn-2.2.2: openvpn
diff -ur openvpn-2.2.2-o/openvpn.c openvpn-2.2.2/openvpn.c
--- openvpn-2.2.2-o/openvpn.c	2011-12-14 03:28:56.000000000 +1030
+++ openvpn-2.2.2/openvpn.c	2019-09-21 18:48:30.000000000 +0930
@@ -106,6 +106,14 @@
      only be initialized once per program instantiation. */
   c.first_time = true;
 
+#ifdef __OS2__
+   if (sock_init() != 0) 
+      {
+      msg (M_SOCKERR,"INET.SYS probably is not running");
+      return 1;
+      }
+#endif
+
   /* initialize program-wide statics */
   if (init_static ())
     {
Only in openvpn-2.2.2: openvpn.exe
Only in openvpn-2.2.2: openvpn.help
Only in openvpn-2.2.2: openvpn.map
Only in openvpn-2.2.2: openvpn.o
diff -ur openvpn-2.2.2-o/options.c openvpn-2.2.2/options.c
--- openvpn-2.2.2-o/options.c	2011-12-14 03:28:56.000000000 +1030
+++ openvpn-2.2.2/options.c	2019-09-21 18:48:30.000000000 +0930
@@ -4736,7 +4736,11 @@
       if (p[2])
 	{
 	  if (streq (p[2], "execve"))
+#ifndef __OS2__ //on os2 fork() execv exit is broken
 	    script_method = SM_EXECVE;
+#else
+            script_method = SM_SYSTEM;
+#endif
 	  else if (streq (p[2], "system"))
 	    script_method = SM_SYSTEM;
 	  else
@@ -4746,7 +4750,11 @@
 	    }
 	}
       else
+#ifndef __OS2__
 	script_method = SM_EXECVE;
+#else
+        script_method = SM_SYSTEM;
+#endif
     }
   else if (streq (p[0], "mssfix"))
     {
Only in openvpn-2.2.2: options.c.orig
Only in openvpn-2.2.2: options.o
Only in openvpn-2.2.2: otime.o
Only in openvpn-2.2.2: packet_id.o
Only in openvpn-2.2.2: patch.log
Only in openvpn-2.2.2: perf.o
Only in openvpn-2.2.2: pf.o
Only in openvpn-2.2.2: ping.o
Only in openvpn-2.2.2: pkcs11.o
Only in openvpn-2.2.2: plugin.o
Only in openvpn-2.2.2: pool.o
Only in openvpn-2.2.2: proto.o
Only in openvpn-2.2.2: proxy.o
Only in openvpn-2.2.2: ps.o
Only in openvpn-2.2.2: push.o
Only in openvpn-2.2.2: reliable.o
diff -ur openvpn-2.2.2-o/route.c openvpn-2.2.2/route.c
--- openvpn-2.2.2-o/route.c	2011-12-14 03:28:56.000000000 +1030
+++ openvpn-2.2.2/route.c	2019-09-21 18:48:30.000000000 +0930
@@ -997,7 +997,7 @@
   argv_msg (D_ROUTE, &argv);
   status = openvpn_execve_check (&argv, es, 0, "ERROR: OS X route add command failed");
 
-#elif defined(TARGET_OPENBSD) || defined(TARGET_NETBSD)
+#elif defined(TARGET_OPENBSD) || defined(TARGET_NETBSD) || defined(__OS2__)
 
   argv_printf (&argv, "%s add",
 		ROUTE_PATH);
@@ -1145,7 +1145,7 @@
   argv_msg (D_ROUTE, &argv);
   openvpn_execve_check (&argv, es, 0, "ERROR: OS X route delete command failed");
 
-#elif defined(TARGET_OPENBSD) || defined(TARGET_NETBSD)
+#elif defined(TARGET_OPENBSD) || defined(TARGET_NETBSD) || defined(__OS2__)
 
   argv_printf (&argv, "%s delete -net %s %s -netmask %s",
 		ROUTE_PATH,
Only in openvpn-2.2.2: route.c.orig
Only in openvpn-2.2.2: route.o
Only in openvpn-2.2.2: schedule.o
Only in openvpn-2.2.2/service-win32: .deps
Only in openvpn-2.2.2/service-win32: Makefile
Only in openvpn-2.2.2: session_id.o
Only in openvpn-2.2.2: shaper.o
Only in openvpn-2.2.2: sig.o
diff -ur openvpn-2.2.2-o/socket.c openvpn-2.2.2/socket.c
--- openvpn-2.2.2-o/socket.c	2011-12-14 03:28:56.000000000 +1030
+++ openvpn-2.2.2/socket.c	2019-09-21 18:48:30.000000000 +0930
@@ -34,6 +34,9 @@
 #include "misc.h"
 
 #include "memdbg.h"
+#ifdef __OS2__
+#include "netdb.h"
+#endif
 
 const int proto_overhead[] = { /* indexed by PROTO_x */
   IPv4_UDP_HEADER_SIZE,
@@ -794,7 +797,14 @@
     }
 
   if (!nowait && openvpn_close_socket (sd))
+#ifdef __OS2__
+   {
+#endif
     msg (M_SOCKERR, "TCP: close socket failed (sd)");
+#ifdef __OS2__
+    psock_errno("Close");
+     }
+#endif
 
   tcp_connection_established (act);
 
Only in openvpn-2.2.2: socket.c.orig
diff -ur openvpn-2.2.2-o/socket.h openvpn-2.2.2/socket.h
--- openvpn-2.2.2-o/socket.h	2011-12-14 03:28:56.000000000 +1030
+++ openvpn-2.2.2/socket.h	2019-09-21 18:48:30.000000000 +0930
@@ -35,6 +35,9 @@
 #include "proxy.h"
 #include "socks.h"
 #include "misc.h"
+#ifdef __OS2__
+#include "nerrno.h"
+#endif
 
 /*
  * OpenVPN's default port number as assigned by IANA.
@@ -612,6 +615,9 @@
 	  const int err = openvpn_errno_socket ();
 #ifdef WIN32
 	  return err == WSAECONNRESET || err == WSAECONNABORTED;
+#elif defined (__OS2__)
+          psock_errno("Link (SOCECONNRESET):");
+          return err == SOCECONNRESET;
 #else
 	  return err == ECONNRESET;
 #endif
Only in openvpn-2.2.2: socket.h.orig
Only in openvpn-2.2.2: socket.o
Only in openvpn-2.2.2: socks.o
diff -ur openvpn-2.2.2-o/ssl.c openvpn-2.2.2/ssl.c
--- openvpn-2.2.2-o/ssl.c	2011-12-14 03:28:56.000000000 +1030
+++ openvpn-2.2.2/ssl.c	2019-09-21 18:48:30.000000000 +0930
@@ -3560,6 +3560,8 @@
       buf_printf (&out, "IV_PLAT=freebsd\n");
 #elif defined(WIN32)
       buf_printf (&out, "IV_PLAT=win\n");
+#elif defined(__OS2__)
+      buf_printf (&out, "IV_PLAT=os2\n");
 #endif
 
       /* push mac addr */
Only in openvpn-2.2.2: ssl.c.orig
Only in openvpn-2.2.2: ssl.o
Only in openvpn-2.2.2: stamp-h1
Only in openvpn-2.2.2: status.o
diff -ur openvpn-2.2.2-o/syshead.h openvpn-2.2.2/syshead.h
--- openvpn-2.2.2-o/syshead.h	2011-12-14 03:28:56.000000000 +1030
+++ openvpn-2.2.2/syshead.h	2019-09-21 18:48:30.000000000 +0930
@@ -53,6 +53,18 @@
 #define srandom srand
 #endif
 
+#ifdef __OS2__
+#define INCL_DOSDATETIME
+#define INCL_DOSDEVICES
+#define INCL_DOSDEVIOCTL
+#define INCL_DOSERRORS
+#define INCL_DOSPROCESS
+#define INCL_DOSPROFILE
+#define INCL_DOSFILEMGR
+#define INCL_DOSSEMAPHORES
+#include <os2.h>
+#endif
+
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
Only in openvpn-2.2.2: syshead.h.orig
diff -ur openvpn-2.2.2-o/t_client.sh openvpn-2.2.2/t_client.sh
--- openvpn-2.2.2-o/t_client.sh	2011-12-14 21:51:44.000000000 +1030
+++ openvpn-2.2.2/t_client.sh	2019-09-21 18:51:18.000000000 +0930
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!sh
 #
 # run OpenVPN client against ``test reference'' server
 # - check that ping, http, ... via tunnel works
@@ -80,12 +80,12 @@
 get_ifconfig_route()
 {
     # linux / iproute2? (-> if configure got a path)
-    if [ "/sbin/ip" != "ip" ]
+    if [ "ip" != "ip" ]
     then
 	echo "-- linux iproute2 --"
-	/sbin/ip addr show     | grep -v valid_lft
-	/sbin/ip route show
-	/sbin/ip -6 route show | sed -e 's/expires [0-9]*sec //'
+	ip addr show     | grep -v valid_lft
+	ip route show
+	ip -6 route show | sed -e 's/expires [0-9]*sec //'
 	return
     fi
 
@@ -93,27 +93,27 @@
     case `uname -s` in
 	Linux)
 	   echo "-- linux / ifconfig --"
-	   LANG=C /sbin/ifconfig -a |egrep  "( addr:|encap:)"
-	   LANG=C /bin/netstat -rn -4 -6
+	   LANG=C C:/MPTN/BIN/ifconfig.exe -a |egrep  "( addr:|encap:)"
+	   LANG=C C:/MPTN/BIN/netstat.exe -rn -4 -6
 	   return
 	   ;;
 	FreeBSD|NetBSD|Darwin)
 	   echo "-- FreeBSD/NetBSD/Darwin [MacOS X] --"
-	   /sbin/ifconfig -a | egrep "(flags=|inet)"
-	   /bin/netstat -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$NF }'
+	   C:/MPTN/BIN/ifconfig.exe -a | egrep "(flags=|inet)"
+	   C:/MPTN/BIN/netstat.exe -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$NF }'
 	   return
 	   ;;
 	OpenBSD)
 	   echo "-- OpenBSD --"
-	   /sbin/ifconfig -a | egrep "(flags=|inet)" | \
+	   C:/MPTN/BIN/ifconfig.exe -a | egrep "(flags=|inet)" | \
 		sed -e 's/pltime [0-9]*//' -e 's/vltime [0-9]*//'
-	   /bin/netstat -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$NF }'
+	   C:/MPTN/BIN/netstat.exe -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$NF }'
 	   return
 	   ;;
 	SunOS)
 	   echo "-- Solaris --"
-	   /sbin/ifconfig -a | egrep "(flags=|inet)"
-	   /bin/netstat -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$6 }'
+	   C:/MPTN/BIN/ifconfig.exe -a | egrep "(flags=|inet)"
+	   C:/MPTN/BIN/netstat.exe -rn | awk '$3 !~ /^UHL/ { print $1,$2,$3,$6 }'
 	   return
 	   ;;
     esac
diff -ur openvpn-2.2.2-o/tun.c openvpn-2.2.2/tun.c
--- openvpn-2.2.2-o/tun.c	2011-12-14 03:28:56.000000000 +1030
+++ openvpn-2.2.2/tun.c	2019-09-29 19:09:54.000000000 +0930
@@ -558,6 +558,9 @@
   tt->adapter_index = ~0;
 #endif
 }
+#ifdef __OS2__
+char DevNode[8];
+#endif
 
 /* execute the ifconfig command through the shell */
 void
@@ -881,6 +884,55 @@
 	  r.gateway = tt->local;
 	  add_route (&r, tt, 0, es);
 	}
+#elif defined(__OS2__)
+      /* example: ifconfig tun2 10.2.0.2 10.2.0.1 mtu 1450 netmask 255.255.255.255 up */
+      if (tun)
+	argv_printf (&argv,
+			  " %s %s %s %s mtu %d netmask 255.255.255.255",
+                        IFCONFIG_PATH,
+                        DevNode,
+			ifconfig_local,
+			ifconfig_remote_netmask,
+			tun_mtu
+			);
+      else
+         {
+           if (tt->topology == TOP_SUBNET)
+        	argv_printf (&argv,
+			  "%s %s %s %s netmask %s mtu %d up",
+                        IFCONFIG_PATH,
+                        DevNode,
+                        ifconfig_local,
+                        ifconfig_local,
+                        ifconfig_remote_netmask,
+                        tun_mtu
+			);
+        else
+    	    argv_printf (&argv,
+			      "%s %s %s netmask %s mtu %d up",
+			      IFCONFIG_PATH,
+			      DevNode,
+			      ifconfig_local,
+			      ifconfig_remote_netmask,
+			      tun_mtu
+			      );
+	}
+	
+      argv_msg (M_INFO, &argv);
+      openvpn_execve_check(&argv, es, S_FATAL, "OS/2 ifconfig failed");
+      tt->did_ifconfig = true;
+
+      /* Add a network route for the local tun interface */
+      if (!tun && tt->topology == TOP_SUBNET)
+	{
+	  struct route r;
+	  CLEAR (r);
+	  r.defined = true;
+	  r.network = tt->local & tt->remote_netmask;
+	  r.netmask = tt->remote_netmask;
+	  r.gateway = tt->local;
+	  add_route (&r, tt, 0, es);
+	}
 
 #elif defined(TARGET_FREEBSD)||defined(TARGET_DRAGONFLY)
 
@@ -4532,6 +4584,375 @@
   return BSTR (&out);
 }
 
+#elif defined(__OS2__)
+
+#define	 pBIOCSETBUFFERSIZE 20
+#pragma pack(1)
+#define IO_NET_SIZE		(65536)
+typedef struct _NET_BUFFER
+{
+	unsigned int	uHead;
+	unsigned int	uTail;
+	unsigned int	uReceivingOffs;
+	unsigned int	uLastByte;
+	unsigned int	uDrvError;
+	unsigned int	bRecPacketPresent;
+	unsigned int	bNetworkAdapterActive;
+	unsigned char	aBuffer[IO_NET_SIZE];
+} NET_BUFFER, *PNET_BUFFER;
+
+typedef struct _SET_NET_BUFFER
+{
+		unsigned char *pBufferAddress;
+		unsigned int  uiSize;
+		unsigned int	uiAdapterType;
+} SET_NET_BUFFER, *PSET_NET_BUFFER;
+#pragma pack()
+
+
+SET_NET_BUFFER NetBuffer;
+unsigned char *Packet=0;
+ULONG Init=0;
+ULONG BytesReturned;
+HFILE Os2Drv = 0;
+char TcpAddr[]="192.168.100.100";
+int opt=1;
+char SockPath[]="\\socket\\OpenVpn";
+ULONG HasRead = 0;
+
+void PrintBuf(char *nam,char *b,unsigned int s)
+{
+FILE *fp;
+int i,j;
+  if( (fp=fopen(nam,"a+")) == NULL)
+    {
+    printf("Error in %s\n",nam);
+    perror(nam);
+    return;
+    }
+fprintf(fp,"     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f\n");
+for(i=0; i < s; i += 16)
+   {
+    fprintf(fp,"%4.4x ",i);
+    for(j =0;j < 16;j++)
+       fprintf(fp,"%2.2x ",b[i+j]);
+    fprintf(fp," ");
+    for(j =0;j < 16;j++)
+       if(b[i+j] > ' ')
+         fprintf(fp,"%1.1c",b[i+j]);
+       else
+         fprintf(fp,".");
+     fprintf(fp,"\n");
+    }
+fflush(fp);
+DosBufReset((HFILE)fileno(fp));
+fclose(fp);
+}
+
+unsigned short port = 1961;      /* port server binds to                  */
+int ns = 0;                       /* socket connected to client            */
+int RunningThread = 0;            // Thread in work 0 - exit, 1 - working
+void WriteWork(void *Num)
+{
+    struct sockaddr_un tcp_client; /* client address information            */
+    struct sockaddr_un tcp_server; /* server address information            */
+    int tcpsock;                   /* socket for accepting connections      */
+    int namelen;                   /* length of client name                 */
+    int sockint, client_address_size;
+    fd_set rdfds;                  /* read set mask for select() call */
+    int width=0;                   /* # bits to be checked for select() call */
+    int readysock=0;
+    struct timeval timeout;
+    APIRET rc;
+    ULONG i;
+    ULONG BytesTransfered;
+    unsigned char *Buffer;
+    int  len;
+
+
+//  DosSetPriority ( PRTYS_THREAD, PRTYC_TIMECRITICAL, PRTYD_MAXIMUM, 0);
+  rc = DosAllocMem((void**)&Buffer, 0x1000  , PAG_COMMIT|PAG_READ|PAG_WRITE|PAG_EXECUTE );
+   if ( rc ) return;
+/*
+ *
+ * TCP SERVER
+ *
+ * Get a TCP socket for accepting connections.
+ */
+    if ((tcpsock = socket(PF_OS2, SOCK_STREAM, 0)) < 0)
+    {
+        psock_errno("Write Socket()");
+        return;
+    }
+/*
+ * Bind the TCP socket to the server address.
+ */
+
+    memset(&tcp_server,0,sizeof(tcp_server));
+    tcp_server.sun_len = sizeof(tcp_server);
+    tcp_server.sun_family  = AF_OS2;
+    strncpy(tcp_server.sun_path,SockPath,strlen(SockPath));
+
+    if ( bind(tcpsock, (struct sockaddr *)&tcp_server, sizeof(tcp_server)) < 0)
+       {
+        psock_errno("Write Bind(tcp)");
+        printf("addr:%x\n",inet_addr(TcpAddr));
+        return;
+       }
+/*
+ * Listen for connections. Specify the backlog as 5.
+ */
+    if (listen(tcpsock, 5) != 0)
+    {
+        psock_errno("Write Listen(tcp)");
+        return;
+    }
+
+
+   namelen = sizeof(tcp_client);
+   if ((ns = accept(tcpsock, (struct sockaddr *)&tcp_client, &namelen)) == -1)
+      {
+      psock_errno("Accept(tcp)");
+      return;
+      }
+
+   while ( RunningThread )
+       {
+       /*
+        * Receive the message on the newly connected socket.
+        */
+       len = recv(ns, Buffer, 0x1000, 0);
+       if (len == -1)
+          {
+          psock_errno("Recv(tcp)");
+          return;
+          }
+       if ( !len ) return;
+       rc = DosWrite( Os2Drv, Buffer, len, &BytesTransfered);
+//       PrintBuf("Write.buf",Buffer,BytesTransfered);
+//       DosResetBuffer ( Os2Drv );
+      if ( BytesTransfered != len )
+          printf("Error len: %d Write %d bytes rc=%d\n",len,BytesTransfered,rc);
+//      DosSleep(BytesTransfered >> 10);
+      } /* end of for(;;) loop */
+
+
+}
+char TapDevice[8] = "OVPNET$";
+PSZ     szSemName  = "\\SEM32\\OPENVPN\\TAP"; /* Semaphore name */
+HEV     hevTap   = 0;                         /* Event semaphore handle    */
+void ReadWork(void *Num)
+{
+int s;
+APIRET rc;
+ULONG BytesTransfered;
+unsigned char *Buffer;
+ULONG Bread[2], Ret,tmp, inrc = 4;
+int socks[1];
+
+
+  DosSetPriority ( PRTYS_THREAD, PRTYC_TIMECRITICAL, PRTYD_MAXIMUM, 0);
+  rc = DosAllocMem((void**)&Buffer, 0x1000 , PAG_COMMIT|PAG_READ|PAG_WRITE|PAG_EXECUTE );
+  if ( rc ) return;
+  while ( RunningThread )
+        {
+        rc = DosResetEventSem ( hevTap, &inrc );    // Здесь может быть rc = 300
+        if ( rc )
+           printf ("sem reset rc=%d\n",rc);
+        rc = DosRead( Os2Drv, Buffer, (ULONG)0x1000, &BytesTransfered);
+//           printf("Read %d bytes rc=%d\n",BytesTransfered,rc);
+        if ( BytesTransfered == 0 )
+           {
+           printf("Read %d bytes rc=%d\n",BytesTransfered,rc);
+           DosSleep (2);
+           return;
+           }
+        socks[0]=ns;
+        rc = os2_select ( socks, 0 , 1, 0 , -1 );
+//           printf("Read %d bytes rc=%d\n",BytesTransfered,rc);
+        if ( (Ret = send(ns, Buffer, BytesTransfered , 0)) < 0 )
+           {
+           printf("Read %d bytes rc=%d\n",BytesTransfered,rc);
+           psock_errno("Read Send()");
+           return;
+           }
+      if ( BytesTransfered != Ret )
+          printf("Error len: %d Read %d bytes rc=%d\n",Ret,BytesTransfered,rc);
+//        PrintBuf("Read.buf",Buffer,BytesTransfered);
+// #ifdef Drova
+        rc = DosWaitEventSem ( hevTap, (ULONG) SEM_INDEFINITE_WAIT); /* As long as it takes       */
+        if ( rc )
+           printf ("sem wait rc=%d\n",rc);
+// #endif
+        }
+ printf("ReadThread Ending %d\n", RunningThread);
+}
+int myS;
+
+void
+open_tun (const char *dev, const char *dev_type, const char *dev_node, bool ipv6, struct tuntap *tt)
+{
+ULONG rc,Action,inrc;
+struct sockaddr_un server; /* server address                           */
+int s;                     /* client socket                            */
+fprintf(stderr,"dev_node = %s\n", dev_node);
+      if (dev_node)// For ifconfig command
+	{
+	  openvpn_snprintf (DevNode, sizeof (DevNode), "%s", dev_node);
+	}
+
+    if ( dev[3] > ' ' )
+       {
+        msg (M_ERR, "Error Open_tun (%s) type %s devnode %s UNDER CONSTRUCTION",dev,dev_type,dev_node,rc);
+        return;
+       }
+    rc = DosOpen(TapDevice,&Os2Drv,&Action,NULL,NULL,
+                           OPEN_ACTION_OPEN_IF_EXISTS,
+                           OPEN_FLAGS_FAIL_ON_ERROR | OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYREADWRITE,
+                           NULL);
+    if (rc != 0)
+       {
+        msg (M_ERR, "Error Open_tun (%s) type %s devnode %s DosOpen rc= %d\n",dev,dev_type,dev_node,rc);
+        return;
+       }
+
+    rc = DosAllocMem((void**)&Packet,(unsigned long)sizeof(NET_BUFFER) + 4096 , PAG_COMMIT|PAG_READ|PAG_WRITE|PAG_EXECUTE );
+
+    if (rc != 0)
+       {
+        msg (M_ERR, "Error Open_tun (%s) type %s devnode %s AllocMem rc= %d\n",dev,dev_type,dev_node,rc);
+        return;
+       }
+
+     NetBuffer.pBufferAddress = Packet;
+     NetBuffer.uiSize         = sizeof(NET_BUFFER);
+
+    inrc = 2;
+    BytesReturned  = 4;
+    inrc=4;
+    rc = DosDevIOCtl( Os2Drv, 0x88, pBIOCSETBUFFERSIZE , &Action, 2 , &inrc , &NetBuffer, BytesReturned, &BytesReturned );
+    if (rc != 0)
+       {
+        msg (M_ERR, "Error Open_tun (%s) type %s devnode %s DosDevIOCtl rc= %d\n",dev,dev_type,dev_node,rc);
+        return;
+       }
+
+     rc = DosCreateEventSem(szSemName,      /* Name of semaphore to create  */
+                            &hevTap,        /* Handle of semaphore returned */
+                            DC_SEM_SHARED,  /* Shared semaphore             */
+                            FALSE);         /* Semaphore is in RESET state  */
+    if (rc != 0)
+       {
+        msg (M_ERR, "Error1 Open_tun (%s) type %s devnode %s DosDevIOCtl rc= %d\n",dev,dev_type,dev_node,rc);
+        return;
+       }
+
+   RunningThread = 1;
+   _beginthread(WriteWork,NULL,32768,(void *)NULL);
+   DosSleep(10);       // Give time for run
+    /*
+     * Get a stream socket.
+     */
+    if ((s = socket(PF_OS2, SOCK_STREAM, 0)) < 0)
+       {
+        msg (M_ERR, "Error Open_tun (%s) type %s devnode %s socket\n",dev,dev_type,dev_node);
+        psock_errno("Socket(open)");
+        return;
+       }
+
+    /*
+     * Put the server information into the server structure.
+     * The port must be put into network byte order.
+     */
+    memset(&server,0,sizeof(server));
+    server.sun_len = sizeof(server);
+    server.sun_family  = AF_OS2;
+    strncpy(server.sun_path,SockPath,strlen(SockPath));
+
+    /*
+     * Connect to the server.
+     */
+    if (connect(s, (struct sockaddr *)&server, sizeof(server)) < 0)
+       {
+        msg (M_ERR, "Error Open_tun (%s) type %s devnode %s connect\n",dev,dev_type,dev_node);
+        psock_errno("Connect(open)");
+        return;
+       }
+
+   _beginthread(ReadWork ,NULL,32768,(void *)s);
+//   _beginthread(WaitKeyboard ,NULL,32768,(void *)s);
+   tt->fd = s;
+   set_nonblock (s);
+//  DosSetPriority ( PRTYS_THREAD, PRTYC_TIMECRITICAL, PRTYD_MAXIMUM, 0);
+  myS = s;
+//   set_block (s);
+}
+void PostSem(int i)
+{
+APIRET rc;
+//  if ( i != myS )
+//     rc = DosPostEventSem ( hevTap );
+//      if ( rc ) printf("PostSem rc = %d\n", rc);
+}
+
+void
+close_tun (struct tuntap* tt)
+{
+ULONG rc, Bread[2], Ret,tmp, inrc = 4;
+
+  if (Os2Drv)
+     {
+     RunningThread = 0;
+     inrc = 2;
+     Ret  = 4;
+     Bread[0] = 1;
+     soclose(ns);
+     rc = DosDevIOCtl( Os2Drv, 0x88, 0x5c , &tmp, 2 , &inrc , Bread, Ret, &Ret );
+     DosSleep(1000);
+     DosClose(Os2Drv);
+     Os2Drv = 0;
+     free (tt);
+     }
+}
+
+ULONG EventWrite = 0;
+int
+write_tun (struct tuntap* tt, uint8_t *buf, int len)
+{
+APIRET rc;
+int i;
+unsigned char *Buffer;
+int socks[1];
+
+    socks[0]=tt->fd;
+    rc = os2_select ( socks, 0 , 1, 0 , -1 );
+    i = send ( tt->fd, buf, len, 0 );
+    if ( i < 0)
+       {
+        msg (M_ERR, "write_tun ");
+        psock_errno("Send()");
+        return ( -1 );
+       }
+  return i;
+}
+int
+read_tun (struct tuntap* tt, uint8_t *buf, int len)
+{
+APIRET rc;
+int i;
+unsigned char *Buffer;
+
+    i = recv(tt->fd, buf, len, 0);
+    if ( i  < 0)
+       {
+        msg (M_ERR, "read_tun ");
+        psock_errno("Recv()");
+        return( -1 );
+       }
+  rc = DosPostEventSem ( hevTap );
+  return i;
+}
+
 #else /* generic */
 
 void
Only in openvpn-2.2.2: tun.c.orig
Only in openvpn-2.2.2: tun.o
Only in openvpn-2.2.2: US-Washingtoni_DC_2_UDP1194_SMART.ovpn
Only in openvpn-2.2.2: win32.o
