Skip to content

Commit 6e29977

Browse files
DavidBuchanan314AileenLumina
authored andcommitted
Dirty hack: Implement get_addr with inet_pton
1 parent 6cb4629 commit 6e29977

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

python_config/getaddrinfo.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,33 @@ get_addr(hostname, af, res, pai, port0)
545545
top = NULL;
546546
sentinel.ai_next = NULL;
547547
cur = &sentinel;
548+
549+
#ifdef SWITCH // XXX dirty hack XXX
550+
struct sockaddr_in *saddr;
551+
552+
if (!(af == AF_INET || af == AF_UNSPEC))
553+
return EAI_NODATA;
554+
555+
saddr = calloc(1, sizeof(*saddr));
556+
saddr->sin_family = AF_INET;
557+
saddr->sin_port = port0;
558+
559+
/* XXX libnx inet_pton is currently broken, we will ignore the return value for now... */
560+
if (inet_pton(AF_INET, hostname, &(saddr->sin_addr)) != 1 && 0) {
561+
free(saddr);
562+
error = EAI_NODATA;
563+
goto free;
564+
}
565+
566+
top = calloc(1, sizeof(*top));
567+
top->ai_family = AF_INET;
568+
top->ai_addrlen = sizeof(*saddr);
569+
top->ai_addr = (struct sockaddr *) saddr;
570+
571+
*res = top;
572+
return SUCCESS;
573+
#endif
574+
548575
#ifdef ENABLE_IPV6
549576
if (af == AF_UNSPEC) {
550577
hp = getipnodebyname(hostname, AF_INET6,

0 commit comments

Comments
 (0)