Skip to content

Sync HAVE_IPV6 and HAVE_GETADDRINFO in #if/ifdef/defined #14341

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 1 commit into from
May 28, 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: 1 addition & 1 deletion ext/sockets/conversions.c
Original file line number Diff line number Diff line change
Expand Up @@ -1243,7 +1243,7 @@ void to_zval_read_msghdr(const char *msghdr_c, zval *zv, res_context *ctx)
to_zval_read_aggregation(msghdr_c, zv, descriptors, ctx);
}

#if defined(IPV6_PKTINFO) && HAVE_IPV6
#if defined(IPV6_PKTINFO) && defined(HAVE_IPV6)
/* CONVERSIONS for if_index */
static void from_zval_write_ifindex(const zval *zv, char *uinteger, ser_context *ctx)
{
Expand Down
6 changes: 3 additions & 3 deletions ext/sockets/sendrecvmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,17 @@ static void init_ancillary_registry(void)
key.cmsg_type = type; \
zend_hash_str_update_mem(&ancillary_registry.ht, (char*)&key, sizeof(key), (void*)&entry, sizeof(entry))

#if defined(IPV6_PKTINFO) && HAVE_IPV6
#if defined(IPV6_PKTINFO) && defined(HAVE_IPV6)
PUT_ENTRY(sizeof(struct in6_pktinfo), 0, 0, from_zval_write_in6_pktinfo,
to_zval_read_in6_pktinfo, IPPROTO_IPV6, IPV6_PKTINFO);
#endif

#if defined(IPV6_HOPLIMIT) && HAVE_IPV6
#if defined(IPV6_HOPLIMIT) && defined(HAVE_IPV6)
PUT_ENTRY(sizeof(int), 0, 0, from_zval_write_int,
to_zval_read_int, IPPROTO_IPV6, IPV6_HOPLIMIT);
#endif

#if defined(IPV6_TCLASS) && HAVE_IPV6
#if defined(IPV6_TCLASS) && defined(HAVE_IPV6)
PUT_ENTRY(sizeof(int), 0, 0, from_zval_write_int,
to_zval_read_int, IPPROTO_IPV6, IPV6_TCLASS);
#endif
Expand Down
4 changes: 2 additions & 2 deletions ext/sockets/sockaddr_conv.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ extern zend_result php_string_to_if_index(const char *val, unsigned *out);
int php_set_inet6_addr(struct sockaddr_in6 *sin6, char *string, php_socket *php_sock) /* {{{ */
{
struct in6_addr tmp;
#if HAVE_GETADDRINFO
#ifdef HAVE_GETADDRINFO
struct addrinfo hints;
struct addrinfo *addrinfo = NULL;
#endif
Expand All @@ -25,7 +25,7 @@ int php_set_inet6_addr(struct sockaddr_in6 *sin6, char *string, php_socket *php_
if (inet_pton(AF_INET6, string, &tmp)) {
memcpy(&(sin6->sin6_addr.s6_addr), &(tmp.s6_addr), sizeof(struct in6_addr));
} else {
#if HAVE_GETADDRINFO
#ifdef HAVE_GETADDRINFO

memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_INET6;
Expand Down
6 changes: 3 additions & 3 deletions ext/sockets/sockets.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -1664,7 +1664,7 @@
const SOL_LOCAL = UNKNOWN;
#endif

#if (defined(IPV6_RECVPKTINFO) && HAVE_IPV6)
#if (defined(IPV6_RECVPKTINFO) && defined(HAVE_IPV6))
/**
* IPv6 ancillary data
* @var int
Expand All @@ -1677,7 +1677,7 @@
*/
const IPV6_PKTINFO = UNKNOWN;
#endif
#if (defined(IPV6_RECVHOPLIMIT) && HAVE_IPV6)
#if (defined(IPV6_RECVHOPLIMIT) && defined(HAVE_IPV6))
/**
* @var int
* @cvalue IPV6_RECVHOPLIMIT
Expand All @@ -1690,7 +1690,7 @@
const IPV6_HOPLIMIT = UNKNOWN;
#endif

#if (defined(IPV6_RECVTCLASS) && HAVE_IPV6)
#if (defined(IPV6_RECVTCLASS) && defined(HAVE_IPV6))
/**
* @var int
* @cvalue IPV6_RECVTCLASS
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.

12 changes: 6 additions & 6 deletions main/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const struct in6_addr in6addr_any = {0}; /* IN6ADDR_ANY_INIT; */
# define PHP_TIMEOUT_ERROR_VALUE ETIMEDOUT
#endif

#if HAVE_GETADDRINFO
#ifdef HAVE_GETADDRINFO
#ifdef HAVE_GAI_STRERROR
# define PHP_GAI_STRERROR(x) (gai_strerror(x))
#else
Expand Down Expand Up @@ -150,7 +150,7 @@ PHPAPI int php_network_getaddresses(const char *host, int socktype, struct socka
{
struct sockaddr **sap;
int n;
#if HAVE_GETADDRINFO
#ifdef HAVE_GETADDRINFO
# ifdef HAVE_IPV6
static int ipv6_borked = -1; /* the way this is used *is* thread safe */
# endif
Expand All @@ -163,7 +163,7 @@ PHPAPI int php_network_getaddresses(const char *host, int socktype, struct socka
if (host == NULL) {
return 0;
}
#if HAVE_GETADDRINFO
#ifdef HAVE_GETADDRINFO
memset(&hints, '\0', sizeof(hints));

hints.ai_family = AF_INET; /* default to regular inet (see below) */
Expand Down Expand Up @@ -422,7 +422,7 @@ php_socket_t php_network_bind_socket_to_local_addr(const char *host, unsigned po
sa = *sal;

switch (sa->sa_family) {
#if HAVE_GETADDRINFO && HAVE_IPV6
#if defined(HAVE_GETADDRINFO) && defined(HAVE_IPV6)
case AF_INET6:
((struct sockaddr_in6 *)sa)->sin6_port = htons(port);
socklen = sizeof(struct sockaddr_in6);
Expand Down Expand Up @@ -566,7 +566,7 @@ PHPAPI int php_network_parse_network_address_with_port(const char *addr, zend_lo

/* copy the details from the first item */
switch ((*psal)->sa_family) {
#if HAVE_GETADDRINFO && HAVE_IPV6
#if defined(HAVE_GETADDRINFO) && defined(HAVE_IPV6)
case AF_INET6:
*in6 = **(struct sockaddr_in6**)psal;
in6->sin6_port = htons(port);
Expand Down Expand Up @@ -802,7 +802,7 @@ php_socket_t php_network_connect_socket_to_host(const char *host, unsigned short
sa = *sal;

switch (sa->sa_family) {
#if HAVE_GETADDRINFO && HAVE_IPV6
#if defined(HAVE_GETADDRINFO) && defined(HAVE_IPV6)
case AF_INET6:
if (!bindto || strchr(bindto, ':')) {
((struct sockaddr_in6 *)sa)->sin6_port = htons(port);
Expand Down
4 changes: 2 additions & 2 deletions sapi/cli/php_cli_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -1302,7 +1302,7 @@ static php_socket_t php_network_listen_socket(const char *host, int *port, int s
}

switch ((*p)->sa_family) {
#if HAVE_GETADDRINFO && HAVE_IPV6
#if defined(HAVE_GETADDRINFO) && defined(HAVE_IPV6)
case AF_INET6:
sa = pemalloc(sizeof(struct sockaddr_in6), 1);
*(struct sockaddr_in6 *)sa = *(struct sockaddr_in6 *)*p;
Expand Down Expand Up @@ -1348,7 +1348,7 @@ static php_socket_t php_network_listen_socket(const char *host, int *port, int s
goto out;
}
switch (sa->sa_family) {
#if HAVE_GETADDRINFO && HAVE_IPV6
#if defined(HAVE_GETADDRINFO) && defined(HAVE_IPV6)
case AF_INET6:
*port = ntohs(((struct sockaddr_in6 *)sa)->sin6_port);
break;
Expand Down
Loading