Skip to content

sockets ext for solaris update. #8191

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
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
48 changes: 48 additions & 0 deletions ext/sockets/sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,11 @@ static PHP_MINIT_FUNCTION(sockets)
#ifdef SO_ACCEPTFILTER
REGISTER_LONG_CONSTANT("SO_ACCEPTFILTER", SO_ACCEPTFILTER, CONST_CS | CONST_PERSISTENT);
#endif
#ifdef SOL_FILTER
REGISTER_LONG_CONSTANT("SOL_FILTER", SOL_FILTER, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FIL_ATTACH", FIL_ATTACH, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FIL_DETACH", FIL_DETACH, CONST_CS | CONST_PERSISTENT);
#endif
#ifdef SO_DONTTRUNC
REGISTER_LONG_CONSTANT("SO_DONTTRUNC", SO_DONTTRUNC, CONST_CS | CONST_PERSISTENT);
#endif
Expand Down Expand Up @@ -1853,6 +1858,32 @@ PHP_FUNCTION(socket_get_option)
}
}

#ifdef SOL_FILTER
if (level == SOL_FILTER) {
switch (optname) {

case FIL_LIST: {
size_t i;
struct fil_info fi[32] = {{0}};
optlen = sizeof(fi);

if (getsockopt(php_sock->bsd_socket, level, optname, (char*)fi, &optlen) != 0) {
PHP_SOCKET_ERROR(php_sock, "Unable to retrieve socket option", errno);
RETURN_FALSE;
}

array_init(return_value);

for (i = 0; i < optlen / sizeof(struct fil_info); i++) {
add_index_string(return_value, i, fi[i].fi_name);
}

return;
}
}
}
#endif

optlen = sizeof(other_val);

if (getsockopt(php_sock->bsd_socket, level, optname, (char*)&other_val, &optlen) != 0) {
Expand Down Expand Up @@ -2004,6 +2035,23 @@ PHP_FUNCTION(socket_set_option)
}
#endif

#ifdef FIL_ATTACH
case FIL_ATTACH:
case FIL_DETACH: {
if (level != SOL_FILTER) {
php_error_docref(NULL, E_WARNING, "Invalid level");
RETURN_FALSE;
}
if (Z_TYPE_P(arg4) != IS_STRING) {
php_error_docref(NULL, E_WARNING, "Invalid filter argument type");
RETURN_FALSE;
}
opt_ptr = Z_STRVAL_P(arg4);
optlen = Z_STRLEN_P(arg4);
break;
}
#endif

default:
default_case:
convert_to_long(arg4);
Expand Down