183cbd279b64f3081af5c06d50fa26e15a99fc066qhuang/** @file 283cbd279b64f3081af5c06d50fa26e15a99fc066qhuang 31f6729ffe98095107ce82e67a4a0209674601a90jiaxinwuCopyright (c) 2005 - 2015, Intel Corporation. All rights reserved.<BR> 4e5eed7d3641d71d7ea539e5379ea9c6a5cd97004hhtianThis program and the accompanying materials 583cbd279b64f3081af5c06d50fa26e15a99fc066qhuangare licensed and made available under the terms and conditions of the BSD License 683cbd279b64f3081af5c06d50fa26e15a99fc066qhuangwhich accompanies this distribution. The full text of the license may be found at 783cbd279b64f3081af5c06d50fa26e15a99fc066qhuanghttp://opensource.org/licenses/bsd-license.php 883cbd279b64f3081af5c06d50fa26e15a99fc066qhuang 983cbd279b64f3081af5c06d50fa26e15a99fc066qhuangTHE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 1083cbd279b64f3081af5c06d50fa26e15a99fc066qhuangWITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 1183cbd279b64f3081af5c06d50fa26e15a99fc066qhuang 1283cbd279b64f3081af5c06d50fa26e15a99fc066qhuang**/ 1383cbd279b64f3081af5c06d50fa26e15a99fc066qhuang 1483cbd279b64f3081af5c06d50fa26e15a99fc066qhuang#ifndef __EFI_IP4_IGMP_H__ 1583cbd279b64f3081af5c06d50fa26e15a99fc066qhuang#define __EFI_IP4_IGMP_H__ 1683cbd279b64f3081af5c06d50fa26e15a99fc066qhuang 17f6b7393ceb34c9b3a27434268bf2ce517047641ftye// 18f6b7393ceb34c9b3a27434268bf2ce517047641ftye// IGMP message type 19f6b7393ceb34c9b3a27434268bf2ce517047641ftye// 20f6b7393ceb34c9b3a27434268bf2ce517047641ftye#define IGMP_MEMBERSHIP_QUERY 0x11 21f6b7393ceb34c9b3a27434268bf2ce517047641ftye#define IGMP_V1_MEMBERSHIP_REPORT 0x12 22f6b7393ceb34c9b3a27434268bf2ce517047641ftye#define IGMP_V2_MEMBERSHIP_REPORT 0x16 23f6b7393ceb34c9b3a27434268bf2ce517047641ftye#define IGMP_LEAVE_GROUP 0x17 24f6b7393ceb34c9b3a27434268bf2ce517047641ftye 25f6b7393ceb34c9b3a27434268bf2ce517047641ftye#define IGMP_V1ROUTER_PRESENT 400 26f6b7393ceb34c9b3a27434268bf2ce517047641ftye#define IGMP_UNSOLICIATED_REPORT 10 27f6b7393ceb34c9b3a27434268bf2ce517047641ftye 2883cbd279b64f3081af5c06d50fa26e15a99fc066qhuang#pragma pack(1) 2983cbd279b64f3081af5c06d50fa26e15a99fc066qhuangtypedef struct { 3083cbd279b64f3081af5c06d50fa26e15a99fc066qhuang UINT8 Type; 3183cbd279b64f3081af5c06d50fa26e15a99fc066qhuang UINT8 MaxRespTime; 3283cbd279b64f3081af5c06d50fa26e15a99fc066qhuang UINT16 Checksum; 3383cbd279b64f3081af5c06d50fa26e15a99fc066qhuang IP4_ADDR Group; 3483cbd279b64f3081af5c06d50fa26e15a99fc066qhuang} IGMP_HEAD; 3583cbd279b64f3081af5c06d50fa26e15a99fc066qhuang#pragma pack() 3683cbd279b64f3081af5c06d50fa26e15a99fc066qhuang 3796e1079fa412753e42edf293ce28adda88e68a45jgong/// 3896e1079fa412753e42edf293ce28adda88e68a45jgong/// The status of multicast group. It isn't necessary to maintain 3996e1079fa412753e42edf293ce28adda88e68a45jgong/// explicit state of host state diagram. A group with non-zero 4096e1079fa412753e42edf293ce28adda88e68a45jgong/// DelayTime is in "delaying member" state. otherwise, it is in 4196e1079fa412753e42edf293ce28adda88e68a45jgong/// "idle member" state. 4296e1079fa412753e42edf293ce28adda88e68a45jgong/// 4383cbd279b64f3081af5c06d50fa26e15a99fc066qhuangtypedef struct { 44e48e37fce2611df7a52aff271835ff72ee396d9bvanjeff LIST_ENTRY Link; 4583cbd279b64f3081af5c06d50fa26e15a99fc066qhuang INTN RefCnt; 4683cbd279b64f3081af5c06d50fa26e15a99fc066qhuang IP4_ADDR Address; 4783cbd279b64f3081af5c06d50fa26e15a99fc066qhuang INTN DelayTime; 4883cbd279b64f3081af5c06d50fa26e15a99fc066qhuang BOOLEAN ReportByUs; 4983cbd279b64f3081af5c06d50fa26e15a99fc066qhuang EFI_MAC_ADDRESS Mac; 5083cbd279b64f3081af5c06d50fa26e15a99fc066qhuang} IGMP_GROUP; 5183cbd279b64f3081af5c06d50fa26e15a99fc066qhuang 5296e1079fa412753e42edf293ce28adda88e68a45jgong/// 5396e1079fa412753e42edf293ce28adda88e68a45jgong/// The IGMP status. Each IP4 service instance has a IGMP_SERVICE_DATA 5496e1079fa412753e42edf293ce28adda88e68a45jgong/// attached. The Igmpv1QuerySeen remember whether the server on this 5596e1079fa412753e42edf293ce28adda88e68a45jgong/// connected network is v1 or v2. 5696e1079fa412753e42edf293ce28adda88e68a45jgong/// 5783cbd279b64f3081af5c06d50fa26e15a99fc066qhuangtypedef struct { 5883cbd279b64f3081af5c06d50fa26e15a99fc066qhuang INTN Igmpv1QuerySeen; 59e48e37fce2611df7a52aff271835ff72ee396d9bvanjeff LIST_ENTRY Groups; 6083cbd279b64f3081af5c06d50fa26e15a99fc066qhuang} IGMP_SERVICE_DATA; 6183cbd279b64f3081af5c06d50fa26e15a99fc066qhuang 622ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong/** 632ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong Init the IGMP control data of the IP4 service instance, configure 642ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong MNP to receive ALL SYSTEM multicast. 652ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong 663e8c18da0441069591e5aa218f378001b29512ddjgong @param[in, out] IpSb The IP4 service whose IGMP is to be initialized. 672ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong 682ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong @retval EFI_SUCCESS IGMP of the IpSb is successfully initialized. 692ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong @retval EFI_OUT_OF_RESOURCES Failed to allocate resource to initialize IGMP. 702ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong @retval Others Failed to initialize the IGMP of IpSb. 712ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong 722ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong**/ 7383cbd279b64f3081af5c06d50fa26e15a99fc066qhuangEFI_STATUS 7483cbd279b64f3081af5c06d50fa26e15a99fc066qhuangIp4InitIgmp ( 752ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong IN OUT IP4_SERVICE *IpSb 7683cbd279b64f3081af5c06d50fa26e15a99fc066qhuang ); 7783cbd279b64f3081af5c06d50fa26e15a99fc066qhuang 782ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong/** 792ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong Join the multicast group on behalf of this IP4 child 802ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong 811f6729ffe98095107ce82e67a4a0209674601a90jiaxinwu @param[in] IpInstance The IP4 child that wants to join the group. 821f6729ffe98095107ce82e67a4a0209674601a90jiaxinwu @param[in] Address The group to join. 832ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong 841f6729ffe98095107ce82e67a4a0209674601a90jiaxinwu @retval EFI_SUCCESS Successfully join the multicast group. 851f6729ffe98095107ce82e67a4a0209674601a90jiaxinwu @retval EFI_OUT_OF_RESOURCES Failed to allocate resources. 862ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong @retval Others Failed to join the multicast group. 872ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong 882ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong**/ 8983cbd279b64f3081af5c06d50fa26e15a99fc066qhuangEFI_STATUS 9083cbd279b64f3081af5c06d50fa26e15a99fc066qhuangIp4JoinGroup ( 912ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong IN IP4_PROTOCOL *IpInstance, 922ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong IN IP4_ADDR Address 9383cbd279b64f3081af5c06d50fa26e15a99fc066qhuang ); 9483cbd279b64f3081af5c06d50fa26e15a99fc066qhuang 952ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong/** 962ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong Leave the IP4 multicast group on behalf of IpInstance. 972ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong 983e8c18da0441069591e5aa218f378001b29512ddjgong @param[in] IpInstance The IP4 child that wants to leave the group 991f6729ffe98095107ce82e67a4a0209674601a90jiaxinwu address. 1001f6729ffe98095107ce82e67a4a0209674601a90jiaxinwu @param[in] Address The group address to leave. 1012ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong 1021f6729ffe98095107ce82e67a4a0209674601a90jiaxinwu @retval EFI_NOT_FOUND The IP4 service instance isn't in the group. 1032ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong @retval EFI_SUCCESS Successfully leave the multicast group. 1042ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong @retval Others Failed to leave the multicast group. 1052ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong 1062ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong**/ 10783cbd279b64f3081af5c06d50fa26e15a99fc066qhuangEFI_STATUS 10883cbd279b64f3081af5c06d50fa26e15a99fc066qhuangIp4LeaveGroup ( 1092ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong IN IP4_PROTOCOL *IpInstance, 1102ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong IN IP4_ADDR Address 11183cbd279b64f3081af5c06d50fa26e15a99fc066qhuang ); 11283cbd279b64f3081af5c06d50fa26e15a99fc066qhuang 1132ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong/** 1142ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong Handle the received IGMP message for the IP4 service instance. 1152ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong 1161f6729ffe98095107ce82e67a4a0209674601a90jiaxinwu @param[in] IpSb The IP4 service instance that received the message. 1171f6729ffe98095107ce82e67a4a0209674601a90jiaxinwu @param[in] Head The IP4 header of the received message. 1181f6729ffe98095107ce82e67a4a0209674601a90jiaxinwu @param[in] Packet The IGMP message, without IP4 header. 1192ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong 1202ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong @retval EFI_INVALID_PARAMETER The IGMP message is malformated. 1212ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong @retval EFI_SUCCESS The IGMP message is successfully processed. 1222ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong 1232ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong**/ 12483cbd279b64f3081af5c06d50fa26e15a99fc066qhuangEFI_STATUS 12583cbd279b64f3081af5c06d50fa26e15a99fc066qhuangIp4IgmpHandle ( 1262ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong IN IP4_SERVICE *IpSb, 1272ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong IN IP4_HEAD *Head, 1282ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong IN NET_BUF *Packet 12983cbd279b64f3081af5c06d50fa26e15a99fc066qhuang ); 13083cbd279b64f3081af5c06d50fa26e15a99fc066qhuang 1312ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong/** 1322ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong The periodical timer function for IGMP. It does the following 1332ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong things: 1342ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong 1. Decrease the Igmpv1QuerySeen to make it possible to refresh 1352ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong the IGMP server type. 1362ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong 2. Decrease the report timer for each IGMP group in "delaying 1372ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong member" state. 1382ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong 1391f6729ffe98095107ce82e67a4a0209674601a90jiaxinwu @param[in] IpSb The IP4 service instance that is ticking. 1402ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong 1412ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong**/ 14283cbd279b64f3081af5c06d50fa26e15a99fc066qhuangVOID 14383cbd279b64f3081af5c06d50fa26e15a99fc066qhuangIp4IgmpTicking ( 1442ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong IN IP4_SERVICE *IpSb 14583cbd279b64f3081af5c06d50fa26e15a99fc066qhuang ); 14683cbd279b64f3081af5c06d50fa26e15a99fc066qhuang 1472ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong/** 1482ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong Add a group address to the array of group addresses. 1492ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong The caller should make sure that no duplicated address 1502ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong existed in the array. Although the function doesn't 1512ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong assume the byte order of the both Source and Addr, the 1522ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong network byte order is used by the caller. 1532ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong 1541f6729ffe98095107ce82e67a4a0209674601a90jiaxinwu @param[in] Source The array of group addresses to add to. 1551f6729ffe98095107ce82e67a4a0209674601a90jiaxinwu @param[in] Count The number of group addresses in the Source. 1561f6729ffe98095107ce82e67a4a0209674601a90jiaxinwu @param[in] Addr The IP4 multicast address to add. 1572ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong 1582ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong @return NULL if failed to allocate memory for the new groups, 1592ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong otherwise the new combined group addresses. 1602ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong 1612ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong**/ 16283cbd279b64f3081af5c06d50fa26e15a99fc066qhuangIP4_ADDR * 16383cbd279b64f3081af5c06d50fa26e15a99fc066qhuangIp4CombineGroups ( 1642ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong IN IP4_ADDR *Source, 1652ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong IN UINT32 Count, 1662ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong IN IP4_ADDR Addr 16783cbd279b64f3081af5c06d50fa26e15a99fc066qhuang ); 16883cbd279b64f3081af5c06d50fa26e15a99fc066qhuang 1692ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong/** 1702ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong Remove a group address from the array of group addresses. 1712ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong Although the function doesn't assume the byte order of the 1722ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong both Groups and Addr, the network byte order is used by 1732ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong the caller. 1742ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong 1751f6729ffe98095107ce82e67a4a0209674601a90jiaxinwu @param Groups The array of group addresses to remove from. 1761f6729ffe98095107ce82e67a4a0209674601a90jiaxinwu @param Count The number of group addresses in the Groups. 1771f6729ffe98095107ce82e67a4a0209674601a90jiaxinwu @param Addr The IP4 multicast address to remove. 1782ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong 1792ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong @return The nubmer of group addresses in the Groups after remove. 1802ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong It is Count if the Addr isn't in the Groups. 1812ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong 1822ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong**/ 18383cbd279b64f3081af5c06d50fa26e15a99fc066qhuangINTN 18483cbd279b64f3081af5c06d50fa26e15a99fc066qhuangIp4RemoveGroupAddr ( 1852ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong IN OUT IP4_ADDR *Groups, 1862ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong IN UINT32 Count, 1872ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong IN IP4_ADDR Addr 18883cbd279b64f3081af5c06d50fa26e15a99fc066qhuang ); 18983cbd279b64f3081af5c06d50fa26e15a99fc066qhuang 1902ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong/** 1912ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong Find the IGMP_GROUP structure which contains the status of multicast 1922ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong group Address in this IGMP control block 1932ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong 1941f6729ffe98095107ce82e67a4a0209674601a90jiaxinwu @param[in] IgmpCtrl The IGMP control block to search from. 1951f6729ffe98095107ce82e67a4a0209674601a90jiaxinwu @param[in] Address The multicast address to search. 1962ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong 1972ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong @return NULL if the multicast address isn't in the IGMP control block. Otherwise 1982ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong the point to the IGMP_GROUP which contains the status of multicast group 1992ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong for Address. 2002ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong 2012ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong**/ 20283cbd279b64f3081af5c06d50fa26e15a99fc066qhuangIGMP_GROUP * 20383cbd279b64f3081af5c06d50fa26e15a99fc066qhuangIp4FindGroup ( 2042ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong IN IGMP_SERVICE_DATA *IgmpCtrl, 2052ff2921247ab4cf5eaa6a0b0358a531e6bfacbcbjgong IN IP4_ADDR Address 20683cbd279b64f3081af5c06d50fa26e15a99fc066qhuang ); 20783cbd279b64f3081af5c06d50fa26e15a99fc066qhuang#endif 208