Implement total Show functions for SockAddr#441
Implement total Show functions for SockAddr#441karknu wants to merge 2 commits intohaskell:masterfrom
Conversation
kazu-yamamoto
left a comment
There was a problem hiding this comment.
I agree to throw away getNameInfo for this purpose.
- Would you start with a test case of multicast address which fails on macOS?
- Then, add your fix code. Unfortunately, @vdukhovni improved the code of
iprouterecently. So, please check it out on github.
You can use push -f for this PR as you like.
The previous implementation of show used unsafePerformIO and getNameInfo. getNameInfo depends on show SockAddr incase of a failure. The showHostAddress and showHostAddress6 are based on showIPv4 and showIPv6 in the iproute package.
5dcd18c to
cabc788
Compare
@kazu-yamamoto I've added test cases for without my patch.
From what I can see @vdukhovni's changes did not affect the show functions for IPv4 and IPv6 addresses. |
That's correct, I only changed the various getters and setters for the binary forms. |
|
@karknu @vdukhovni Thank you for clarification. This PR now looks great. Rebased and merged. Thank you for your contribution! It would be nice if we implemented |
The previous implementation of show
SockAddrusedunsafePerformIOandgetNameInfo.getNameInfodepends on showSockAddrin case of a failure which causes exceptions within exceptions within exceptions...This is not just a theoretical problem. It is possible to get
getnameinfoto fail on OSX using a multicast address with a reserved scope. This is because OSX attempts to map the second 16 bit word of an IPv6 address to a device name.Example from C's
getnameinfo:The showHostAddress and showHostAddress6 are based on showIPv4 and
showIPv6 in the iproute package.