-
Notifications
You must be signed in to change notification settings - Fork 7.9k
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
Remove HAVE_INET_PTON #13410
Changes from 8 commits
4d7b5e8
b921236
9eda2cd
ad6a418
e7e7a25
add1f37
02a97cf
0778638
dc43dd1
6eab8e6
bf1fad7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -157,7 +157,7 @@ PHP_FUNCTION(gethostbyaddr) | |||||
hostname = php_gethostbyaddr(addr); | ||||||
|
||||||
if (hostname == NULL) { | ||||||
#if defined(HAVE_IPV6) && defined(HAVE_INET_PTON) | ||||||
#if defined(HAVE_IPV6) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
php_error_docref(NULL, E_WARNING, "Address is not a valid IPv4 or IPv6 address"); | ||||||
#else | ||||||
php_error_docref(NULL, E_WARNING, "Address is not in a.b.c.d form"); | ||||||
|
@@ -172,7 +172,7 @@ PHP_FUNCTION(gethostbyaddr) | |||||
/* {{{ php_gethostbyaddr */ | ||||||
static zend_string *php_gethostbyaddr(char *ip) | ||||||
{ | ||||||
#if defined(HAVE_IPV6) && defined(HAVE_INET_PTON) | ||||||
#if defined(HAVE_IPV6) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
struct sockaddr_in sa4; | ||||||
struct sockaddr_in6 sa6; | ||||||
char out[NI_MAXHOST]; | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
--TEST-- | ||
Test ip2long() function : usage variation 2, 32 bit | ||
--SKIPIF-- | ||
<?php if(PHP_INT_SIZE != 4) {die('skip 32 bit only');} ?> | ||
<?php if (strtolower(substr(PHP_OS, 0, 3)) == 'aix') {die('skip not for AIX');} ?> | ||
<?php | ||
if(PHP_INT_SIZE != 4) { die('skip 32 bit only'); } | ||
if(strtolower(substr(PHP_OS, 0, 3)) == 'aix') { die('skip not for AIX'); } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NIT: space after if |
||
?> | ||
--FILE-- | ||
<?php | ||
$ips = array( | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -237,11 +237,7 @@ PHPAPI int php_network_getaddresses(const char *host, int socktype, struct socka | |||||
|
||||||
freeaddrinfo(res); | ||||||
#else | ||||||
#ifdef HAVE_INET_PTON | ||||||
if (!inet_pton(AF_INET, host, &in)) { | ||||||
#else | ||||||
if (!inet_aton(host, &in)) { | ||||||
#endif | ||||||
if(strlen(host) > MAXFQDNLEN) { | ||||||
host_info = NULL; | ||||||
errno = E2BIG; | ||||||
|
@@ -545,7 +541,7 @@ PHPAPI int php_network_parse_network_address_with_port(const char *addr, zend_lo | |||||
|
||||||
/* first, try interpreting the address as a numeric address */ | ||||||
|
||||||
#if HAVE_IPV6 && HAVE_INET_PTON | ||||||
#if HAVE_IPV6 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
think it should always test definition There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed, I have a long-standing (very outdated PR (#5526) now) to try to enable There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you need help with this PR, @Girgias ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can take it over, I was hitting some issue with YACC generating something that I couldn't check. |
||||||
if (inet_pton(AF_INET6, tmp, &in6->sin6_addr) > 0) { | ||||||
in6->sin6_port = htons(port); | ||||||
in6->sin6_family = AF_INET6; | ||||||
|
@@ -554,11 +550,7 @@ PHPAPI int php_network_parse_network_address_with_port(const char *addr, zend_lo | |||||
goto out; | ||||||
} | ||||||
#endif | ||||||
#ifdef HAVE_INET_PTON | ||||||
if (inet_pton(AF_INET, tmp, &in4->sin_addr) > 0) { | ||||||
#else | ||||||
if (inet_aton(tmp, &in4->sin_addr) > 0) { | ||||||
#endif | ||||||
in4->sin_port = htons(port); | ||||||
in4->sin_family = AF_INET; | ||||||
*sl = sizeof(struct sockaddr_in); | ||||||
|
@@ -852,25 +844,21 @@ php_socket_t php_network_connect_socket_to_host(const char *host, unsigned short | |||||
union { | ||||||
struct sockaddr common; | ||||||
struct sockaddr_in in4; | ||||||
#if HAVE_IPV6 && HAVE_INET_PTON | ||||||
#if HAVE_IPV6 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
struct sockaddr_in6 in6; | ||||||
#endif | ||||||
} local_address; | ||||||
int local_address_len = 0; | ||||||
|
||||||
if (sa->sa_family == AF_INET) { | ||||||
#ifdef HAVE_INET_PTON | ||||||
if (inet_pton(AF_INET, bindto, &local_address.in4.sin_addr) == 1) { | ||||||
#else | ||||||
if (inet_aton(bindto, &local_address.in4.sin_addr)) { | ||||||
#endif | ||||||
local_address_len = sizeof(struct sockaddr_in); | ||||||
local_address.in4.sin_family = sa->sa_family; | ||||||
local_address.in4.sin_port = htons(bindport); | ||||||
memset(&(local_address.in4.sin_zero), 0, sizeof(local_address.in4.sin_zero)); | ||||||
} | ||||||
} | ||||||
#if HAVE_IPV6 && HAVE_INET_PTON | ||||||
#if HAVE_IPV6 | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
else { /* IPV6 */ | ||||||
if (inet_pton(AF_INET6, bindto, &local_address.in6.sin6_addr) == 1) { | ||||||
local_address_len = sizeof(struct sockaddr_in6); | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.