
New patches:

[Add IPv6 support to Network.
Bryan O'Sullivan <bos@serpentine.com>**20070404223751
 
 The public API remains unchanged; it can now transparently handle IPv6
 addresses and sockets.
] {
hunk ./Network.hs 1
-{-# OPTIONS_GHC -cpp #-}
+{-# OPTIONS -cpp #-}
hunk ./Network.hs 18
+#include "HsNetworkConfig.h"
+
+#ifdef HAVE_IN6_ADDR
+-- Use IPv6-capable function definitions if the OS supports it.
+#define IPV6_SOCKET_SUPPORT 1
+#endif
+
hunk ./Network.hs 64
+import Control.Monad (liftM)
hunk ./Network.hs 96
+#if defined(IPV6_SOCKET_SUPPORT)
+-- IPv6 and IPv4.
+
+connectTo hostname (Service serv) = connect' hostname serv
+
+connectTo hostname (PortNumber port) = connect' hostname (show port)
+#else
+-- IPv4 only.
+
hunk ./Network.hs 127
+#endif
hunk ./Network.hs 140
+#if defined(IPV6_SOCKET_SUPPORT)
+connect' :: HostName -> ServiceName -> IO Handle
+
+connect' host serv = do
+    proto <- getProtocolNumber "tcp"
+    let hints = defaultHints { addrFlags = [AI_ADDRCONFIG]
+                             , addrProtocol = proto
+                             , addrSocketType = Stream }
+    addrs <- getAddrInfo (Just hints) (Just host) (Just serv)
+    let addr = head addrs
+    Exception.bracketOnError
+	(socket (addrFamily addr) (addrSocketType addr) (addrProtocol addr))
+	(sClose)  -- only done if there's an error
+	(\sock -> do
+          connect sock (addrAddress addr)
+          socketToHandle sock ReadWriteMode
+ 	)
+#endif
+
hunk ./Network.hs 171
+#if defined(IPV6_SOCKET_SUPPORT)
+-- IPv6 and IPv4.
+
+listenOn (Service serv) = listen' serv
+
+listenOn (PortNumber port) = listen' (show port)
+#else
+-- IPv4 only.
+
hunk ./Network.hs 204
+#endif
hunk ./Network.hs 219
+#if defined(IPV6_SOCKET_SUPPORT)
+listen' :: ServiceName -> IO Socket
+
+listen' serv = do
+    proto <- getProtocolNumber "tcp"
+    let hints = defaultHints { addrFlags = [AI_ADDRCONFIG, AI_PASSIVE]
+                             , addrProtocol = proto }
+    addrs <- getAddrInfo (Just hints) Nothing (Just serv)
+    let addr = head addrs
+    Exception.bracketOnError
+        (socket (addrFamily addr) (addrSocketType addr) (addrProtocol addr))
+	(sClose)
+	(\sock -> do
+	    setSocketOption sock ReuseAddr 1
+	    bindSocket sock (addrAddress addr)
+	    listen sock maxListenQueue
+	    return sock
+	)
+#endif
+
hunk ./Network.hs 245
--- Notice that although you can pass any Socket to Network.accept, only
--- sockets of either AF_UNIX or AF_INET will work (this shouldn't be a problem,
--- though). When using AF_UNIX, HostName will be set to the path of the socket
--- and PortNumber to -1.
+-- Notice that although you can pass any Socket to Network.accept,
+-- only sockets of either AF_UNIX, AF_INET, or AF_INET6 will work
+-- (this shouldn't be a problem, though). When using AF_UNIX, HostName
+-- will be set to the path of the socket and PortNumber to -1.
hunk ./Network.hs 268
+#if defined(IPV6_SOCKET_SUPPORT)
+accept sock@(MkSocket _ AF_INET6 _ _ _) = do
+ (sock', addr) <- Socket.accept sock
+ (Just peer, _) <- getNameInfo [] True False addr
+ handle <- socketToHandle sock' ReadWriteMode
+ (PortNumber port) <- socketPort sock'
+ return (handle, peer, port)
+#endif
hunk ./Network.hs 309
+
+#if defined(IPV6_SOCKET_SUPPORT)
+recvFrom host port = do
+    proto <- getProtocolNumber "tcp"
+    let hints = defaultHints { addrFlags = [AI_ADDRCONFIG]
+                             , addrProtocol = proto
+                             , addrSocketType = Stream }
+    allowed <- map addrAddress `liftM` getAddrInfo (Just hints) (Just host)
+                                                   Nothing
+    s <- listenOn port
+    let waiting = do
+        (s', addr) <- Socket.accept s
+        if not (addr `oneOf` allowed)
+         then sClose s' >> waiting
+         else socketToHandle s' ReadMode >>= hGetContents
+    waiting
+  where
+    a@(SockAddrInet _ ha) `oneOf` ((SockAddrInet _ hb):bs)
+        | ha == hb = True
+        | otherwise = a `oneOf` bs
+    a@(SockAddrInet6 _ _ ha _) `oneOf` ((SockAddrInet6 _ _ hb _):bs)
+        | ha == hb = True
+        | otherwise = a `oneOf` bs
+    _ `oneOf` _ = False
+#else
hunk ./Network.hs 353
+#endif
hunk ./Network.hs 366
-     SockAddrInet port _    -> PortNumber port
+     SockAddrInet port _      -> PortNumber port
+#if defined(IPV6_SOCKET_SUPPORT)
+     SockAddrInet6 port _ _ _ -> PortNumber port
+#endif
hunk ./Network.hs 371
-     SockAddrUnix path	    -> UnixSocket path
+     SockAddrUnix path	      -> UnixSocket path
}

Context:

[apply changes from patch "make this test deterministic on a multiprocessor" in testsuite
Simon Marlow <simonmar@microsoft.com>**20070221142822] 
[tests for use with GHC's test framework, moved from the testsuite
Simon Marlow <simonmar@microsoft.com>**20070221142258] 
[README about building from darcs
Ross Paterson <ross@soi.city.ac.uk>**20070218110201] 
[don't install Typeable.h, fixes #1106
Simon Marlow <simonmar@microsoft.com>**20070201125821] 
[network doesn't really need the html package
Ian Lynagh <igloo@earth.li>**20070111122348] 
[includes -> install-includes
Ross Paterson <ross@soi.city.ac.uk>**20060829123744] 
[change title to Haskell Hierarchical Libraries
Ross Paterson <ross@soi.city.ac.uk>**20060827131348] 
[exclude Setup.hs from build
Ross Paterson <ross@soi.city.ac.uk>**20060824183533] 
[add boilerplate Setup.hs
Ross Paterson <ross@soi.city.ac.uk>**20060824115019] 
[Update Network.BSD header to not mention symlinks.
Ian Lynagh <igloo@earth.li>**20060823184314] 
[Removed Network.CGI from the network package. A backwards-compatible new Network.CGI is available in the cgi package.
bringert@cs.chalmers.se**20060814095652] 
[remove deprecated Network.BSD.{readlink,symlink}
Simon Marlow <simonmar@microsoft.com>**20060811153755] 
[bump version to 2.0
Simon Marlow <simonmar@microsoft.com>**20060811152554] 
[depend on html (for the time being)
Simon Marlow <simonmar@microsoft.com>**20060810121424] 
[initWinSock(): have defn match proto
sof@galois.com**20060613224903] 
[only GHC has rtsSupportsBoundThreads
Ross Paterson <ross@soi.city.ac.uk>**20060531200123] 
[add files used by configure
Ross Paterson <ross@soi.city.ac.uk>**20060518174356] 
[Import unsafePerformIO
Sven Panne <sven.panne@aedion.de>**20060507171832] 
[Import MVar type
Sven Panne <sven.panne@aedion.de>**20060507170308] 
[Add various address families
Simon Marlow <simonmar@microsoft.com>**20060503081915] 
[Fix for #265, build problem on AIX
Simon Marlow <simonmar@microsoft.com>**20060316143337
 Not the fix from the ticket, but this one at least doesn't require
 modifying the configure script.
] 
[workaround for non-thread-safety of some functions in Network.BSD
Simon Marlow <simonmar@microsoft.com>**20060126153014
 Various functions in Network.BSD are non-thread-safe,
 eg. getHostByName, because the underlying gethostbyname() provided by
 the C library uses static storage.  The workaround here is to use a
 giant lock around these functions.
 
 In some cases, even the API we provide is itself unsafe, relying on
 implicit state (eg. getHostEntry), but this commit makes no attempt to
 fix that.  We should deprecate this library in favour of a complete
 replacement at some point (before 6.6 would be nice).
 
 Thanks to Einar Kartunnen for the patch.
] 
[Fix Ticket 647, Socket bug on Mac OS X
wolfgang.thaller@gmx.net**20060121050509
 Patch kindly provided by Greg Wright
] 
[TAG Initial conversion from CVS complete
John Goerzen <jgoerzen@complete.org>**20060112154134] 
Patch bundle hash:
d27c3b51a66a0b422738466096decda412ee9207
