Skip to content

Commit 0b49753

Browse files
committed
Remove HAVE_INET_PTON
1 parent 1e770d1 commit 0b49753

14 files changed

+15
-69
lines changed

Zend/Optimizer/zend_func_infos.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,9 +517,7 @@ static const func_info_t func_infos[] = {
517517
F1("sha1", MAY_BE_STRING),
518518
F1("sha1_file", MAY_BE_STRING|MAY_BE_FALSE),
519519
F1("inet_ntop", MAY_BE_STRING|MAY_BE_FALSE),
520-
#if defined(HAVE_INET_PTON)
521520
F1("inet_pton", MAY_BE_STRING|MAY_BE_FALSE),
522-
#endif
523521
F1("metaphone", MAY_BE_STRING),
524522
F1("headers_list", MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_LONG|MAY_BE_ARRAY_OF_STRING),
525523
F1("htmlspecialchars", MAY_BE_STRING),

configure.ac

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,11 @@ AC_CHECK_FUNC(inet_ntop,[],[
644644
]
645645
)
646646

647+
AC_CHECK_FUNC(inet_pton,[],[
648+
AC_MSG_ERROR([Cannot find inet_pton which is required])
649+
]
650+
)
651+
647652
dnl Check for strerror_r, and if its a POSIX-compatible or a GNU specific version.
648653
AC_FUNC_STRERROR_R
649654

ext/openssl/xp_ssl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@
130130
#define PHP_X509_NAME_ENTRY_TO_UTF8(ne, i, out) \
131131
ASN1_STRING_to_UTF8(&out, X509_NAME_ENTRY_get_data(X509_NAME_get_entry(ne, i)))
132132

133-
#if defined(HAVE_IPV6) && defined(HAVE_INET_PTON)
133+
#if defined(HAVE_IPV6)
134134
/* Used for IPv6 Address peer verification */
135135
#define EXPAND_IPV6_ADDRESS(_str, _bytes) \
136136
do { \

ext/sockets/sockaddr_conv.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,7 @@ int php_set_inet_addr(struct sockaddr_in *sin, char *string, php_socket *php_soc
8989
struct in_addr tmp;
9090
struct hostent *host_entry;
9191

92-
#ifdef HAVE_INET_PTON
9392
if (inet_pton(AF_INET, string, &tmp)) {
94-
#else
95-
if (inet_aton(string, &tmp)) {
96-
#endif
9793
sin->sin_addr.s_addr = tmp.s_addr;
9894
} else {
9995
if (strlen(string) > MAXFQDNLEN || ! (host_entry = php_network_gethostbyname(string))) {

ext/standard/basic_functions.c

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,6 @@ PHP_FUNCTION(inet_ntop)
555555
}
556556
/* }}} */
557557

558-
#ifdef HAVE_INET_PTON
559558
/* {{{ Converts a human readable IP address to a packed binary string */
560559
PHP_FUNCTION(inet_pton)
561560
{
@@ -588,42 +587,22 @@ PHP_FUNCTION(inet_pton)
588587
RETURN_STRINGL(buffer, af == AF_INET ? 4 : 16);
589588
}
590589
/* }}} */
591-
#endif /* HAVE_INET_PTON */
592590

593591
/* {{{ Converts a string containing an (IPv4) Internet Protocol dotted address into a proper address */
594592
PHP_FUNCTION(ip2long)
595593
{
596594
char *addr;
597595
size_t addr_len;
598-
#ifdef HAVE_INET_PTON
599596
struct in_addr ip;
600-
#else
601-
zend_ulong ip;
602-
#endif
603597

604598
ZEND_PARSE_PARAMETERS_START(1, 1)
605599
Z_PARAM_STRING(addr, addr_len)
606600
ZEND_PARSE_PARAMETERS_END();
607601

608-
#ifdef HAVE_INET_PTON
609602
if (addr_len == 0 || inet_pton(AF_INET, addr, &ip) != 1) {
610603
RETURN_FALSE;
611604
}
612605
RETURN_LONG(ntohl(ip.s_addr));
613-
#else
614-
if (addr_len == 0 || (ip = inet_addr(addr)) == INADDR_NONE) {
615-
/* The only special case when we should return -1 ourselves,
616-
* because inet_addr() considers it wrong. We return 0xFFFFFFFF and
617-
* not -1 or ~0 because of 32/64bit issues. */
618-
if (addr_len == sizeof("255.255.255.255") - 1 &&
619-
!memcmp(addr, "255.255.255.255", sizeof("255.255.255.255") - 1)
620-
) {
621-
RETURN_LONG(0xFFFFFFFF);
622-
}
623-
RETURN_FALSE;
624-
}
625-
RETURN_LONG(ntohl(ip));
626-
#endif
627606
}
628607
/* }}} */
629608

ext/standard/basic_functions.stub.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2238,10 +2238,8 @@ function syslog(int $priority, string $message): true {} // TODO make return typ
22382238
/** @refcount 1 */
22392239
function inet_ntop(string $ip): string|false {}
22402240

2241-
#ifdef HAVE_INET_PTON
22422241
/** @refcount 1 */
22432242
function inet_pton(string $ip): string|false {}
2244-
#endif
22452243

22462244
/* metaphone.c */
22472245

ext/standard/basic_functions_arginfo.h

Lines changed: 0 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/standard/dns.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ PHP_FUNCTION(gethostbyaddr)
157157
hostname = php_gethostbyaddr(addr);
158158

159159
if (hostname == NULL) {
160-
#if defined(HAVE_IPV6) && defined(HAVE_INET_PTON)
160+
#if defined(HAVE_IPV6)
161161
php_error_docref(NULL, E_WARNING, "Address is not a valid IPv4 or IPv6 address");
162162
#else
163163
php_error_docref(NULL, E_WARNING, "Address is not in a.b.c.d form");
@@ -172,7 +172,7 @@ PHP_FUNCTION(gethostbyaddr)
172172
/* {{{ php_gethostbyaddr */
173173
static zend_string *php_gethostbyaddr(char *ip)
174174
{
175-
#if defined(HAVE_IPV6) && defined(HAVE_INET_PTON)
175+
#if defined(HAVE_IPV6)
176176
struct sockaddr_in sa4;
177177
struct sockaddr_in6 sa6;
178178
char out[NI_MAXHOST];

ext/standard/tests/network/ip2long_variation2.phpt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
--TEST--
22
Test ip2long() function : usage variation 2, 32 bit
33
--SKIPIF--
4-
<?php if(PHP_INT_SIZE != 4) {die('skip 32 bit only');} ?>
5-
<?php if (strtolower(substr(PHP_OS, 0, 3)) == 'aix') {die('skip not for AIX');} ?>
4+
<?php
5+
if(PHP_INT_SIZE != 4) { die('skip 32 bit only'); }
6+
if(strtolower(substr(PHP_OS, 0, 3)) == 'aix') { die('skip not for AIX'); }
7+
?>
68
--FILE--
79
<?php
810
$ips = array(

ext/standard/tests/network/ip2long_variation2_x64.phpt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ Test ip2long() function : usage variation 2, 64 bit
77
in the C language (i.e., a leading 0x or 0X implies hexadecimal; otherwise, a leading 0 implies octal;
88
otherwise, the number is interpreted as decimal).
99
*/
10-
if(PHP_OS == 'Darwin') die("skip - inet_pton behaves differently on Darwin");
1110
if(PHP_INT_SIZE != 8) {die('skip 64 bit only');}
1211
?>
1312
--FILE--

main/fastcgi.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -681,12 +681,7 @@ int fcgi_listen(const char *path, int backlog)
681681
if (!*host || !strncmp(host, "*", sizeof("*")-1)) {
682682
sa.sa_inet.sin_addr.s_addr = htonl(INADDR_ANY);
683683
} else {
684-
#ifdef HAVE_INET_PTON
685684
if (!inet_pton(AF_INET, host, &sa.sa_inet.sin_addr)) {
686-
#else
687-
sa.sa_inet.sin_addr.s_addr = inet_addr(host);
688-
if (sa.sa_inet.sin_addr.s_addr == INADDR_NONE) {
689-
#endif
690685
struct hostent *hep;
691686

692687
if(strlen(host) > MAXFQDNLEN) {

main/network.c

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,7 @@ PHPAPI int php_network_getaddresses(const char *host, int socktype, struct socka
237237

238238
freeaddrinfo(res);
239239
#else
240-
#ifdef HAVE_INET_PTON
241240
if (!inet_pton(AF_INET, host, &in)) {
242-
#else
243-
if (!inet_aton(host, &in)) {
244-
#endif
245241
if(strlen(host) > MAXFQDNLEN) {
246242
host_info = NULL;
247243
errno = E2BIG;
@@ -545,7 +541,7 @@ PHPAPI int php_network_parse_network_address_with_port(const char *addr, zend_lo
545541

546542
/* first, try interpreting the address as a numeric address */
547543

548-
#if HAVE_IPV6 && HAVE_INET_PTON
544+
#if HAVE_IPV6
549545
if (inet_pton(AF_INET6, tmp, &in6->sin6_addr) > 0) {
550546
in6->sin6_port = htons(port);
551547
in6->sin6_family = AF_INET6;
@@ -554,11 +550,7 @@ PHPAPI int php_network_parse_network_address_with_port(const char *addr, zend_lo
554550
goto out;
555551
}
556552
#endif
557-
#ifdef HAVE_INET_PTON
558553
if (inet_pton(AF_INET, tmp, &in4->sin_addr) > 0) {
559-
#else
560-
if (inet_aton(tmp, &in4->sin_addr) > 0) {
561-
#endif
562554
in4->sin_port = htons(port);
563555
in4->sin_family = AF_INET;
564556
*sl = sizeof(struct sockaddr_in);
@@ -852,25 +844,21 @@ php_socket_t php_network_connect_socket_to_host(const char *host, unsigned short
852844
union {
853845
struct sockaddr common;
854846
struct sockaddr_in in4;
855-
#if HAVE_IPV6 && HAVE_INET_PTON
847+
#if HAVE_IPV6
856848
struct sockaddr_in6 in6;
857849
#endif
858850
} local_address;
859851
int local_address_len = 0;
860852

861853
if (sa->sa_family == AF_INET) {
862-
#ifdef HAVE_INET_PTON
863854
if (inet_pton(AF_INET, bindto, &local_address.in4.sin_addr) == 1) {
864-
#else
865-
if (inet_aton(bindto, &local_address.in4.sin_addr)) {
866-
#endif
867855
local_address_len = sizeof(struct sockaddr_in);
868856
local_address.in4.sin_family = sa->sa_family;
869857
local_address.in4.sin_port = htons(bindport);
870858
memset(&(local_address.in4.sin_zero), 0, sizeof(local_address.in4.sin_zero));
871859
}
872860
}
873-
#if HAVE_IPV6 && HAVE_INET_PTON
861+
#if HAVE_IPV6
874862
else { /* IPV6 */
875863
if (inet_pton(AF_INET6, bindto, &local_address.in6.sin6_addr) == 1) {
876864
local_address_len = sizeof(struct sockaddr_in6);

sapi/litespeed/lsapilib.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2688,12 +2688,7 @@ int LSAPI_ParseSockAddr( const char * pBind, struct sockaddr * pAddr )
26882688
((struct sockaddr_in *)pAddr)->sin_addr.s_addr = htonl( INADDR_LOOPBACK );
26892689
else
26902690
{
2691-
#ifdef HAVE_INET_PTON
26922691
if (!inet_pton(AF_INET, p, &((struct sockaddr_in *)pAddr)->sin_addr))
2693-
#else
2694-
((struct sockaddr_in *)pAddr)->sin_addr.s_addr = inet_addr( p );
2695-
if ( ((struct sockaddr_in *)pAddr)->sin_addr.s_addr == INADDR_BROADCAST)
2696-
#endif
26972692
{
26982693
doAddrInfo = 1;
26992694
}

win32/build/config.w32.h.in

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,6 @@
116116
/* Win32 support proc_open */
117117
#define PHP_CAN_SUPPORT_PROC_OPEN 1
118118

119-
/* inet_pton() */
120-
#define HAVE_INET_PTON 1
121-
122119
/* vs.net 2005 has a 64-bit time_t. This will likely break
123120
* 3rdParty libs that were built with older compilers; switch
124121
* back to 32-bit */

0 commit comments

Comments
 (0)