Skip to content

socket add socket_atmark support. #9846

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

Closed
wants to merge 1 commit into from
Closed
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
1 change: 1 addition & 0 deletions ext/sockets/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ PHP_ARG_ENABLE([sockets],

if test "$PHP_SOCKETS" != "no"; then
AC_CHECK_FUNCS([hstrerror if_nametoindex if_indextoname])
AC_CHECK_FUNCS(sockatmark)
AC_CHECK_HEADERS([netinet/tcp.h sys/un.h sys/sockio.h linux/filter.h])
AC_DEFINE([HAVE_SOCKETS], 1, [ ])

Expand Down
26 changes: 26 additions & 0 deletions ext/sockets/sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -2109,6 +2109,32 @@ PHP_FUNCTION(socket_shutdown)
/* }}} */
#endif

#ifdef HAVE_SOCKATMARK
PHP_FUNCTION(socket_atmark)
{
zval *arg1;
php_socket *php_sock;
int r;

if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &arg1, socket_ce) == FAILURE) {
RETURN_THROWS();
}

php_sock = Z_SOCKET_P(arg1);
ENSURE_SOCKET_VALID(php_sock);

r = sockatmark(php_sock->bsd_socket);
if (r < 0) {
PHP_SOCKET_ERROR(php_sock, "Unable to apply sockmark", errno);
RETURN_FALSE;
} else if (r == 0) {
RETURN_FALSE;
} else {
RETURN_TRUE;
}
}
#endif

/* {{{ Returns the last socket error (either the last used or the provided socket resource) */
PHP_FUNCTION(socket_last_error)
{
Expand Down
4 changes: 4 additions & 0 deletions ext/sockets/sockets.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -1798,6 +1798,10 @@ function socket_create_pair(int $domain, int $type, int $protocol, &$pair): bool
function socket_shutdown(Socket $socket, int $mode = 2): bool {}
#endif

#ifdef HAVE_SOCKATMARK
function socket_atmark(Socket $socket): bool {}
#endif

function socket_last_error(?Socket $socket = null): int {}

function socket_clear_error(?Socket $socket = null): void {}
Expand Down
14 changes: 13 additions & 1 deletion ext/sockets/sockets_arginfo.h

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