multicast.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. #if defined(MCAST_JOIN_GROUP) && !defined(__APPLE__)
  17. # define RFC3678_API 1
  18. /* has block/unblock and source membership, in this case for both IPv4 and IPv6 */
  19. # define HAS_MCAST_EXT 1
  20. #elif defined(IP_ADD_SOURCE_MEMBERSHIP) && !defined(__APPLE__)
  21. /* has block/unblock and source membership, but only for IPv4 */
  22. # define HAS_MCAST_EXT 1
  23. #endif
  24. #ifndef RFC3678_API
  25. # define PHP_MCAST_JOIN_GROUP IP_ADD_MEMBERSHIP
  26. # define PHP_MCAST_LEAVE_GROUP IP_DROP_MEMBERSHIP
  27. # ifdef HAS_MCAST_EXT
  28. # define PHP_MCAST_BLOCK_SOURCE IP_BLOCK_SOURCE
  29. # define PHP_MCAST_UNBLOCK_SOURCE IP_UNBLOCK_SOURCE
  30. # define PHP_MCAST_JOIN_SOURCE_GROUP IP_ADD_SOURCE_MEMBERSHIP
  31. # define PHP_MCAST_LEAVE_SOURCE_GROUP IP_DROP_SOURCE_MEMBERSHIP
  32. # endif
  33. #else
  34. # define PHP_MCAST_JOIN_GROUP MCAST_JOIN_GROUP
  35. # define PHP_MCAST_LEAVE_GROUP MCAST_LEAVE_GROUP
  36. # define PHP_MCAST_BLOCK_SOURCE MCAST_BLOCK_SOURCE
  37. # define PHP_MCAST_UNBLOCK_SOURCE MCAST_UNBLOCK_SOURCE
  38. # define PHP_MCAST_JOIN_SOURCE_GROUP MCAST_JOIN_SOURCE_GROUP
  39. # define PHP_MCAST_LEAVE_SOURCE_GROUP MCAST_LEAVE_SOURCE_GROUP
  40. #endif
  41. int php_do_setsockopt_ip_mcast(php_socket *php_sock,
  42. int level,
  43. int optname,
  44. zval *arg4);
  45. int php_do_setsockopt_ipv6_mcast(php_socket *php_sock,
  46. int level,
  47. int optname,
  48. zval *arg4);
  49. int php_if_index_to_addr4(
  50. unsigned if_index,
  51. php_socket *php_sock,
  52. struct in_addr *out_addr);
  53. int php_add4_to_if_index(
  54. struct in_addr *addr,
  55. php_socket *php_sock,
  56. unsigned *if_index);
  57. int php_string_to_if_index(const char *val, unsigned *out);
  58. int php_mcast_join(
  59. php_socket *sock,
  60. int level,
  61. struct sockaddr *group,
  62. socklen_t group_len,
  63. unsigned int if_index);
  64. int php_mcast_leave(
  65. php_socket *sock,
  66. int level,
  67. struct sockaddr *group,
  68. socklen_t group_len,
  69. unsigned int if_index);
  70. #ifdef HAS_MCAST_EXT
  71. int php_mcast_join_source(
  72. php_socket *sock,
  73. int level,
  74. struct sockaddr *group,
  75. socklen_t group_len,
  76. struct sockaddr *source,
  77. socklen_t source_len,
  78. unsigned int if_index);
  79. int php_mcast_leave_source(
  80. php_socket *sock,
  81. int level,
  82. struct sockaddr *group,
  83. socklen_t group_len,
  84. struct sockaddr *source,
  85. socklen_t source_len,
  86. unsigned int if_index);
  87. int php_mcast_block_source(
  88. php_socket *sock,
  89. int level,
  90. struct sockaddr *group,
  91. socklen_t group_len,
  92. struct sockaddr *source,
  93. socklen_t source_len,
  94. unsigned int if_index);
  95. int php_mcast_unblock_source(
  96. php_socket *sock,
  97. int level,
  98. struct sockaddr *group,
  99. socklen_t group_len,
  100. struct sockaddr *source,
  101. socklen_t source_len,
  102. unsigned int if_index);
  103. #endif