X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FNetwork%2FIp4Dxe%2FIp4Common.h;h=e0fffc9d0da20eeb5dcdb31a62cc3dfd7bb3dc63;hp=553714e89b0851777029cdf89c65b2d8ff153af3;hb=d1102dba7210b95e41d06c2338a22ba6af248645;hpb=2ff2921247ab4cf5eaa6a0b0358a531e6bfacbcb diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Common.h b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Common.h index 553714e89b..e0fffc9d0d 100644 --- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Common.h +++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Common.h @@ -1,7 +1,8 @@ /** @file + Common definition for IP4. -Copyright (c) 2005 - 2006, Intel Corporation -All rights reserved. This program and the accompanying materials +Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.
+This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -9,16 +10,6 @@ http://opensource.org/licenses/bsd-license.php THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -Module Name: - - Ip4Common.h - -Abstract: - - Common definition for IP4. - - **/ #ifndef __EFI_IP4_COMMON_H__ @@ -28,38 +19,32 @@ typedef struct _IP4_INTERFACE IP4_INTERFACE; typedef struct _IP4_PROTOCOL IP4_PROTOCOL; typedef struct _IP4_SERVICE IP4_SERVICE; - -typedef enum { - IP4_ETHER_PROTO = 0x0800, - - IP4_PROTO_ICMP = 0x01, - IP4_PROTO_IGMP = 0x02, - - // - // The packet is received as link level broadcast/multicast/promiscuous. - // - IP4_LINK_BROADCAST = 0x00000001, - IP4_LINK_MULTICAST = 0x00000002, - IP4_LINK_PROMISC = 0x00000004, - - // - // IP4 address cast type classfication. Keep it true that any - // type bigger than or equal to LOCAL_BROADCAST is broadcast. - // - IP4_PROMISCUOUS = 1, - IP4_LOCAL_HOST, - IP4_MULTICAST, - IP4_LOCAL_BROADCAST, // Destination is 255.255.255.255 - IP4_SUBNET_BROADCAST, - IP4_NET_BROADCAST, - - // - // IP4 header flags - // - IP4_HEAD_DF_MASK = 0x4000, - IP4_HEAD_MF_MASK = 0x2000, - IP4_HEAD_OFFSET_MASK = 0x1fff -} IP_ENUM_TYPES; +#define IP4_ETHER_PROTO 0x0800 + +// +// The packet is received as link level broadcast/multicast/promiscuous. +// +#define IP4_LINK_BROADCAST 0x00000001 +#define IP4_LINK_MULTICAST 0x00000002 +#define IP4_LINK_PROMISC 0x00000004 + +// +// IP4 address cast type classfication. Keep it true that any +// type bigger than or equal to LOCAL_BROADCAST is broadcast. +// +#define IP4_PROMISCUOUS 1 +#define IP4_LOCAL_HOST 2 +#define IP4_MULTICAST 3 +#define IP4_LOCAL_BROADCAST 4 // Destination is 255.255.255.255 +#define IP4_SUBNET_BROADCAST 5 +#define IP4_NET_BROADCAST 6 + +// +// IP4 header flags +// +#define IP4_HEAD_DF_MASK 0x4000 +#define IP4_HEAD_MF_MASK 0x2000 +#define IP4_HEAD_OFFSET_MASK 0x1fff #define IP4_ALLZERO_ADDRESS 0x00000000u #define IP4_ALLONE_ADDRESS 0xFFFFFFFFu @@ -78,6 +63,9 @@ typedef enum { #define IP4_FIRST_FRAGMENT(FragmentField) \ ((BOOLEAN)(((FragmentField) & IP4_HEAD_OFFSET_MASK) == 0)) +#define IP4_DO_NOT_FRAGMENT(FragmentField) \ + ((BOOLEAN)(((FragmentField) & IP4_HEAD_DF_MASK) == IP4_HEAD_DF_MASK)) + #define IP4_IS_BROADCAST(CastType) ((CastType) >= IP4_LOCAL_BROADCAST) /// @@ -90,8 +78,8 @@ typedef enum { Return the cast type (Unicast/Boradcast) specific to an interface. All the addresses are host byte ordered. - @param IpAddr The IP address to classify in host byte order - @param IpIf The interface that IpAddr received from + @param[in] IpAddr The IP address to classify in host byte order + @param[in] IpIf The interface that IpAddr received from @return The cast type of this IP address specific to the interface. @retval IP4_LOCAL_HOST The IpAddr equals to the interface's address @@ -112,11 +100,11 @@ Ip4GetNetCast ( This isn't the same as link layer cast type. For example, DHCP server may send local broadcast to the local unicast MAC. - @param IpSb The IP4 service binding instance that received the - packet - @param Dst The destination address in the packet (host byte - order) - @param Src The source address in the packet (host byte order) + @param[in] IpSb The IP4 service binding instance that received the + packet + @param[in] Dst The destination address in the packet (host byte + order) + @param[in] Src The source address in the packet (host byte order) @return The cast type for the Dst, it will return on the first non-promiscuous cast type to a configured interface. If the packet doesn't match any of @@ -133,8 +121,8 @@ Ip4GetHostCast ( /** Find an interface whose configured IP address is Ip. - @param IpSb The IP4 service binding instance - @param Ip The Ip address (host byte order) to find + @param[in] IpSb The IP4 service binding instance + @param[in] Ip The Ip address (host byte order) to find @return The IP4_INTERFACE point if found, otherwise NULL @@ -148,8 +136,8 @@ Ip4FindInterface ( /** Find an interface that Ip is on that connected network. - @param IpSb The IP4 service binding instance - @param Ip The Ip address (host byte order) to find + @param[in] IpSb The IP4 service binding instance + @param[in] Ip The Ip address (host byte order) to find @return The IP4_INTERFACE point if found, otherwise NULL @@ -163,9 +151,9 @@ Ip4FindNet ( /** Find an interface of the service with the same Ip/Netmask pair. - @param IpSb Ip4 service binding instance - @param Ip The Ip adress to find (host byte order) - @param Netmask The network to find (host byte order) + @param[in] IpSb Ip4 service binding instance + @param[in] Ip The Ip adress to find (host byte order) + @param[in] Netmask The network to find (host byte order) @return The IP4_INTERFACE point if found, otherwise NULL @@ -182,9 +170,9 @@ Ip4FindStationAddress ( Mnp's McastIpToMac to find the MAC address in stead of hard code the NIC to be Ethernet. - @param Mnp The Mnp instance to get the MAC address. - @param Multicast The multicast IP address to translate. - @param Mac The buffer to hold the translated address. + @param[in] Mnp The Mnp instance to get the MAC address. + @param[in] Multicast The multicast IP address to translate. + @param[out] Mac The buffer to hold the translated address. @retval EFI_SUCCESS if the multicast IP is successfully translated to a multicast MAC address. @@ -203,7 +191,7 @@ Ip4GetMulticastMac ( In spite of its name, it can also be used to convert from host to network byte order. - @param Head The IP head to convert + @param[in] Head The IP head to convert @return Point to the converted IP head @@ -213,35 +201,23 @@ Ip4NtohHead ( IN IP4_HEAD *Head ); -/** - Set the Ip4 variable data. - - Save the list of all of the IPv4 addresses and subnet masks that are currently - being used to volatile variable storage. - - @param IpSb Ip4 service binding instance - - @retval EFI_SUCCESS Successfully set variable. - @retval EFI_OUT_OF_RESOURCES There are not enough resources to set the variable. - @retval other Set variable failed. - -**/ -EFI_STATUS -Ip4SetVariableData ( - IN IP4_SERVICE *IpSb - ); /** - Clear the variable and free the resource. + Validate that Ip/Netmask pair is OK to be used as station + address. Only continuous netmasks are supported. and check + that StationAddress is a unicast address on the newtwork. - @param IpSb Ip4 service binding instance + @param[in] Ip The IP address to validate. + @param[in] Netmask The netmaks of the IP. - @return None. + @retval TRUE The Ip/Netmask pair is valid. + @retval FALSE The Ip/Netmask pair is invalid. **/ -VOID -Ip4ClearVariableData ( - IN IP4_SERVICE *IpSb +BOOLEAN +Ip4StationAddressValid ( + IN IP4_ADDR Ip, + IN IP4_ADDR Netmask ); #endif