diff options
author | wt <iwangtongi@163.com> | 2017-04-01 04:13:06 +0800 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2017-03-31 22:13:06 +0200 |
commit | c480505797f9d82b9b19a72b5a5abde9c0cb0fd4 (patch) | |
tree | c89e7cb5a1234749b720747f4f43c5b2dab9f3bc | |
parent | 2946c7a4b9db26d238ea5d6b639e35983b34aaf5 (diff) | |
download | Nim-c480505797f9d82b9b19a72b5a5abde9c0cb0fd4.tar.gz |
Fix wrong value range of ntohs ... (#5390)
-rw-r--r-- | lib/posix/posix.nim | 8 | ||||
-rw-r--r-- | tests/async/tnewasyncudp.nim | 6 |
2 files changed, 7 insertions, 7 deletions
diff --git a/lib/posix/posix.nim b/lib/posix/posix.nim index b29f43eb4..0d11bd853 100644 --- a/lib/posix/posix.nim +++ b/lib/posix/posix.nim @@ -1862,10 +1862,10 @@ when hasAioH: a4: ptr SigEvent): cint {.importc, header: "<aio.h>".} # arpa/inet.h -proc htonl*(a1: int32): int32 {.importc, header: "<arpa/inet.h>".} -proc htons*(a1: int16): int16 {.importc, header: "<arpa/inet.h>".} -proc ntohl*(a1: int32): int32 {.importc, header: "<arpa/inet.h>".} -proc ntohs*(a1: int16): int16 {.importc, header: "<arpa/inet.h>".} +proc htonl*(a1: uint32): uint32 {.importc, header: "<arpa/inet.h>".} +proc htons*(a1: uint16): uint16 {.importc, header: "<arpa/inet.h>".} +proc ntohl*(a1: uint32): uint32 {.importc, header: "<arpa/inet.h>".} +proc ntohs*(a1: uint16): uint16 {.importc, header: "<arpa/inet.h>".} proc inet_addr*(a1: cstring): InAddrT {.importc, header: "<arpa/inet.h>".} proc inet_ntoa*(a1: InAddr): cstring {.importc, header: "<arpa/inet.h>".} diff --git a/tests/async/tnewasyncudp.nim b/tests/async/tnewasyncudp.nim index 6277e877c..bf54c0d06 100644 --- a/tests/async/tnewasyncudp.nim +++ b/tests/async/tnewasyncudp.nim @@ -33,8 +33,8 @@ proc prepareAddress(intaddr: uint32, intport: uint16): ptr Sockaddr_in = result.sin_family = toInt(nativesockets.AF_INET).int16 else: result.sin_family = toInt(nativesockets.AF_INET) - result.sin_port = htons(intport) - result.sin_addr.s_addr = htonl(intaddr) + result.sin_port = nativesockets.htons(intport) + result.sin_addr.s_addr = nativesockets.htonl(intaddr) proc launchSwarm(name: ptr SockAddr) {.async.} = var i = 0 @@ -90,7 +90,7 @@ proc readMessages(server: AsyncFD) {.async.} = await sendTo(server, addr grammString[0], len(grammString), cast[ptr SockAddr](addr saddr), slen) inc(msgCount) - saveReceivedPort(ntohs(saddr.sin_port).int) + saveReceivedPort(nativesockets.ntohs(saddr.sin_port).int) inc(i) proc createServer() {.async.} = |