diff options
author | flywind <43030857+xflywind@users.noreply.github.com> | 2020-09-07 18:10:20 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-07 12:10:20 +0200 |
commit | e08b802d79e173d230b893ed96fd82c3c5228161 (patch) | |
tree | ab2a1ebec22add38e01e070e015300f8d15fe82a /lib/pure | |
parent | 2f6d04fd5d302646d40abc60b611653ec58463d0 (diff) | |
download | Nim-e08b802d79e173d230b893ed96fd82c3c5228161.tar.gz |
more Protocol supports in windows (#15274) [backport:1.2]
Diffstat (limited to 'lib/pure')
-rw-r--r-- | lib/pure/nativesockets.nim | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/lib/pure/nativesockets.nim b/lib/pure/nativesockets.nim index 0b0c4b398..9303dff1d 100644 --- a/lib/pure/nativesockets.nim +++ b/lib/pure/nativesockets.nim @@ -68,11 +68,11 @@ type Protocol* = enum ## third argument to `socket` proc IPPROTO_TCP = 6, ## Transmission control protocol. IPPROTO_UDP = 17, ## User datagram protocol. - IPPROTO_IP, ## Internet protocol. Unsupported on Windows. - IPPROTO_IPV6, ## Internet Protocol Version 6. Unsupported on Windows. + IPPROTO_IP, ## Internet protocol. + IPPROTO_IPV6, ## Internet Protocol Version 6. 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. + IPPROTO_ICMP ## Control message protocol. + IPPROTO_ICMPV6 ## Control message protocol for IPv6. Servent* = object ## information about a service name*: string @@ -174,7 +174,21 @@ else: result = cint(ord(typ)) proc toInt(p: Protocol): cint = - result = cint(ord(p)) + case p + of IPPROTO_IP: + result = 0.cint + of IPPROTO_ICMP: + result = 1.cint + of IPPROTO_TCP: + result = 6.cint + of IPPROTO_UDP: + result = 17.cint + of IPPROTO_IPV6: + result = 41.cint + of IPPROTO_ICMPV6: + result = 58.cint + else: + result = cint(ord(p)) proc toSockType*(protocol: Protocol): SockType = result = case protocol |