Package: vnc4server
Version: 4.1.1+X4.3.0-32
Severity: wishlist
Tags: patch ipv6

Now that VNC Viewer supports IPv6 [1], it is time to add IPv6 support to VNC 
Server too. Here is a patch which does
that. I hope you will find it useful.

With this patch, unless the "-localhost" option is given, the VNC server will 
create an IPv6-capable socket which
listens on all available IPv4 and IPv6 addresses. This corresponds to 
/proc/sys/net/ipv6/bindv6only = 0, and is the
default behavior of the network stack.

[1] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=342620

--- System information. ---
Architecture: amd64
Kernel:       Linux 2.6.31.2-rm2

Debian Release: squeeze/sid
  500 testing         natsu.ipv6.rm.pp.ru 

--- Package information. ---
Depends               (Version) | Installed
===============================-+-=============
libc6                  (>= 2.3) | 2.9-25
libgcc1            (>= 1:4.1.1) | 1:4.4.1-4
libice6            (>= 1:1.0.0) | 2:1.0.5-1
libsm6                          | 2:1.1.1-1
libstdc++6           (>= 4.1.1) | 4.4.1-4
libx11-6                        | 2:1.2.2-1
libxext6                        | 2:1.0.4-1
libxtst6                        | 2:1.0.3-1
zlib1g             (>= 1:1.1.4) | 1:1.2.3.3.dfsg-15
xbase-clients                   | 1:7.4+4
x11-common                      | 1:7.4+4
 OR xserver-common              | 


Recommends       (Version) | Installed
==========================-+-===========
xfonts-base                | 1:1.0.0-6


Suggests      (Version) | Installed
=======================-+-===========
vnc-java                | 

-- 
With respect,
Roman
--- orig/vnc4-4.1.1+X4.3.0/common/network/TcpSocket.cxx	2009-10-13 03:39:50.000000000 +0600
+++ vnc4-4.1.1+X4.3.0/common/network/TcpSocket.cxx	2009-10-13 05:03:27.409382727 +0600
@@ -314,8 +314,17 @@
     return;
   }
 
+  bool use_ipv6 = false;
+  int af = AF_INET;
+#ifdef AF_INET6
+  // - localhostOnly will mean "127.0.0.1 only", no IPv6
+  use_ipv6 = !localhostOnly;
+  if (use_ipv6)
+    af = AF_INET6;
+#endif
+
   initSockets();
-  if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
+  if ((fd = socket(af, SOCK_STREAM, 0)) < 0)
     throw SocketException("unable to create listening socket", errorNumber);
 
 #ifndef WIN32
@@ -333,14 +342,25 @@
 
   // - Bind it to the desired port
   struct sockaddr_in addr;
-  memset(&addr, 0, sizeof(addr));
-  addr.sin_family = AF_INET;
-  addr.sin_port = htons(port);
-  if (localhostOnly)
-    addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
-  else
-    addr.sin_addr.s_addr = htonl(INADDR_ANY);
-  if (bind(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
+  struct sockaddr_in6 addr6;
+  struct sockaddr *sa;
+  int sa_len;
+  if (use_ipv6) {
+    memset(&addr6, 0, (sa_len = sizeof(addr6)));
+    addr6.sin6_family = AF_INET6;
+    addr6.sin6_port = htons(port);
+    sa = (struct sockaddr*) &addr6;
+  } else {
+    memset(&addr, 0, (sa_len = sizeof(addr)));
+    addr.sin_family = AF_INET;
+    addr.sin_port = htons(port);
+    if (localhostOnly)
+      addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+    else
+      addr.sin_addr.s_addr = htonl(INADDR_ANY);
+    sa = (struct sockaddr*) &addr;
+  }
+  if (bind(fd, sa, sa_len) < 0) {
     int e = errorNumber;
     closesocket(fd);
     throw SocketException("unable to bind listening socket", e);

Attachment: signature.asc
Description: PGP signature

Reply via email to