Opened 7 years ago

Closed 7 years ago

Last modified 4 years ago

#1212 closed proposal (fixed)

Add IPv6 support to network library

Reported by: bos@… Owned by:
Priority: normal Milestone: Not GHC
Component: libraries/network Version: 6.6
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Difficulty: Moderate (less than a day)
Test Case: Blocked By:
Blocking: Related Tickets:

Description

This proposal adds two standard protocol-independent functions to Network.BSD to allow the networking code to work with both IPv6 and IPv4 addresses and protocols.

getAddrInfo is the equivalent of getaddrinfo from RFC 2553.
getNameInfo is the equivalent of getnameinfo from RFC 2553.

These functions rely on a few new types:

AddrInfo
AddrInfoFlags
NameInfoFlags

Several global values provide mnemonics for query hints and flags.

Both of these functions are available on all modern operating systems. They unify name and service lookup for IPv4 and IPv6. The code has been autoconfiscated so that it will not be compiled if IPv6 support is not available.

I have not touched existing code in any way, save to add and extend the smallest possible number of types and functions so that IPv6 addresses can be accommodated.

Attachments (4)

ipv6.patch (32.5 KB) - added by bos@… 7 years ago.
ipv6.2.patch (19.4 KB) - added by bos@… 7 years ago.
ipv6.3.patch (19.4 KB) - added by guest 7 years ago.
ipv6.4.patch (21.7 KB) - added by guest 7 years ago.

Download all attachments as: .zip

Change History (16)

Changed 7 years ago by bos@…

comment:1 Changed 7 years ago by guest

I should mention that there's a darcs repo available here:

http://darcs.serpentine.com/network6

And formatted haddocks here:

http://darcs.serpentine.com/network6/docs/Network-BSD.html

comment:2 Changed 7 years ago by bos@…

Does 1 week seem like a reasonable timescale for consideration?

comment:3 Changed 7 years ago by panne

I haven't looked into the patch in detail, but I have one general remark: It is very bad if the set of exported entities of a Haskell module is platform-dependent. This leads to the need of an "autoconf at the Haskell level", which is not very desirable. Your suggested patch is not the only culprit in the standard libraries, but let at least not make things worse. A better strategy is to supply default values and/or fallback implementations for things not directly supported on the platform in question, even if the implementation is more limited or even 'ioError (userError "not supported")'. This way, platform differences can be handled at runtime, often during normal error handling.

comment:4 Changed 7 years ago by bos

Sven, thanks for your comments. I'll be happy to trim off the non-portable options.

comment:5 Changed 7 years ago by guest

Peter Simons suggests that in fact Network.Socket would be a better home for all of the new functionality, instead of Network.BSD, as the IPv6 entry points and constants do not have a BSD heritage (they're defined in RFC 2553, and available on all modern operating systems under the same names). I agree. Furthermore, adding this functionality to Network.Socket will mean that new code will never need to import Network.BSD.

As a consequence of Peter and Sven's comments, I'm going to redo the patch, and tender it for consideration again in a day or two, then extend the discussion period for another week.

Changed 7 years ago by bos@…

comment:6 Changed 7 years ago by bos@…

I've attached the final version of this patch, which is tidier and uses a few more standard combinators I hadn't noticed before.

Changed 7 years ago by guest

comment:7 Changed 7 years ago by guest

I've improved the docs in the attachment I just added.

Changed 7 years ago by guest

comment:8 Changed 7 years ago by guest

darcs repo here:

darcs get --partial http://darcs.serpentine.com/network6

comment:9 Changed 7 years ago by igloo

  • Resolution set to fixed
  • Status changed from new to closed

Now applied, thanks!

comment:10 Changed 6 years ago by simonmar

  • Architecture changed from Multiple to Unknown/Multiple

comment:11 Changed 6 years ago by simonmar

  • Operating System changed from Multiple to Unknown/Multiple

comment:12 Changed 4 years ago by simonmar

  • Difficulty changed from Moderate (1 day) to Moderate (less than a day)
Note: See TracTickets for help on using tickets.