Skip to content

Commit

Permalink
Merge branch 'PHP-5.5'
Browse files Browse the repository at this point in the history
* PHP-5.5:
  Cleanup some multicast code; fix for mac os x?
  • Loading branch information
cataphract committed Feb 17, 2013
2 parents c389d33 + 91538e4 commit 427de31
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 38 deletions.
36 changes: 18 additions & 18 deletions ext/sockets/multicast.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,10 @@ static int php_do_mcast_opt(php_socket *php_sock, int level, int optname, zval *
#endif

switch (optname) {
case MCAST_JOIN_GROUP:
case PHP_MCAST_JOIN_GROUP:
mcast_req_fun = &php_mcast_join;
goto mcast_req_fun;
case MCAST_LEAVE_GROUP:
case PHP_MCAST_LEAVE_GROUP:
{
php_sockaddr_storage group = {0};
socklen_t glen;
Expand All @@ -180,16 +180,16 @@ static int php_do_mcast_opt(php_socket *php_sock, int level, int optname, zval *
}

#ifdef HAS_MCAST_EXT
case MCAST_BLOCK_SOURCE:
case PHP_MCAST_BLOCK_SOURCE:
mcast_sreq_fun = &php_mcast_block_source;
goto mcast_sreq_fun;
case MCAST_UNBLOCK_SOURCE:
case PHP_MCAST_UNBLOCK_SOURCE:
mcast_sreq_fun = &php_mcast_unblock_source;
goto mcast_sreq_fun;
case MCAST_JOIN_SOURCE_GROUP:
case PHP_MCAST_JOIN_SOURCE_GROUP:
mcast_sreq_fun = &php_mcast_join_source;
goto mcast_sreq_fun;
case MCAST_LEAVE_SOURCE_GROUP:
case PHP_MCAST_LEAVE_SOURCE_GROUP:
{
php_sockaddr_storage group = {0},
source = {0};
Expand Down Expand Up @@ -248,13 +248,13 @@ int php_do_setsockopt_ip_mcast(php_socket *php_sock,
int retval;

switch (optname) {
case MCAST_JOIN_GROUP:
case MCAST_LEAVE_GROUP:
case PHP_MCAST_JOIN_GROUP:
case PHP_MCAST_LEAVE_GROUP:
#ifdef HAS_MCAST_EXT
case MCAST_BLOCK_SOURCE:
case MCAST_UNBLOCK_SOURCE:
case MCAST_JOIN_SOURCE_GROUP:
case MCAST_LEAVE_SOURCE_GROUP:
case PHP_MCAST_BLOCK_SOURCE:
case PHP_MCAST_UNBLOCK_SOURCE:
case PHP_MCAST_JOIN_SOURCE_GROUP:
case PHP_MCAST_LEAVE_SOURCE_GROUP:
#endif
if (php_do_mcast_opt(php_sock, level, optname, arg4 TSRMLS_CC) == FAILURE) {
return FAILURE;
Expand Down Expand Up @@ -316,13 +316,13 @@ int php_do_setsockopt_ipv6_mcast(php_socket *php_sock,
int retval;

switch (optname) {
case MCAST_JOIN_GROUP:
case MCAST_LEAVE_GROUP:
case PHP_MCAST_JOIN_GROUP:
case PHP_MCAST_LEAVE_GROUP:
#ifdef HAS_MCAST_EXT
case MCAST_BLOCK_SOURCE:
case MCAST_UNBLOCK_SOURCE:
case MCAST_JOIN_SOURCE_GROUP:
case MCAST_LEAVE_SOURCE_GROUP:
case PHP_MCAST_BLOCK_SOURCE:
case PHP_MCAST_UNBLOCK_SOURCE:
case PHP_MCAST_JOIN_SOURCE_GROUP:
case PHP_MCAST_LEAVE_SOURCE_GROUP:
#endif
if (php_do_mcast_opt(php_sock, level, optname, arg4 TSRMLS_CC) == FAILURE) {
return FAILURE;
Expand Down
24 changes: 21 additions & 3 deletions ext/sockets/multicast.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,30 @@
/* $Id$ */

#if defined(MCAST_JOIN_GROUP) && !defined(__APPLE__)
#define RFC3678_API 1
# define RFC3678_API 1
/* has block/unblock and source membership, in this case for both IPv4 and IPv6 */
#define HAS_MCAST_EXT 1
# define HAS_MCAST_EXT 1
#elif defined(IP_ADD_SOURCE_MEMBERSHIP) && !defined(__APPLE__)
/* has block/unblock and source membership, but only for IPv4 */
#define HAS_MCAST_EXT 1
# define HAS_MCAST_EXT 1
#endif

#ifndef RFC3678_API
# define PHP_MCAST_JOIN_GROUP IP_ADD_MEMBERSHIP
# define PHP_MCAST_LEAVE_GROUP IP_DROP_MEMBERSHIP
# ifdef HAS_MCAST_EXT
# define PHP_MCAST_BLOCK_SOURCE IP_BLOCK_SOURCE
# define PHP_MCAST_UNBLOCK_SOURCE IP_UNBLOCK_SOURCE
# define PHP_MCAST_JOIN_SOURCE_GROUP IP_ADD_SOURCE_MEMBERSHIP
# define PHP_MCAST_LEAVE_SOURCE_GROUP IP_DROP_SOURCE_MEMBERSHIP
# endif
#else
# define PHP_MCAST_JOIN_GROUP MCAST_JOIN_GROUP
# define PHP_MCAST_LEAVE_GROUP MCAST_LEAVE_GROUP
# define PHP_MCAST_BLOCK_SOURCE MCAST_BLOCK_SOURCE
# define PHP_MCAST_UNBLOCK_SOURCE MCAST_UNBLOCK_SOURCE
# define PHP_MCAST_JOIN_SOURCE_GROUP MCAST_JOIN_SOURCE_GROUP
# define PHP_MCAST_LEAVE_SOURCE_GROUP MCAST_LEAVE_SOURCE_GROUP
#endif

int php_do_setsockopt_ip_mcast(php_socket *php_sock,
Expand Down
23 changes: 6 additions & 17 deletions ext/sockets/sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -688,24 +688,13 @@ PHP_MINIT_FUNCTION(sockets)
REGISTER_LONG_CONSTANT("PHP_NORMAL_READ", PHP_NORMAL_READ, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("PHP_BINARY_READ", PHP_BINARY_READ, CONST_CS | CONST_PERSISTENT);

#ifndef RFC3678_API
#define MCAST_JOIN_GROUP IP_ADD_MEMBERSHIP
#define MCAST_LEAVE_GROUP IP_DROP_MEMBERSHIP
REGISTER_LONG_CONSTANT("MCAST_JOIN_GROUP", PHP_MCAST_JOIN_GROUP, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("MCAST_LEAVE_GROUP", PHP_MCAST_LEAVE_GROUP, CONST_CS | CONST_PERSISTENT);
#ifdef HAS_MCAST_EXT
#define MCAST_BLOCK_SOURCE IP_BLOCK_SOURCE
#define MCAST_UNBLOCK_SOURCE IP_UNBLOCK_SOURCE
#define MCAST_JOIN_SOURCE_GROUP IP_ADD_SOURCE_MEMBERSHIP
#define MCAST_LEAVE_SOURCE_GROUP IP_DROP_SOURCE_MEMBERSHIP
#endif
#endif

REGISTER_LONG_CONSTANT("MCAST_JOIN_GROUP", MCAST_JOIN_GROUP, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("MCAST_LEAVE_GROUP", MCAST_LEAVE_GROUP, CONST_CS | CONST_PERSISTENT);
#ifdef HAS_MCAST_EXT
REGISTER_LONG_CONSTANT("MCAST_BLOCK_SOURCE", MCAST_BLOCK_SOURCE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("MCAST_UNBLOCK_SOURCE", MCAST_UNBLOCK_SOURCE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("MCAST_JOIN_SOURCE_GROUP", MCAST_JOIN_SOURCE_GROUP, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("MCAST_LEAVE_SOURCE_GROUP", MCAST_LEAVE_SOURCE_GROUP, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("MCAST_BLOCK_SOURCE", PHP_MCAST_BLOCK_SOURCE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("MCAST_UNBLOCK_SOURCE", PHP_MCAST_UNBLOCK_SOURCE, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("MCAST_JOIN_SOURCE_GROUP", PHP_MCAST_JOIN_SOURCE_GROUP, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("MCAST_LEAVE_SOURCE_GROUP", PHP_MCAST_LEAVE_SOURCE_GROUP, CONST_CS | CONST_PERSISTENT);
#endif

REGISTER_LONG_CONSTANT("IP_MULTICAST_IF", IP_MULTICAST_IF, CONST_CS | CONST_PERSISTENT);
Expand Down

0 comments on commit 427de31

Please sign in to comment.