Ip4Igmp.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. /** @file
  2. Copyright (c) 2005 - 2015, Intel Corporation. All rights reserved.<BR>
  3. SPDX-License-Identifier: BSD-2-Clause-Patent
  4. **/
  5. #ifndef __EFI_IP4_IGMP_H__
  6. #define __EFI_IP4_IGMP_H__
  7. //
  8. // IGMP message type
  9. //
  10. #define IGMP_MEMBERSHIP_QUERY 0x11
  11. #define IGMP_V1_MEMBERSHIP_REPORT 0x12
  12. #define IGMP_V2_MEMBERSHIP_REPORT 0x16
  13. #define IGMP_LEAVE_GROUP 0x17
  14. #define IGMP_V1ROUTER_PRESENT 400
  15. #define IGMP_UNSOLICIATED_REPORT 10
  16. #pragma pack(1)
  17. typedef struct {
  18. UINT8 Type;
  19. UINT8 MaxRespTime;
  20. UINT16 Checksum;
  21. IP4_ADDR Group;
  22. } IGMP_HEAD;
  23. #pragma pack()
  24. ///
  25. /// The status of multicast group. It isn't necessary to maintain
  26. /// explicit state of host state diagram. A group with non-zero
  27. /// DelayTime is in "delaying member" state. otherwise, it is in
  28. /// "idle member" state.
  29. ///
  30. typedef struct {
  31. LIST_ENTRY Link;
  32. INTN RefCnt;
  33. IP4_ADDR Address;
  34. INTN DelayTime;
  35. BOOLEAN ReportByUs;
  36. EFI_MAC_ADDRESS Mac;
  37. } IGMP_GROUP;
  38. ///
  39. /// The IGMP status. Each IP4 service instance has a IGMP_SERVICE_DATA
  40. /// attached. The Igmpv1QuerySeen remember whether the server on this
  41. /// connected network is v1 or v2.
  42. ///
  43. typedef struct {
  44. INTN Igmpv1QuerySeen;
  45. LIST_ENTRY Groups;
  46. } IGMP_SERVICE_DATA;
  47. /**
  48. Init the IGMP control data of the IP4 service instance, configure
  49. MNP to receive ALL SYSTEM multicast.
  50. @param[in, out] IpSb The IP4 service whose IGMP is to be initialized.
  51. @retval EFI_SUCCESS IGMP of the IpSb is successfully initialized.
  52. @retval EFI_OUT_OF_RESOURCES Failed to allocate resource to initialize IGMP.
  53. @retval Others Failed to initialize the IGMP of IpSb.
  54. **/
  55. EFI_STATUS
  56. Ip4InitIgmp (
  57. IN OUT IP4_SERVICE *IpSb
  58. );
  59. /**
  60. Join the multicast group on behalf of this IP4 child
  61. @param[in] IpInstance The IP4 child that wants to join the group.
  62. @param[in] Address The group to join.
  63. @retval EFI_SUCCESS Successfully join the multicast group.
  64. @retval EFI_OUT_OF_RESOURCES Failed to allocate resources.
  65. @retval Others Failed to join the multicast group.
  66. **/
  67. EFI_STATUS
  68. Ip4JoinGroup (
  69. IN IP4_PROTOCOL *IpInstance,
  70. IN IP4_ADDR Address
  71. );
  72. /**
  73. Leave the IP4 multicast group on behalf of IpInstance.
  74. @param[in] IpInstance The IP4 child that wants to leave the group
  75. address.
  76. @param[in] Address The group address to leave.
  77. @retval EFI_NOT_FOUND The IP4 service instance isn't in the group.
  78. @retval EFI_SUCCESS Successfully leave the multicast group.
  79. @retval Others Failed to leave the multicast group.
  80. **/
  81. EFI_STATUS
  82. Ip4LeaveGroup (
  83. IN IP4_PROTOCOL *IpInstance,
  84. IN IP4_ADDR Address
  85. );
  86. /**
  87. Handle the received IGMP message for the IP4 service instance.
  88. @param[in] IpSb The IP4 service instance that received the message.
  89. @param[in] Head The IP4 header of the received message.
  90. @param[in] Packet The IGMP message, without IP4 header.
  91. @retval EFI_INVALID_PARAMETER The IGMP message is malformatted.
  92. @retval EFI_SUCCESS The IGMP message is successfully processed.
  93. **/
  94. EFI_STATUS
  95. Ip4IgmpHandle (
  96. IN IP4_SERVICE *IpSb,
  97. IN IP4_HEAD *Head,
  98. IN NET_BUF *Packet
  99. );
  100. /**
  101. The periodical timer function for IGMP. It does the following
  102. things:
  103. 1. Decrease the Igmpv1QuerySeen to make it possible to refresh
  104. the IGMP server type.
  105. 2. Decrease the report timer for each IGMP group in "delaying
  106. member" state.
  107. @param[in] IpSb The IP4 service instance that is ticking.
  108. **/
  109. VOID
  110. Ip4IgmpTicking (
  111. IN IP4_SERVICE *IpSb
  112. );
  113. /**
  114. Add a group address to the array of group addresses.
  115. The caller should make sure that no duplicated address
  116. existed in the array. Although the function doesn't
  117. assume the byte order of the both Source and Addr, the
  118. network byte order is used by the caller.
  119. @param[in] Source The array of group addresses to add to.
  120. @param[in] Count The number of group addresses in the Source.
  121. @param[in] Addr The IP4 multicast address to add.
  122. @return NULL if failed to allocate memory for the new groups,
  123. otherwise the new combined group addresses.
  124. **/
  125. IP4_ADDR *
  126. Ip4CombineGroups (
  127. IN IP4_ADDR *Source,
  128. IN UINT32 Count,
  129. IN IP4_ADDR Addr
  130. );
  131. /**
  132. Remove a group address from the array of group addresses.
  133. Although the function doesn't assume the byte order of the
  134. both Groups and Addr, the network byte order is used by
  135. the caller.
  136. @param Groups The array of group addresses to remove from.
  137. @param Count The number of group addresses in the Groups.
  138. @param Addr The IP4 multicast address to remove.
  139. @return The number of group addresses in the Groups after remove.
  140. It is Count if the Addr isn't in the Groups.
  141. **/
  142. INTN
  143. Ip4RemoveGroupAddr (
  144. IN OUT IP4_ADDR *Groups,
  145. IN UINT32 Count,
  146. IN IP4_ADDR Addr
  147. );
  148. /**
  149. Find the IGMP_GROUP structure which contains the status of multicast
  150. group Address in this IGMP control block
  151. @param[in] IgmpCtrl The IGMP control block to search from.
  152. @param[in] Address The multicast address to search.
  153. @return NULL if the multicast address isn't in the IGMP control block. Otherwise
  154. the point to the IGMP_GROUP which contains the status of multicast group
  155. for Address.
  156. **/
  157. IGMP_GROUP *
  158. Ip4FindGroup (
  159. IN IGMP_SERVICE_DATA *IgmpCtrl,
  160. IN IP4_ADDR Address
  161. );
  162. #endif