1 /* 2 +----------------------------------------------------------------------+ 3 | Copyright (c) The PHP Group | 4 +----------------------------------------------------------------------+ 5 | This source file is subject to version 3.01 of the PHP license, | 6 | that is bundled with this package in the file LICENSE, and is | 7 | available through the world-wide-web at the following url: | 8 | https://www.php.net/license/3_01.txt | 9 | If you did not receive a copy of the PHP license and are unable to | 10 | obtain it through the world-wide-web, please send a note to | 11 | license@php.net so we can mail you a copy immediately. | 12 +----------------------------------------------------------------------+ 13 | Authors: Gustavo Lopes <cataphract@php.net> | 14 +----------------------------------------------------------------------+ 15 */ 16 17 // TODO using setsourcefilter api on freebsd to support both ipv4/ipv6. 18 #if defined(MCAST_JOIN_GROUP) && !defined(__APPLE__) && !defined(__FreeBSD__) 19 # define RFC3678_API 1 20 /* has block/unblock and source membership, in this case for both IPv4 and IPv6 */ 21 # define HAS_MCAST_EXT 1 22 #elif defined(IP_ADD_SOURCE_MEMBERSHIP) && !defined(__APPLE__) 23 /* has block/unblock and source membership, but only for IPv4 */ 24 # define HAS_MCAST_EXT 1 25 #endif 26 27 #ifndef RFC3678_API 28 # define PHP_MCAST_JOIN_GROUP IP_ADD_MEMBERSHIP 29 # define PHP_MCAST_LEAVE_GROUP IP_DROP_MEMBERSHIP 30 # ifdef HAS_MCAST_EXT 31 # define PHP_MCAST_BLOCK_SOURCE IP_BLOCK_SOURCE 32 # define PHP_MCAST_UNBLOCK_SOURCE IP_UNBLOCK_SOURCE 33 # define PHP_MCAST_JOIN_SOURCE_GROUP IP_ADD_SOURCE_MEMBERSHIP 34 # define PHP_MCAST_LEAVE_SOURCE_GROUP IP_DROP_SOURCE_MEMBERSHIP 35 # endif 36 #else 37 # define PHP_MCAST_JOIN_GROUP MCAST_JOIN_GROUP 38 # define PHP_MCAST_LEAVE_GROUP MCAST_LEAVE_GROUP 39 # define PHP_MCAST_BLOCK_SOURCE MCAST_BLOCK_SOURCE 40 # define PHP_MCAST_UNBLOCK_SOURCE MCAST_UNBLOCK_SOURCE 41 # define PHP_MCAST_JOIN_SOURCE_GROUP MCAST_JOIN_SOURCE_GROUP 42 # define PHP_MCAST_LEAVE_SOURCE_GROUP MCAST_LEAVE_SOURCE_GROUP 43 #endif 44 45 int php_do_setsockopt_ip_mcast(php_socket *php_sock, 46 int level, 47 int optname, 48 zval *arg4); 49 50 int php_do_setsockopt_ipv6_mcast(php_socket *php_sock, 51 int level, 52 int optname, 53 zval *arg4); 54 55 zend_result php_if_index_to_addr4( 56 unsigned if_index, 57 php_socket *php_sock, 58 struct in_addr *out_addr); 59 60 zend_result php_add4_to_if_index( 61 struct in_addr *addr, 62 php_socket *php_sock, 63 unsigned *if_index); 64 65 zend_result php_string_to_if_index(const char *val, unsigned *out); 66 67 int php_mcast_join( 68 php_socket *sock, 69 int level, 70 struct sockaddr *group, 71 socklen_t group_len, 72 unsigned int if_index); 73 74 int php_mcast_leave( 75 php_socket *sock, 76 int level, 77 struct sockaddr *group, 78 socklen_t group_len, 79 unsigned int if_index); 80 81 #ifdef HAS_MCAST_EXT 82 int php_mcast_join_source( 83 php_socket *sock, 84 int level, 85 struct sockaddr *group, 86 socklen_t group_len, 87 struct sockaddr *source, 88 socklen_t source_len, 89 unsigned int if_index); 90 91 int php_mcast_leave_source( 92 php_socket *sock, 93 int level, 94 struct sockaddr *group, 95 socklen_t group_len, 96 struct sockaddr *source, 97 socklen_t source_len, 98 unsigned int if_index); 99 100 int php_mcast_block_source( 101 php_socket *sock, 102 int level, 103 struct sockaddr *group, 104 socklen_t group_len, 105 struct sockaddr *source, 106 socklen_t source_len, 107 unsigned int if_index); 108 109 int php_mcast_unblock_source( 110 php_socket *sock, 111 int level, 112 struct sockaddr *group, 113 socklen_t group_len, 114 struct sockaddr *source, 115 socklen_t source_len, 116 unsigned int if_index); 117 #endif 118