multicast.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. +----------------------------------------------------------------------+
  3. | PHP Version 7 |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) 1997-2018 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. #if defined(MCAST_JOIN_GROUP) && !defined(__APPLE__)
  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. #ifndef RFC3678_API
  27. # define PHP_MCAST_JOIN_GROUP IP_ADD_MEMBERSHIP
  28. # define PHP_MCAST_LEAVE_GROUP IP_DROP_MEMBERSHIP
  29. # ifdef HAS_MCAST_EXT
  30. # define PHP_MCAST_BLOCK_SOURCE IP_BLOCK_SOURCE
  31. # define PHP_MCAST_UNBLOCK_SOURCE IP_UNBLOCK_SOURCE
  32. # define PHP_MCAST_JOIN_SOURCE_GROUP IP_ADD_SOURCE_MEMBERSHIP
  33. # define PHP_MCAST_LEAVE_SOURCE_GROUP IP_DROP_SOURCE_MEMBERSHIP
  34. # endif
  35. #else
  36. # define PHP_MCAST_JOIN_GROUP MCAST_JOIN_GROUP
  37. # define PHP_MCAST_LEAVE_GROUP MCAST_LEAVE_GROUP
  38. # define PHP_MCAST_BLOCK_SOURCE MCAST_BLOCK_SOURCE
  39. # define PHP_MCAST_UNBLOCK_SOURCE MCAST_UNBLOCK_SOURCE
  40. # define PHP_MCAST_JOIN_SOURCE_GROUP MCAST_JOIN_SOURCE_GROUP
  41. # define PHP_MCAST_LEAVE_SOURCE_GROUP MCAST_LEAVE_SOURCE_GROUP
  42. #endif
  43. int php_do_setsockopt_ip_mcast(php_socket *php_sock,
  44. int level,
  45. int optname,
  46. zval *arg4);
  47. int php_do_setsockopt_ipv6_mcast(php_socket *php_sock,
  48. int level,
  49. int optname,
  50. zval *arg4);
  51. int php_if_index_to_addr4(
  52. unsigned if_index,
  53. php_socket *php_sock,
  54. struct in_addr *out_addr);
  55. int php_add4_to_if_index(
  56. struct in_addr *addr,
  57. php_socket *php_sock,
  58. unsigned *if_index);
  59. int php_string_to_if_index(const char *val, unsigned *out);
  60. int php_mcast_join(
  61. php_socket *sock,
  62. int level,
  63. struct sockaddr *group,
  64. socklen_t group_len,
  65. unsigned int if_index);
  66. int php_mcast_leave(
  67. php_socket *sock,
  68. int level,
  69. struct sockaddr *group,
  70. socklen_t group_len,
  71. unsigned int if_index);
  72. #ifdef HAS_MCAST_EXT
  73. int php_mcast_join_source(
  74. php_socket *sock,
  75. int level,
  76. struct sockaddr *group,
  77. socklen_t group_len,
  78. struct sockaddr *source,
  79. socklen_t source_len,
  80. unsigned int if_index);
  81. int php_mcast_leave_source(
  82. php_socket *sock,
  83. int level,
  84. struct sockaddr *group,
  85. socklen_t group_len,
  86. struct sockaddr *source,
  87. socklen_t source_len,
  88. unsigned int if_index);
  89. int php_mcast_block_source(
  90. php_socket *sock,
  91. int level,
  92. struct sockaddr *group,
  93. socklen_t group_len,
  94. struct sockaddr *source,
  95. socklen_t source_len,
  96. unsigned int if_index);
  97. int php_mcast_unblock_source(
  98. php_socket *sock,
  99. int level,
  100. struct sockaddr *group,
  101. socklen_t group_len,
  102. struct sockaddr *source,
  103. socklen_t source_len,
  104. unsigned int if_index);
  105. #endif