Skip to content

Commit

Permalink
changes from review
Browse files Browse the repository at this point in the history
  • Loading branch information
devnexen committed Jan 20, 2025
1 parent 6ac51d8 commit cf003e7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
17 changes: 8 additions & 9 deletions ext/sockets/sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,13 @@ ZEND_DECLARE_MODULE_GLOBALS(sockets)
#endif

#if defined(ETH_P_ALL)
#define PHP_ETH_PROTO_CHECK(protocol, family) \
do { \
/* We ll let EINVAL errno warning about miusage, too many protocols conflicts but AF_PACKET family works only with ETH_P_* constants */ \
if ((protocol >= ETH_P_LOOP && protocol <= USHRT_MAX) && family == AF_PACKET) { \
protocol = htons(protocol); \
} \
} \
while (0)
#define PHP_ETH_PROTO_CHECK(protocol, family) \
do { \
/* We ll let EINVAL errno warning about miusage, too many protocols conflicts */ \
if (protocol <= USHRT_MAX && family == AF_PACKET) { \
protocol = htons(protocol); \
} \
} while (0)
#else
#define PHP_ETH_PROTO_CHECK(protocol, family) (0)
#endif
Expand Down Expand Up @@ -1180,7 +1179,7 @@ PHP_FUNCTION(socket_create)
RETURN_THROWS();
}

PHP_ETH_PROTO_CHECK(protocol, protocol);
PHP_ETH_PROTO_CHECK(protocol, domain);

object_init_ex(return_value, socket_ce);
php_sock = Z_SOCKET_P(return_value);
Expand Down
3 changes: 2 additions & 1 deletion ext/sockets/tests/socket_afpacket.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
socket_getsockname from AF_PACKET socket
--EXTENSIONS--
sockets
posix
--SKIPIF--
<?php

Expand All @@ -18,7 +19,7 @@ if (!function_exists("posix_getuid") || posix_getuid() != 0) {
$s_bind = socket_bind($s_c, 'lo');
var_dump($s_bind);

// Connect to destination address
// sock_getsockname in this context gets the interface rather than the address.
$s_conn = socket_getsockname($s_c, $istr, $iindex);
var_dump($s_conn);
var_dump($istr);
Expand Down

0 comments on commit cf003e7

Please sign in to comment.