summaryrefslogtreecommitdiff
path: root/src/core/net-nonblock.c
diff options
context:
space:
mode:
authorailin-nemui <ailin-nemui@users.noreply.github.com>2015-09-22 21:59:17 +0200
committerailin-nemui <ailin-nemui@users.noreply.github.com>2015-09-22 21:59:17 +0200
commitf5f3d7cc98f24799f562e8d3126ea1c2786a6547 (patch)
treec229a706535599a59c4f29ea14db769859686465 /src/core/net-nonblock.c
parent2d69deb0a36516bac9514c6d53a1389b0a4b031a (diff)
downloadirssi-f5f3d7cc98f24799f562e8d3126ea1c2786a6547.zip
Revert "Network and IPv{4,6} related changes"
Diffstat (limited to 'src/core/net-nonblock.c')
-rw-r--r--src/core/net-nonblock.c38
1 files changed, 28 insertions, 10 deletions
diff --git a/src/core/net-nonblock.c b/src/core/net-nonblock.c
index bc8c4b96..e637e673 100644
--- a/src/core/net-nonblock.c
+++ b/src/core/net-nonblock.c
@@ -103,12 +103,15 @@ int net_gethostbyname_nonblock(const char *addr, GIOChannel *pipe,
srand(time(NULL));
memset(&rec, 0, sizeof(rec));
- rec.error = net_gethostbyname(addr, &rec.ip);
+ rec.error = net_gethostbyname(addr, &rec.ip4, &rec.ip6);
if (rec.error == 0) {
errorstr = NULL;
if (reverse_lookup) {
/* reverse lookup the IP, ignore any error */
- net_gethostbyaddr(&rec.ip, &rec.host);
+ if (rec.ip4.family != 0)
+ net_gethostbyaddr(&rec.ip4, &rec.host4);
+ if (rec.ip6.family != 0)
+ net_gethostbyaddr(&rec.ip6, &rec.host6);
}
} else {
errorstr = net_gethosterror(rec.error);
@@ -119,11 +122,18 @@ int net_gethostbyname_nonblock(const char *addr, GIOChannel *pipe,
if (rec.errlen != 0)
g_io_channel_write_block(pipe, (void *) errorstr, rec.errlen);
else {
- if (rec.host) {
- len = strlen(rec.host) + 1;
+ if (rec.host4) {
+ len = strlen(rec.host4) + 1;
g_io_channel_write_block(pipe, (void *) &len,
sizeof(int));
- g_io_channel_write_block(pipe, (void *) rec.host,
+ g_io_channel_write_block(pipe, (void *) rec.host4,
+ len);
+ }
+ if (rec.host6) {
+ len = strlen(rec.host6) + 1;
+ g_io_channel_write_block(pipe, (void *) &len,
+ sizeof(int));
+ g_io_channel_write_block(pipe, (void *) rec.host6,
len);
}
}
@@ -144,7 +154,8 @@ int net_gethostbyname_return(GIOChannel *pipe, RESOLVED_IP_REC *rec)
rec->error = -1;
rec->errorstr = NULL;
- rec->host = NULL;
+ rec->host4 = NULL;
+ rec->host6 = NULL;
#ifndef WIN32
fcntl(g_io_channel_unix_get_fd(pipe), F_SETFL, O_NONBLOCK);
@@ -163,10 +174,15 @@ int net_gethostbyname_return(GIOChannel *pipe, RESOLVED_IP_REC *rec)
rec->errorstr = g_malloc0(rec->errlen+1);
g_io_channel_read_block(pipe, rec->errorstr, rec->errlen);
} else {
- if (rec->host) {
+ if (rec->host4) {
+ g_io_channel_read_block(pipe, &len, sizeof(int));
+ rec->host4 = g_malloc0(len);
+ g_io_channel_read_block(pipe, rec->host4, len);
+ }
+ if (rec->host6) {
g_io_channel_read_block(pipe, &len, sizeof(int));
- rec->host = g_malloc0(len);
- g_io_channel_read_block(pipe, rec->host, len);
+ rec->host6 = g_malloc0(len);
+ g_io_channel_read_block(pipe, rec->host6, len);
}
}
@@ -211,6 +227,7 @@ static void simple_readpipe(SIMPLE_THREAD_REC *rec, GIOChannel *pipe)
{
RESOLVED_IP_REC iprec;
GIOChannel *handle;
+ IPADDR *ip;
g_return_if_fail(rec != NULL);
@@ -224,8 +241,9 @@ static void simple_readpipe(SIMPLE_THREAD_REC *rec, GIOChannel *pipe)
g_io_channel_shutdown(rec->pipes[1], TRUE, NULL);
g_io_channel_unref(rec->pipes[1]);
+ ip = iprec.ip4.family != 0 ? &iprec.ip4 : &iprec.ip6;
handle = iprec.error == -1 ? NULL :
- net_connect_ip(&iprec.ip, rec->port, rec->my_ip);
+ net_connect_ip(ip, rec->port, rec->my_ip);
g_free_not_null(rec->my_ip);