summaryrefslogtreecommitdiff
path: root/ext/socket/socket.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/socket/socket.c')
-rw-r--r--ext/socket/socket.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index d13b7e9..67bfcb3 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -1055,7 +1055,7 @@ sock_gethostname(VALUE obj)
#endif
static VALUE
-make_addrinfo(struct addrinfo *res0, int norevlookup)
+make_addrinfo(struct rb_addrinfo *res0, int norevlookup)
{
VALUE base, ary;
struct addrinfo *res;
@@ -1064,7 +1064,7 @@ make_addrinfo(struct addrinfo *res0, int norevlookup)
rb_raise(rb_eSocket, "host not found");
}
base = rb_ary_new();
- for (res = res0; res; res = res->ai_next) {
+ for (res = res0->ai; res; res = res->ai_next) {
ary = rsock_ipaddr(res->ai_addr, res->ai_addrlen, norevlookup);
if (res->ai_canonname) {
RARRAY_PTR(ary)[2] = rb_str_new2(res->ai_canonname);
@@ -1287,7 +1287,8 @@ static VALUE
sock_s_getaddrinfo(int argc, VALUE *argv)
{
VALUE host, port, family, socktype, protocol, flags, ret, revlookup;
- struct addrinfo hints, *res;
+ struct addrinfo hints;
+ struct rb_addrinfo *res;
int norevlookup;
rb_scan_args(argc, argv, "25", &host, &port, &family, &socktype, &protocol, &flags, &revlookup);
@@ -1310,7 +1311,7 @@ sock_s_getaddrinfo(int argc, VALUE *argv)
res = rsock_getaddrinfo(host, port, &hints, 0);
ret = make_addrinfo(res, norevlookup);
- freeaddrinfo(res);
+ rb_freeaddrinfo(res);
return ret;
}
@@ -1343,7 +1344,8 @@ sock_s_getnameinfo(int argc, VALUE *argv)
char *hptr, *pptr;
char hbuf[1024], pbuf[1024];
int fl;
- struct addrinfo hints, *res = NULL, *r;
+ struct rb_addrinfo *res = NULL;
+ struct addrinfo hints, *r;
int error;
union_sockaddr ss;
struct sockaddr *sap;
@@ -1428,8 +1430,8 @@ sock_s_getnameinfo(int argc, VALUE *argv)
hints.ai_family = NIL_P(af) ? PF_UNSPEC : rsock_family_arg(af);
error = rb_getaddrinfo(hptr, pptr, &hints, &res);
if (error) goto error_exit_addr;
- sap = res->ai_addr;
- salen = res->ai_addrlen;
+ sap = res->ai->ai_addr;
+ salen = res->ai->ai_addrlen;
}
else {
rb_raise(rb_eTypeError, "expecting String or Array");
@@ -1440,7 +1442,7 @@ sock_s_getnameinfo(int argc, VALUE *argv)
pbuf, sizeof(pbuf), fl);
if (error) goto error_exit_name;
if (res) {
- for (r = res->ai_next; r; r = r->ai_next) {
+ for (r = res->ai->ai_next; r; r = r->ai_next) {
char hbuf2[1024], pbuf2[1024];
sap = r->ai_addr;
@@ -1449,20 +1451,20 @@ sock_s_getnameinfo(int argc, VALUE *argv)
pbuf2, sizeof(pbuf2), fl);
if (error) goto error_exit_name;
if (strcmp(hbuf, hbuf2) != 0|| strcmp(pbuf, pbuf2) != 0) {
- freeaddrinfo(res);
+ rb_freeaddrinfo(res);
rb_raise(rb_eSocket, "sockaddr resolved to multiple nodename");
}
}
- freeaddrinfo(res);
+ rb_freeaddrinfo(res);
}
return rb_assoc_new(rb_str_new2(hbuf), rb_str_new2(pbuf));
error_exit_addr:
- if (res) freeaddrinfo(res);
+ if (res) rb_freeaddrinfo(res);
rsock_raise_socket_error("getaddrinfo", error);
error_exit_name:
- if (res) freeaddrinfo(res);
+ if (res) rb_freeaddrinfo(res);
rsock_raise_socket_error("getnameinfo", error);
UNREACHABLE;
@@ -1485,10 +1487,10 @@ sock_s_getnameinfo(int argc, VALUE *argv)
static VALUE
sock_s_pack_sockaddr_in(VALUE self, VALUE port, VALUE host)
{
- struct addrinfo *res = rsock_addrinfo(host, port, 0, 0);
- VALUE addr = rb_str_new((char*)res->ai_addr, res->ai_addrlen);
+ struct rb_addrinfo *res = rsock_addrinfo(host, port, 0, 0);
+ VALUE addr = rb_str_new((char*)res->ai->ai_addr, res->ai->ai_addrlen);
- freeaddrinfo(res);
+ rb_freeaddrinfo(res);
OBJ_INFECT(addr, port);
OBJ_INFECT(addr, host);