Skip to content

Commit 450da69

Browse files
committed
add IPv6 support to socket.gethostbyaddr on Solaris
1 parent e66bec0 commit 450da69

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

Modules/socketmodule.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6404,6 +6404,20 @@ _socket_gethostbyaddr(PyObject *module, PyObject *hobj)
64046404
PyErr_SetString(PyExc_OSError, "unsupported address family");
64056405
goto finally;
64066406
}
6407+
#if defined(__sun) && defined(ENABLE_IPV6)
6408+
/* Solaris gethostbyaddr supports AF_INET only; use platform
6409+
specific and AF_INET6 capable getipnodebyaddr instead. */
6410+
if (af == AF_INET6) {
6411+
Py_BEGIN_ALLOW_THREADS
6412+
h = getipnodebyaddr(ap, al, af, &h_error);
6413+
Py_END_ALLOW_THREADS
6414+
ret = gethost_common(state, h, SAS2SA(&addr), sizeof(addr), af, h_error);
6415+
if (h != NULL) {
6416+
freehostent(h);
6417+
}
6418+
goto finally;
6419+
}
6420+
#endif
64076421
Py_BEGIN_ALLOW_THREADS
64086422
#ifdef HAVE_GETHOSTBYNAME_R
64096423
#if defined(HAVE_GETHOSTBYNAME_R_6_ARG)

0 commit comments

Comments
 (0)