Skip to content

Commit 0d040dd

Browse files
committed
add necessary header and little test.
1 parent 4c9f7c9 commit 0d040dd

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

ext/sockets/config.m4

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ PHP_ARG_ENABLE([sockets],
55

66
if test "$PHP_SOCKETS" != "no"; then
77
AC_CHECK_FUNCS([hstrerror if_nametoindex if_indextoname sockatmark])
8-
AC_CHECK_HEADERS([sys/sockio.h linux/filter.h linux/if_packet.h linux/if_ether.h])
8+
AC_CHECK_HEADERS([sys/sockio.h linux/filter.h linux/if_packet.h linux/if_ether.h linux/udp.h])
99
AC_DEFINE([HAVE_SOCKETS], [1],
1010
[Define to 1 if the PHP extension 'sockets' is available.])
1111

ext/sockets/sockets.c

+3
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@
7070
# if defined(HAVE_LINUX_IF_ETHER_H)
7171
# include <linux/if_ether.h>
7272
# endif
73+
# if defined(HAVE_LINUX_UDP_H)
74+
# include <linux/udp.h>
75+
# endif
7376
#endif
7477

7578
#include <stddef.h>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--TEST--
2+
UDP_SEGMENT setsockopt(), can't really test is as the kernel support might not be enabled.
3+
--EXTENSIONS--
4+
sockets
5+
--SKIPIF--
6+
<?php
7+
if (!defined('UDP_SEGMENT')) { die('skip UDP_SEGMENT is not defined'); }
8+
?>
9+
--FILE--
10+
<?php
11+
$src = socket_create(AF_UNIX, SOCK_DGRAM, 0);
12+
13+
try {
14+
socket_setopt($src, SOL_UDP, UDP_SEGMENT, -1);
15+
} catch (\ValueError $e) {
16+
echo $e->getMessage(), PHP_EOL;
17+
}
18+
try {
19+
socket_setopt($src, SOL_UDP, UDP_SEGMENT, 65536);
20+
} catch (\ValueError $e) {
21+
echo $e->getMessage(), PHP_EOL;
22+
}
23+
?>
24+
--EXPECT--
25+
socket_setopt(): Argument #4 ($value) must be of between 0 and 65535
26+
socket_setopt(): Argument #4 ($value) must be of between 0 and 65535

0 commit comments

Comments
 (0)