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