зеркало из https://github.com/github/ruby.git
* ext/socket/sockport.h (SET_SS_LEN): removed.
(SET_SIN_LEN): removed. (INIT_SOCKADDR): new macro. * ext/socket/ancdata.c (extract_ipv6_pktinfo): use INIT_SOCKADDR. * ext/socket/raddrinfo.c (make_inetaddr): use INIT_SOCKADDR. (addrinfo_ipv6_to_ipv4): ditto. * ext/socket/getaddrinfo.c (GET_AI): use INIT_SOCKADDR. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39248 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
dfbb5b677c
Коммит
1ff7108306
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
|||
Fri Feb 15 08:12:11 2013 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* ext/socket/sockport.h (SET_SS_LEN): removed.
|
||||
(SET_SIN_LEN): removed.
|
||||
(INIT_SOCKADDR): new macro.
|
||||
|
||||
* ext/socket/ancdata.c (extract_ipv6_pktinfo): use INIT_SOCKADDR.
|
||||
|
||||
* ext/socket/raddrinfo.c (make_inetaddr): use INIT_SOCKADDR.
|
||||
(addrinfo_ipv6_to_ipv4): ditto.
|
||||
|
||||
* ext/socket/getaddrinfo.c (GET_AI): use INIT_SOCKADDR.
|
||||
|
||||
Fri Feb 15 07:49:27 2013 Eric Hodel <drbrain@segment7.net>
|
||||
|
||||
* lib/rdoc.rb: Update to release version of 4.0.0
|
||||
|
|
|
@ -573,9 +573,7 @@ extract_ipv6_pktinfo(VALUE self, struct in6_pktinfo *pktinfo_ptr, struct sockadd
|
|||
|
||||
memcpy(pktinfo_ptr, RSTRING_PTR(data), sizeof(*pktinfo_ptr));
|
||||
|
||||
memset(sa_ptr, 0, sizeof(*sa_ptr));
|
||||
SET_SA_LEN((struct sockaddr *)sa_ptr, sizeof(struct sockaddr_in6));
|
||||
sa_ptr->sin6_family = AF_INET6;
|
||||
INIT_SOCKADDR((struct sockaddr *)sa_ptr, AF_INET6, sizeof(*sa_ptr));
|
||||
memcpy(&sa_ptr->sin6_addr, &pktinfo_ptr->ipi6_addr, sizeof(sa_ptr->sin6_addr));
|
||||
if (IN6_IS_ADDR_LINKLOCAL(&sa_ptr->sin6_addr))
|
||||
sa_ptr->sin6_scope_id = pktinfo_ptr->ipi6_ifindex;
|
||||
|
|
|
@ -184,9 +184,9 @@ if (pai->ai_flags & AI_CANONNAME) {\
|
|||
}\
|
||||
memcpy((ai), pai, sizeof(struct addrinfo));\
|
||||
(ai)->ai_addr = (struct sockaddr *)((ai) + 1);\
|
||||
memset((ai)->ai_addr, 0, (afd)->a_socklen);\
|
||||
SET_SA_LEN((ai)->ai_addr, (ai)->ai_addrlen = (afd)->a_socklen);\
|
||||
(ai)->ai_addr->sa_family = (ai)->ai_family = (afd)->a_af;\
|
||||
(ai)->ai_family = (afd)->a_af;\
|
||||
(ai)->ai_addrlen = (afd)->a_socklen;\
|
||||
INIT_SOCKADDR((struct sockaddr *)(ai)->ai_addr, (afd)->a_af, (afd)->a_socklen);\
|
||||
((struct sockinet *)(ai)->ai_addr)->si_port = (port);\
|
||||
p = (char *)((ai)->ai_addr);\
|
||||
memcpy(p + (afd)->a_off, (addr), (afd)->a_addrlen);\
|
||||
|
|
|
@ -253,9 +253,7 @@ make_inetaddr(unsigned int host, char *buf, size_t buflen)
|
|||
{
|
||||
struct sockaddr_in sin;
|
||||
|
||||
MEMZERO(&sin, struct sockaddr_in, 1);
|
||||
sin.sin_family = AF_INET;
|
||||
SET_SIN_LEN(&sin, sizeof(sin));
|
||||
INIT_SOCKADDR((struct sockaddr *)&sin, AF_INET, sizeof(sin));
|
||||
sin.sin_addr.s_addr = host;
|
||||
make_ipaddr0((struct sockaddr*)&sin, sizeof(sin), buf, buflen);
|
||||
}
|
||||
|
@ -1931,9 +1929,7 @@ addrinfo_ipv6_to_ipv4(VALUE self)
|
|||
addr = &((struct sockaddr_in6 *)&rai->addr)->sin6_addr;
|
||||
if (IN6_IS_ADDR_V4MAPPED(addr) || IN6_IS_ADDR_V4COMPAT(addr)) {
|
||||
struct sockaddr_in sin4;
|
||||
MEMZERO(&sin4, struct sockaddr_in, 1);
|
||||
sin4.sin_family = AF_INET;
|
||||
SET_SIN_LEN(&sin4, sizeof(sin4));
|
||||
INIT_SOCKADDR((struct sockaddr *)&sin4, AF_INET, sizeof(sin4));
|
||||
memcpy(&sin4.sin_addr, (char*)addr + sizeof(*addr) - sizeof(sin4.sin_addr), sizeof(sin4.sin_addr));
|
||||
return rsock_addrinfo_new((struct sockaddr *)&sin4, (socklen_t)sizeof(sin4),
|
||||
PF_INET, rai->socktype, rai->protocol,
|
||||
|
|
|
@ -18,17 +18,18 @@
|
|||
|
||||
#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
|
||||
# define SET_SA_LEN(sa, len) (void)((sa)->sa_len = (len))
|
||||
# define SET_SS_LEN(ss, len) (void)((ss)->ss_len = (len))
|
||||
#else
|
||||
# define SET_SA_LEN(sa, len) (void)(len)
|
||||
# define SET_SS_LEN(ss, len) (void)(len)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN
|
||||
# define SET_SIN_LEN(si,len) (si)->sin_len = (len)
|
||||
#else
|
||||
# define SET_SIN_LEN(si,len)
|
||||
#endif
|
||||
#define INIT_SOCKADDR(addr, family, len) \
|
||||
do { \
|
||||
struct sockaddr *init_sockaddr_ptr = (addr); \
|
||||
socklen_t init_sockaddr_len = (len); \
|
||||
memset(init_sockaddr_ptr, 0, init_sockaddr_len); \
|
||||
init_sockaddr_ptr->sa_family = (family); \
|
||||
SET_SA_LEN(init_sockaddr_ptr, init_sockaddr_len); \
|
||||
} while (0)
|
||||
|
||||
#ifndef IN_MULTICAST
|
||||
# define IN_CLASSD(i) (((long)(i) & 0xf0000000) == 0xe0000000)
|
||||
|
|
Загрузка…
Ссылка в новой задаче