Skip to content

Remove HAVE_INET_PTON #13410

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Zend/Optimizer/zend_func_infos.h
Original file line number Diff line number Diff line change
Expand Up @@ -517,9 +517,7 @@ static const func_info_t func_infos[] = {
F1("sha1", MAY_BE_STRING),
F1("sha1_file", MAY_BE_STRING|MAY_BE_FALSE),
F1("inet_ntop", MAY_BE_STRING|MAY_BE_FALSE),
#if defined(HAVE_INET_PTON)
F1("inet_pton", MAY_BE_STRING|MAY_BE_FALSE),
#endif
F1("metaphone", MAY_BE_STRING),
F1("headers_list", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING),
F1("htmlspecialchars", MAY_BE_STRING),
Expand Down
7 changes: 2 additions & 5 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,6 @@ getgrnam_r \
getpwuid_r \
getwd \
glob \
inet_pton \
localtime_r \
lchown \
memcntl \
Expand Down Expand Up @@ -640,10 +639,8 @@ memrchr \
mempcpy \
)

AC_CHECK_FUNC(inet_ntop,[],[
AC_MSG_ERROR([Cannot find inet_ntop which is required])
]
)
AC_CHECK_FUNC([inet_ntop],,[AC_MSG_ERROR([Required inet_ntop not found.])])
AC_CHECK_FUNC([inet_pton],,[AC_MSG_ERROR([Required inet_pton not found.])])

dnl Check for strerror_r, and if its a POSIX-compatible or a GNU specific version.
AC_FUNC_STRERROR_R
Expand Down
2 changes: 1 addition & 1 deletion ext/ftp/ftp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1704,7 +1704,7 @@ ftp_getdata(ftpbuf_t *ftp)

data->listener = fd;

#if defined(HAVE_IPV6)
#ifdef HAVE_IPV6
if (sa->sa_family == AF_INET6) {
/* need to use EPRT */
char eprtarg[INET6_ADDRSTRLEN + sizeof("|x||xxxxx|")];
Expand Down
2 changes: 1 addition & 1 deletion ext/openssl/xp_ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
#define PHP_X509_NAME_ENTRY_TO_UTF8(ne, i, out) \
ASN1_STRING_to_UTF8(&out, X509_NAME_ENTRY_get_data(X509_NAME_get_entry(ne, i)))

#if defined(HAVE_IPV6) && defined(HAVE_INET_PTON)
#ifdef HAVE_IPV6
/* Used for IPv6 Address peer verification */
#define EXPAND_IPV6_ADDRESS(_str, _bytes) \
do { \
Expand Down
8 changes: 4 additions & 4 deletions ext/sockets/conversions.c
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ static void to_zval_read_sa_family(const char *data, zval *zv, res_context *ctx)

ZVAL_LONG(zv, (zend_long)ival);
}
#if HAVE_IPV6
#ifdef HAVE_IPV6
static void to_zval_read_unsigned(const char *data, zval *zv, res_context *ctx)
{
unsigned ival;
Expand Down Expand Up @@ -597,7 +597,7 @@ static void to_zval_read_sockaddr_in(const char *data, zval *zv, res_context *ct
{
to_zval_read_aggregation(data, zv, descriptors_sockaddr_in, ctx);
}
#if HAVE_IPV6
#ifdef HAVE_IPV6
static void from_zval_write_sin6_addr(const zval *zaddr_str, char *addr6, ser_context *ctx)
{
int res;
Expand Down Expand Up @@ -753,7 +753,7 @@ static void from_zval_write_sockaddr_aux(const zval *container,
}
break;

#if HAVE_IPV6
#ifdef HAVE_IPV6
case AF_INET6:
if (ctx->sock->type != AF_INET6) {
do_from_zval_err(ctx, "the specified family (AF_INET6) is not "
Expand Down Expand Up @@ -817,7 +817,7 @@ static void to_zval_read_sockaddr_aux(const char *sockaddr_c, zval *zv, res_cont
to_zval_read_sockaddr_in(sockaddr_c, zv, ctx);
break;

#if HAVE_IPV6
#ifdef HAVE_IPV6
case AF_INET6:
to_zval_read_sockaddr_in6(sockaddr_c, zv, ctx);
break;
Expand Down
4 changes: 2 additions & 2 deletions ext/sockets/multicast.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ static int _php_mcast_join_leave(
join ? IP_ADD_MEMBERSHIP : IP_DROP_MEMBERSHIP, (char*)&mreq,
sizeof(mreq));
}
#if HAVE_IPV6
#ifdef HAVE_IPV6
else if (sock->type == AF_INET6) {
struct ipv6_mreq mreq;
memset(&mreq, 0, sizeof(struct ipv6_mreq));
Expand Down Expand Up @@ -543,7 +543,7 @@ static int _php_mcast_source_op(
return setsockopt(sock->bsd_socket, level,
_php_source_op_to_ipv4_op(sop), (char*)&mreqs, sizeof(mreqs));
}
#if HAVE_IPV6
#ifdef HAVE_IPV6
else if (sock->type == AF_INET6) {
php_error_docref(NULL, E_WARNING,
"This platform does not support %s for IPv6 sockets",
Expand Down
2 changes: 1 addition & 1 deletion ext/sockets/sendrecvmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ PHP_FUNCTION(socket_cmsg_space)
RETURN_LONG((zend_long)CMSG_SPACE(entry->size + n * entry->var_el_size));
}

#if HAVE_IPV6
#ifdef HAVE_IPV6
int php_do_setsockopt_ipv6_rfc3542(php_socket *php_sock, int level, int optname, zval *arg4)
{
struct err_s err = {0};
Expand Down
8 changes: 2 additions & 6 deletions ext/sockets/sockaddr_conv.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

extern zend_result php_string_to_if_index(const char *val, unsigned *out);

#if HAVE_IPV6
#ifdef HAVE_IPV6
/* Sets addr by hostname, or by ip in string form (AF_INET6) */
int php_set_inet6_addr(struct sockaddr_in6 *sin6, char *string, php_socket *php_sock) /* {{{ */
{
Expand Down Expand Up @@ -89,11 +89,7 @@ int php_set_inet_addr(struct sockaddr_in *sin, char *string, php_socket *php_soc
struct in_addr tmp;
struct hostent *host_entry;

#ifdef HAVE_INET_PTON
if (inet_pton(AF_INET, string, &tmp)) {
#else
if (inet_aton(string, &tmp)) {
#endif
sin->sin_addr.s_addr = tmp.s_addr;
} else {
if (strlen(string) > MAXFQDNLEN || ! (host_entry = php_network_gethostbyname(string))) {
Expand Down Expand Up @@ -129,7 +125,7 @@ int php_set_inet46_addr(php_sockaddr_storage *ss, socklen_t *ss_len, char *strin
return 1;
}
}
#if HAVE_IPV6
#ifdef HAVE_IPV6
else if (php_sock->type == AF_INET6) {
struct sockaddr_in6 t = {0};
if (php_set_inet6_addr(&t, string, php_sock)) {
Expand Down
36 changes: 18 additions & 18 deletions ext/sockets/sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ PHP_FUNCTION(socket_getsockname)
php_socket *php_sock;
struct sockaddr *sa;
struct sockaddr_in *sin;
#if HAVE_IPV6
#ifdef HAVE_IPV6
struct sockaddr_in6 *sin6;
#endif
char addrbuf[INET6_ADDRSTRLEN];
Expand All @@ -943,7 +943,7 @@ PHP_FUNCTION(socket_getsockname)
}

switch (sa->sa_family) {
#if HAVE_IPV6
#ifdef HAVE_IPV6
case AF_INET6:
sin6 = (struct sockaddr_in6 *) sa;
inet_ntop(AF_INET6, &sin6->sin6_addr, addrbuf, sizeof(addrbuf));
Expand Down Expand Up @@ -988,7 +988,7 @@ PHP_FUNCTION(socket_getpeername)
php_socket *php_sock;
struct sockaddr *sa;
struct sockaddr_in *sin;
#if HAVE_IPV6
#ifdef HAVE_IPV6
struct sockaddr_in6 *sin6;
#endif
char addrbuf[INET6_ADDRSTRLEN];
Expand All @@ -1011,7 +1011,7 @@ PHP_FUNCTION(socket_getpeername)
}

switch (sa->sa_family) {
#if HAVE_IPV6
#ifdef HAVE_IPV6
case AF_INET6:
sin6 = (struct sockaddr_in6 *) sa;
inet_ntop(AF_INET6, &sin6->sin6_addr, addrbuf, sizeof(addrbuf));
Expand Down Expand Up @@ -1062,7 +1062,7 @@ PHP_FUNCTION(socket_create)
}

if (domain != AF_UNIX
#if HAVE_IPV6
#ifdef HAVE_IPV6
&& domain != AF_INET6
#endif
&& domain != AF_INET) {
Expand Down Expand Up @@ -1113,7 +1113,7 @@ PHP_FUNCTION(socket_connect)
ENSURE_SOCKET_VALID(php_sock);

switch(php_sock->type) {
#if HAVE_IPV6
#ifdef HAVE_IPV6
case AF_INET6: {
struct sockaddr_in6 sin6 = {0};

Expand Down Expand Up @@ -1247,7 +1247,7 @@ PHP_FUNCTION(socket_bind)
retval = bind(php_sock->bsd_socket, (struct sockaddr *)sa, sizeof(struct sockaddr_in));
break;
}
#if HAVE_IPV6
#ifdef HAVE_IPV6
case AF_INET6:
{
struct sockaddr_in6 *sa = (struct sockaddr_in6 *) sock_type;
Expand Down Expand Up @@ -1357,7 +1357,7 @@ PHP_FUNCTION(socket_recvfrom)
php_socket *php_sock;
struct sockaddr_un s_un;
struct sockaddr_in sin;
#if HAVE_IPV6
#ifdef HAVE_IPV6
struct sockaddr_in6 sin6;
#endif
char addrbuf[INET6_ADDRSTRLEN];
Expand Down Expand Up @@ -1428,7 +1428,7 @@ PHP_FUNCTION(socket_recvfrom)
ZEND_TRY_ASSIGN_REF_STRING(arg5, address ? address : "0.0.0.0");
ZEND_TRY_ASSIGN_REF_LONG(arg6, ntohs(sin.sin_port));
break;
#if HAVE_IPV6
#ifdef HAVE_IPV6
case AF_INET6:
slen = sizeof(sin6);
memset(&sin6, 0, slen);
Expand Down Expand Up @@ -1473,7 +1473,7 @@ PHP_FUNCTION(socket_sendto)
php_socket *php_sock;
struct sockaddr_un s_un;
struct sockaddr_in sin;
#if HAVE_IPV6
#ifdef HAVE_IPV6
struct sockaddr_in6 sin6;
#endif
int retval;
Expand Down Expand Up @@ -1519,7 +1519,7 @@ PHP_FUNCTION(socket_sendto)

retval = sendto(php_sock->bsd_socket, buf, ((size_t)len > buf_len) ? buf_len : (size_t)len, flags, (struct sockaddr *) &sin, sizeof(sin));
break;
#if HAVE_IPV6
#ifdef HAVE_IPV6
case AF_INET6:
if (port_is_null) {
zend_argument_value_error(6, "cannot be null when the socket type is AF_INET6");
Expand Down Expand Up @@ -1590,7 +1590,7 @@ PHP_FUNCTION(socket_get_option)
}
}
}
#if HAVE_IPV6
#ifdef HAVE_IPV6
else if (level == IPPROTO_IPV6) {
int ret = php_do_getsockopt_ipv6_rfc3542(php_sock, level, optname, return_value);
if (ret == SUCCESS) {
Expand Down Expand Up @@ -1795,7 +1795,7 @@ PHP_FUNCTION(socket_set_option)
HANDLE_SUBCALL(res);
}

#if HAVE_IPV6
#ifdef HAVE_IPV6
else if (level == IPPROTO_IPV6) {
int res = php_do_setsockopt_ipv6_mcast(php_sock, level, optname, arg4);
if (res == 1) {
Expand Down Expand Up @@ -1999,7 +1999,7 @@ PHP_FUNCTION(socket_create_pair)
}

if (domain != AF_INET
#if HAVE_IPV6
#ifdef HAVE_IPV6
&& domain != AF_INET6
#endif
&& domain != AF_UNIX) {
Expand Down Expand Up @@ -2258,7 +2258,7 @@ PHP_FUNCTION(socket_export_stream)
/* Determine if socket is using a protocol with one of the default registered
* socket stream wrappers */
if (socket->type == PF_INET
#if HAVE_IPV6
#ifdef HAVE_IPV6
|| socket->type == PF_INET6
#endif
) {
Expand Down Expand Up @@ -2435,7 +2435,7 @@ PHP_FUNCTION(socket_addrinfo_bind)
}

case AF_INET:
#if HAVE_IPV6
#ifdef HAVE_IPV6
case AF_INET6:
#endif
{
Expand Down Expand Up @@ -2498,7 +2498,7 @@ PHP_FUNCTION(socket_addrinfo_connect)
}

case AF_INET:
#if HAVE_IPV6
#ifdef HAVE_IPV6
case AF_INET6:
#endif
{
Expand Down Expand Up @@ -2555,7 +2555,7 @@ PHP_FUNCTION(socket_addrinfo_explain)
add_assoc_string(&sockaddr, "sin_addr", addr);
break;
}
#if HAVE_IPV6
#ifdef HAVE_IPV6
case AF_INET6:
{
struct sockaddr_in6 *sa = (struct sockaddr_in6 *) ai->addrinfo.ai_addr;
Expand Down
8 changes: 4 additions & 4 deletions ext/sockets/sockets.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* @cvalue AF_INET
*/
const AF_INET = UNKNOWN;
#if HAVE_IPV6
#ifdef HAVE_IPV6
/**
* @var int
* @cvalue AF_INET6
Expand Down Expand Up @@ -649,7 +649,7 @@
*/
const IP_BIND_ADDRESS_NO_PORT = UNKNOWN;
#endif
#if HAVE_IPV6
#ifdef HAVE_IPV6
/**
* @var int
* @cvalue IPV6_MULTICAST_IF
Expand Down Expand Up @@ -1542,7 +1542,7 @@
* @cvalue IPPROTO_IP
*/
const IPPROTO_IP = UNKNOWN;
#if HAVE_IPV6
#ifdef HAVE_IPV6
/**
* @var int
* @cvalue IPPROTO_IPV6
Expand All @@ -1568,7 +1568,7 @@
const SOL_UDPLITE = UNKNOWN;
#endif

#if HAVE_IPV6
#ifdef HAVE_IPV6
/**
* @var int
* @cvalue IPV6_UNICAST_HOPS
Expand Down
14 changes: 7 additions & 7 deletions ext/sockets/sockets_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading