diff options
author | Federico Ceratto <federico.ceratto@gmail.com> | 2019-01-05 21:12:53 +0000 |
---|---|---|
committer | Dominik Picheta <dominikpicheta@googlemail.com> | 2019-01-06 20:23:44 +0000 |
commit | 2fa35126b09e3487fbb82328238e59b9a4dd6d4c (patch) | |
tree | 869c4f2600d3c9ed82510ed7bdb01f3e87f7493d /lib/pure | |
parent | f3bd3691e796f4be5d522b4d0d1c64e30f985e68 (diff) | |
download | Nim-2fa35126b09e3487fbb82328238e59b9a4dd6d4c.tar.gz |
Fix getAddrInfo, add IPPROTO_ICMPV6 Closes #10198
Diffstat (limited to 'lib/pure')
-rw-r--r-- | lib/pure/nativesockets.nim | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/pure/nativesockets.nim b/lib/pure/nativesockets.nim index f98f9a444..96c377187 100644 --- a/lib/pure/nativesockets.nim +++ b/lib/pure/nativesockets.nim @@ -71,6 +71,7 @@ type IPPROTO_IPV6, ## Internet Protocol Version 6. Unsupported on Windows. IPPROTO_RAW, ## Raw IP Packets Protocol. Unsupported on Windows. IPPROTO_ICMP ## Control message protocol. Unsupported on Windows. + IPPROTO_ICMPV6 ## Control message protocol for IPv6. Unsupported on Windows. Servent* = object ## information about a service name*: string @@ -154,6 +155,7 @@ when not useWinVersion: of IPPROTO_IPV6: result = posix.IPPROTO_IPV6 of IPPROTO_RAW: result = posix.IPPROTO_RAW of IPPROTO_ICMP: result = posix.IPPROTO_ICMP + of IPPROTO_ICMPV6: result = posix.IPPROTO_ICMPV6 else: proc toInt(domain: Domain): cint = @@ -179,7 +181,7 @@ proc toSockType*(protocol: Protocol): SockType = SOCK_STREAM of IPPROTO_UDP: SOCK_DGRAM - of IPPROTO_IP, IPPROTO_IPV6, IPPROTO_RAW, IPPROTO_ICMP: + of IPPROTO_IP, IPPROTO_IPV6, IPPROTO_RAW, IPPROTO_ICMP, IPPROTO_ICMPV6: SOCK_RAW proc createNativeSocket*(domain: Domain = AF_INET, @@ -255,7 +257,8 @@ proc getAddrInfo*(address: string, port: Port, domain: Domain = AF_INET, when not defined(freebsd) and not defined(openbsd) and not defined(netbsd) and not defined(android) and not defined(haiku): if domain == AF_INET6: hints.ai_flags = AI_V4MAPPED - var gaiResult = getaddrinfo(address, $port, addr(hints), result) + let socket_port = if sockType == SOCK_RAW: "" else: $port + var gaiResult = getaddrinfo(address, socket_port, addr(hints), result) if gaiResult != 0'i32: when useWinVersion: raiseOSError(osLastError()) |