diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2012-01-28 03:17:01 +0400 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2012-01-28 03:17:01 +0400 |
commit | 22e23473ea7fd1a083c43aa33fe4d09c1b6bd34e (patch) | |
tree | 72e904e06b86c9a3a080712357b46b3693a7c923 /deps | |
parent | 38651521a8649f113e851e9ea1a8e81eaf2f0db6 (diff) |
uv: upgrade to 16124bb
Diffstat (limited to 'deps')
-rw-r--r-- | deps/uv/src/unix/udp.c | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/deps/uv/src/unix/udp.c b/deps/uv/src/unix/udp.c index 6db0ea1063b..3580e4e576c 100644 --- a/deps/uv/src/unix/udp.c +++ b/deps/uv/src/unix/udp.c @@ -528,13 +528,44 @@ int uv_udp_set_membership(uv_udp_t* handle, const char* multicast_addr, } X(multicast_loop, IPPROTO_IP, IP_MULTICAST_LOOP) -X(multicast_ttl, IPPROTO_IP, IP_MULTICAST_TTL) X(broadcast, SOL_SOCKET, SO_BROADCAST) -X(ttl, IPPROTO_IP, IP_TTL) #undef X +static int uv__udp_set_ttl(uv_udp_t* handle, int option, int ttl) { +#if __sun + char arg = ttl; +#else + int arg = ttl; +#endif + +#if __sun + if (ttl < 0 || ttl > 255) { + uv__set_sys_error(handle->loop, EINVAL); + return -1; + } +#endif + + if (setsockopt(handle->fd, IPPROTO_IP, option, &arg, sizeof(arg))) { + uv__set_sys_error(handle->loop, errno); + return -1; + } + + return 0; +} + + +int uv_udp_set_ttl(uv_udp_t* handle, int ttl) { + return uv__udp_set_ttl(handle, IP_TTL, ttl); +} + + +int uv_udp_set_multicast_ttl(uv_udp_t* handle, int ttl) { + return uv__udp_set_ttl(handle, IP_MULTICAST_TTL, ttl); +} + + int uv_udp_getsockname(uv_udp_t* handle, struct sockaddr* name, int* namelen) { socklen_t socklen; int saved_errno; |