From f6b7393ceb34c9b3a27434268bf2ce517047641f Mon Sep 17 00:00:00 2001 From: tye Date: Wed, 4 Nov 2009 08:18:34 +0000 Subject: [PATCH] [Change summary]: 1. Update NetLib to a combined NetLib support dual network stack: 1) Add Network Debug facility for IPv4 stack. 2) Extend the library APIs to support IPv6 stack: a. NetIp6IsUnspecifiedAddr b. NetIp6IsLinkLocalAddr c. NetIp6IsNetEqual d. NetLibCreateIPv6DPathNode. e. NetIp6PseudoHeadChecksum f. NetIp6IsValidUnicast 3) Update the structure definitions: a. Update NET_BUF to add EFI_IP6_HEADER and EFI_UDP_HEADER b. Add NET_IP6_PSEUDO_HDR 4) Update Ip4IsUnicast to NetIp4IsUnicast 2. Update the impacted modules to adopt the combined NetLib. 3. Clean up coding style errors in all network drivers and libraries. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9391 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Include/Guid/NicIp4ConfigNvData.h | 19 +- MdeModulePkg/Include/Library/NetLib.h | 256 +++++++- MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.c | 4 +- MdeModulePkg/Library/DxeNetLib/DxeNetLib.c | 600 +++++++++++++++++- MdeModulePkg/Library/DxeNetLib/NetBuffer.c | 38 ++ .../Universal/Network/ArpDxe/ArpImpl.c | 2 +- .../Universal/Network/ArpDxe/ArpImpl.h | 18 +- .../Universal/Network/Dhcp4Dxe/Dhcp4Impl.c | 2 +- .../Universal/Network/Dhcp4Dxe/Dhcp4Impl.h | 24 +- .../Universal/Network/Dhcp4Dxe/Dhcp4Io.h | 54 +- .../Universal/Network/Dhcp4Dxe/Dhcp4Option.h | 257 ++++---- .../Universal/Network/IScsiDxe/IScsiCHAP.h | 15 +- .../Universal/Network/IScsiDxe/IScsiConfig.c | 10 +- .../Universal/Network/IScsiDxe/IScsiDhcp.c | 4 +- .../Universal/Network/IScsiDxe/IScsiDhcp.h | 16 +- .../Universal/Network/IScsiDxe/IScsiIbft.c | 4 +- .../Universal/Network/IScsiDxe/IScsiMisc.c | 2 +- .../Universal/Network/IScsiDxe/IScsiProto.c | 24 +- .../Universal/Network/IScsiDxe/IScsiProto.h | 37 +- .../Network/Ip4ConfigDxe/Ip4Config.h | 31 +- .../Network/Ip4ConfigDxe/Ip4ConfigNv.c | 8 +- .../Network/Ip4ConfigDxe/NicIp4Variable.c | 6 +- .../Universal/Network/Ip4Dxe/Ip4Common.h | 60 +- .../Universal/Network/Ip4Dxe/Ip4Icmp.c | 6 +- .../Universal/Network/Ip4Dxe/Ip4Icmp.h | 72 +-- MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.h | 12 +- .../Universal/Network/Ip4Dxe/Ip4Igmp.h | 26 +- .../Universal/Network/Ip4Dxe/Ip4Impl.c | 2 +- .../Universal/Network/Ip4Dxe/Ip4Impl.h | 51 +- .../Universal/Network/Ip4Dxe/Ip4Input.c | 22 +- .../Universal/Network/Ip4Dxe/Ip4Input.h | 14 +- .../Universal/Network/Ip4Dxe/Ip4Option.h | 16 +- .../Universal/Network/Ip4Dxe/Ip4Output.c | 4 +- .../Universal/Network/Ip4Dxe/Ip4Route.c | 8 +- .../Universal/Network/Ip4Dxe/Ip4Route.h | 14 +- .../Universal/Network/Mtftp4Dxe/Mtftp4Impl.c | 10 +- .../Universal/Network/Mtftp4Dxe/Mtftp4Impl.h | 26 +- .../Network/Mtftp4Dxe/Mtftp4Option.h | 24 +- MdeModulePkg/Universal/Network/SnpDxe/Snp.h | 8 +- .../Universal/Network/Tcp4Dxe/SockImpl.c | 16 +- .../Universal/Network/Tcp4Dxe/SockInterface.c | 12 +- .../Universal/Network/Tcp4Dxe/Socket.h | 82 ++- .../Network/Tcp4Dxe/Tcp4Dispatcher.c | 2 +- .../Universal/Network/Tcp4Dxe/Tcp4Driver.c | 4 +- .../Universal/Network/Tcp4Dxe/Tcp4Driver.h | 2 +- .../Universal/Network/Tcp4Dxe/Tcp4Main.c | 6 +- .../Universal/Network/Tcp4Dxe/Tcp4Main.h | 4 +- .../Universal/Network/Tcp4Dxe/Tcp4Option.h | 81 ++- .../Universal/Network/Tcp4Dxe/Tcp4Proto.h | 208 +++--- .../Universal/Network/Udp4Dxe/Udp4Impl.c | 4 +- .../Universal/Network/Udp4Dxe/Udp4Main.c | 4 +- .../Network/UefiPxeBcDxe/PxeBcDhcp.h | 211 +++--- .../Network/UefiPxeBcDxe/PxeBcImpl.c | 18 +- .../Network/UefiPxeBcDxe/PxeBcMtftp.h | 14 +- 54 files changed, 1634 insertions(+), 840 deletions(-) diff --git a/MdeModulePkg/Include/Guid/NicIp4ConfigNvData.h b/MdeModulePkg/Include/Guid/NicIp4ConfigNvData.h index 5e27477d42..68acd906a0 100644 --- a/MdeModulePkg/Include/Guid/NicIp4ConfigNvData.h +++ b/MdeModulePkg/Include/Guid/NicIp4ConfigNvData.h @@ -24,17 +24,16 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #define EFI_NIC_IP4_CONFIG_VARIABLE L"EfiNicIp4ConfigVariable" -typedef enum { - // - // Config source: dhcp or static - // - IP4_CONFIG_SOURCE_DHCP = 0, - IP4_CONFIG_SOURCE_STATIC, - IP4_CONFIG_SOURCE_MAX, - IP4_NIC_NAME_LENGTH = 64, - MAX_IP4_CONFIG_IN_VARIABLE = 16 -} IP4_CONFIG_TYPE; +// +// Config source: dhcp or static +// +#define IP4_CONFIG_SOURCE_DHCP 0 +#define IP4_CONFIG_SOURCE_STATIC 1 +#define IP4_CONFIG_SOURCE_MAX 2 + +#define IP4_NIC_NAME_LENGTH 64 +#define MAX_IP4_CONFIG_IN_VARIABLE 16 // // The following structures are used by drivers/applications other diff --git a/MdeModulePkg/Include/Library/NetLib.h b/MdeModulePkg/Include/Library/NetLib.h index 1a0507b9e6..07bf2cbc9f 100644 --- a/MdeModulePkg/Include/Library/NetLib.h +++ b/MdeModulePkg/Include/Library/NetLib.h @@ -29,6 +29,8 @@ typedef UINT16 TCP_PORTNO; #define EFI_IP_PROTO_UDP 0x11 #define EFI_IP_PROTO_TCP 0x06 #define EFI_IP_PROTO_ICMP 0x01 +#define IP4_PROTO_IGMP 0x02 +#define IP6_ICMP 58 // // The address classification @@ -40,7 +42,7 @@ typedef UINT16 TCP_PORTNO; #define IP4_ADDR_CLASSE 5 #define IP4_MASK_NUM 33 - +#define IP6_PREFIX_NUM 129 #define IP6_HOP_BY_HOP 0 #define IP6_DESTINATION 60 @@ -166,7 +168,11 @@ typedef struct { #define NTOHS(x) (UINT16)((((UINT16) (x) & 0xff) << 8) | \ (((UINT16) (x) & 0xff00) >> 8)) -#define HTONS(x) NTOHS(x) +#define HTONS(x) NTOHS(x) +#define NTOHLL(x) SwapBytes64 (x) +#define HTONLL(x) NTOHLL(x) +#define NTOHLLL(x) Ip6Swap128 (x) +#define HTONLLL(x) NTOHLLL(x) // // Test the IP's attribute, All the IPs are in host byte order. @@ -187,6 +193,113 @@ typedef struct { #define EFI_IP6_EQUAL(Ip1, Ip2) (CompareMem ((Ip1), (Ip2), sizeof (EFI_IPv6_ADDRESS)) == 0) +#define IP6_COPY_ADDRESS(Dest, Src) (CopyMem ((Dest), (Src), sizeof (EFI_IPv6_ADDRESS))) +#define IP6_COPY_LINK_ADDRESS(Mac1, Mac2) (CopyMem ((Mac1), (Mac2), sizeof (EFI_MAC_ADDRESS))) + +// +// The debug level definition. This value is also used as the +// syslog's servity level. Don't change it. +// +#define NETDEBUG_LEVEL_TRACE 5 +#define NETDEBUG_LEVEL_WARNING 4 +#define NETDEBUG_LEVEL_ERROR 3 + +// +// Network debug message is sent out as syslog packet. +// +#define NET_SYSLOG_FACILITY 16 // Syslog local facility local use +#define NET_SYSLOG_PACKET_LEN 512 +#define NET_SYSLOG_TX_TIMEOUT 500 *1000 *10 // 500ms +#define NET_DEBUG_MSG_LEN 470 // 512 - (ether+ip4+udp4 head length) + +// +// The debug output expects the ASCII format string, Use %a to print ASCII +// string, and %s to print UNICODE string. PrintArg must be enclosed in (). +// For example: NET_DEBUG_TRACE ("Tcp", ("State transit to %a\n", Name)); +// +#define NET_DEBUG_TRACE(Module, PrintArg) \ + NetDebugOutput ( \ + NETDEBUG_LEVEL_TRACE, \ + Module, \ + __FILE__, \ + __LINE__, \ + NetDebugASPrint PrintArg \ + ) + +#define NET_DEBUG_WARNING(Module, PrintArg) \ + NetDebugOutput ( \ + NETDEBUG_LEVEL_WARNING, \ + Module, \ + __FILE__, \ + __LINE__, \ + NetDebugASPrint PrintArg \ + ) + +#define NET_DEBUG_ERROR(Module, PrintArg) \ + NetDebugOutput ( \ + NETDEBUG_LEVEL_ERROR, \ + Module, \ + __FILE__, \ + __LINE__, \ + NetDebugASPrint PrintArg \ + ) + +/** + Allocate a buffer, then format the message to it. This is a + help function for the NET_DEBUG_XXX macros. The PrintArg of + these macros treats the variable length print parameters as a + single parameter, and pass it to the NetDebugASPrint. For + example, NET_DEBUG_TRACE ("Tcp", ("State transit to %a\n", Name)) + if extracted to: + + NetDebugOutput ( + NETDEBUG_LEVEL_TRACE, + "Tcp", + __FILE__, + __LINE__, + NetDebugASPrint ("State transit to %a\n", Name) + ) + + @param Format The ASCII format string. + @param ... The variable length parameter whose format is determined + by the Format string. + + @return The buffer containing the formatted message, + or NULL if failed to allocate memory. + +**/ +CHAR8 * +NetDebugASPrint ( + IN CHAR8 *Format, + ... + ); + +/** + Builds an UDP4 syslog packet and send it using SNP. + + This function will locate a instance of SNP then send the message through it. + Because it isn't open the SNP BY_DRIVER, apply caution when using it. + + @param Level The servity level of the message. + @param Module The Moudle that generates the log. + @param File The file that contains the log. + @param Line The exact line that contains the log. + @param Message The user message to log. + + @retval EFI_INVALID_PARAMETER Any input parameter is invalid. + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory for the packet + @retval EFI_SUCCESS The log is discard because that it is more verbose + than the mNetDebugLevelMax. Or, it has been sent out. +**/ +EFI_STATUS +NetDebugOutput ( + IN UINT32 Level, + IN UINT8 *Module, + IN UINT8 *File, + IN UINT32 Line, + IN UINT8 *Message + ); + /** Return the length of the mask. @@ -250,7 +363,7 @@ NetGetIpClass ( **/ BOOLEAN EFIAPI -Ip4IsUnicast ( +NetIp4IsUnicast ( IN IP4_ADDR Ip, IN IP4_ADDR NetMask ); @@ -270,10 +383,57 @@ Ip4IsUnicast ( **/ BOOLEAN -Ip6IsValidUnicast ( +NetIp6IsValidUnicast ( + IN EFI_IPv6_ADDRESS *Ip6 + ); + + +/** + Check whether the incoming Ipv6 address is the unspecified address or not. + + @param[in] Ip6 - Ip6 address, in network order. + + @retval TRUE - Yes, unspecified + @retval FALSE - No + +**/ +BOOLEAN +NetIp6IsUnspecifiedAddr ( IN EFI_IPv6_ADDRESS *Ip6 ); +/** + Check whether the incoming Ipv6 address is a link-local address. + + @param[in] Ip6 - Ip6 address, in network order. + + @retval TRUE - Yes, link-local address + @retval FALSE - No + +**/ +BOOLEAN +NetIp6IsLinkLocalAddr ( + IN EFI_IPv6_ADDRESS *Ip6 + ); + +/** + Check whether the Ipv6 address1 and address2 are on the connected network. + + @param[in] Ip1 - Ip6 address1, in network order. + @param[in] Ip2 - Ip6 address2, in network order. + @param[in] PrefixLength - The prefix length of the checking net. + + @retval TRUE - Yes, connected. + @retval FALSE - No. + +**/ +BOOLEAN +NetIp6IsNetEqual ( + EFI_IPv6_ADDRESS *Ip1, + EFI_IPv6_ADDRESS *Ip2, + UINT8 PrefixLength + ); + /** Switches the endianess of an IPv6 address @@ -741,7 +901,7 @@ EFIAPI NetMapIterate ( IN NET_MAP *Map, IN NET_MAP_CALLBACK CallBack, - IN VOID *Arg + IN VOID *Arg OPTIONAL ); @@ -838,7 +998,7 @@ NetLibGetMacString ( Get other info from parameters to make up the whole IPv4 device path node. @param[in, out] Node Pointer to the IPv4 device path node. - @param[in] Controller The handle where the NIC IP4 config protocol resides. + @param[in] Controller The controller handle. @param[in] LocalIp The local IPv4 address. @param[in] LocalPort The local port. @param[in] RemoteIp The remote IPv4 address. @@ -860,6 +1020,36 @@ NetLibCreateIPv4DPathNode ( IN BOOLEAN UseDefaultAddress ); +/** + Create an IPv6 device path node. + + The header type of IPv6 device path node is MESSAGING_DEVICE_PATH. + The header subtype of IPv6 device path node is MSG_IPv6_DP. + The length of the IPv6 device path node in bytes is 43. + Get other info from parameters to make up the whole IPv6 device path node. + + @param[in, out] Node Pointer to the IPv6 device path node. + @param[in] Controller The controller handle. + @param[in] LocalIp The local IPv6 address. + @param[in] LocalPort The local port. + @param[in] RemoteIp The remote IPv6 address. + @param[in] RemotePort The remote port. + @param[in] Protocol The protocol type in the IP header. + +**/ +VOID +EFIAPI +NetLibCreateIPv6DPathNode ( + IN OUT IPv6_DEVICE_PATH *Node, + IN EFI_HANDLE Controller, + IN EFI_IPv6_ADDRESS *LocalIp, + IN UINT16 LocalPort, + IN EFI_IPv6_ADDRESS *RemoteIp, + IN UINT16 RemotePort, + IN UINT16 Protocol + ); + + /** Find the UNDI/SNP handle from controller and protocol GUID. @@ -961,6 +1151,10 @@ typedef struct { UINT32 Size; // The size of the data } NET_BLOCK_OP; +typedef union { + IP4_HEAD *Ip4; + EFI_IP6_HEADER *Ip6; +} NET_IP_HEAD; // //NET_BUF is the buffer manage structure used by the @@ -973,22 +1167,22 @@ typedef struct { //to overwrite the members after that. // typedef struct { - UINT32 Signature; - INTN RefCnt; - LIST_ENTRY List; // The List this NET_BUF is on + UINT32 Signature; + INTN RefCnt; + LIST_ENTRY List; // The List this NET_BUF is on - IP4_HEAD *Ip; // Network layer header, for fast access - TCP_HEAD *Tcp; // Transport layer header, for fast access - UINT8 ProtoData [NET_PROTO_DATA]; //Protocol specific data + NET_IP_HEAD Ip; // Network layer header, for fast access + TCP_HEAD *Tcp; // Transport layer header, for fast access + EFI_UDP_HEADER *Udp; // User Datagram Protocol header + UINT8 ProtoData [NET_PROTO_DATA]; //Protocol specific data - NET_VECTOR *Vector; // The vector containing the packet + NET_VECTOR *Vector; // The vector containing the packet - UINT32 BlockOpNum; // Total number of BlockOp in the buffer - UINT32 TotalSize; // Total size of the actual packet - NET_BLOCK_OP BlockOp[1]; // Specify the position of actual packet + UINT32 BlockOpNum; // Total number of BlockOp in the buffer + UINT32 TotalSize; // Total size of the actual packet + NET_BLOCK_OP BlockOp[1]; // Specify the position of actual packet } NET_BUF; - // //A queue of NET_BUFs. It is a thin extension of //NET_BUF functions. @@ -1014,6 +1208,14 @@ typedef struct { UINT8 Protocol; UINT16 Len; } NET_PSEUDO_HDR; + +typedef struct { + EFI_IPv6_ADDRESS SrcIp; + EFI_IPv6_ADDRESS DstIp; + UINT32 Len; + UINT32 Reserved:24; + UINT32 NextHeader:8; +} NET_IP6_PSEUDO_HDR; #pragma pack() // @@ -1544,4 +1746,24 @@ NetPseudoHeadChecksum ( IN UINT16 Len ); +/** + Compute the checksum for TCP6/UDP6 pseudo header. + + Src and Dst are in network byte order, and Len is in host byte order. + + @param[in] Src The source address of the packet. + @param[in] Dst The destination address of the packet. + @param[in] NextHeader The protocol type of the packet. + @param[in] Len The length of the packet. + + @return The computed checksum. + +**/ +UINT16 +NetIp6PseudoHeadChecksum ( + IN EFI_IPv6_ADDRESS *Src, + IN EFI_IPv6_ADDRESS *Dst, + IN UINT8 NextHeader, + IN UINT32 Len + ); #endif diff --git a/MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.c b/MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.c index 032545b32b..c94a79c4dc 100644 --- a/MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.c +++ b/MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.c @@ -1029,7 +1029,7 @@ IpIoListenHandlerDpc ( if (IpIo->IpVersion == IP_VERSION_4) { if ((EFI_IP4 (RxData->Ip4RxData.Header->SourceAddress) != 0) && - !Ip4IsUnicast (EFI_NTOHL (((EFI_IP4_RECEIVE_DATA *) RxData)->Header->SourceAddress), 0)) { + !NetIp4IsUnicast (EFI_NTOHL (((EFI_IP4_RECEIVE_DATA *) RxData)->Header->SourceAddress), 0)) { // // The source address is not zero and it's not a unicast IP address, discard it. // @@ -1060,7 +1060,7 @@ IpIoListenHandlerDpc ( Session.IpVersion = IP_VERSION_4; } else { - if (!Ip6IsValidUnicast(&RxData->Ip6RxData.Header->SourceAddress)) { + if (!NetIp6IsValidUnicast(&RxData->Ip6RxData.Header->SourceAddress)) { goto CleanUp; } diff --git a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c index fb296e5f59..b42054f544 100644 --- a/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c +++ b/MdeModulePkg/Library/DxeNetLib/DxeNetLib.c @@ -81,6 +81,452 @@ IP4_ADDR gIp4AllMasks[IP4_MASK_NUM] = { EFI_IPv4_ADDRESS mZeroIp4Addr = {{0, 0, 0, 0}}; +// +// Any error level digitally larger than mNetDebugLevelMax +// will be silently discarded. +// +UINTN mNetDebugLevelMax = NETDEBUG_LEVEL_ERROR; +UINT32 mSyslogPacketSeq = 0xDEADBEEF; + +// +// You can change mSyslogDstMac mSyslogDstIp and mSyslogSrcIp +// here to direct the syslog packets to the syslog deamon. The +// default is broadcast to both the ethernet and IP. +// +UINT8 mSyslogDstMac[NET_ETHER_ADDR_LEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; +UINT32 mSyslogDstIp = 0xffffffff; +UINT32 mSyslogSrcIp = 0; + +CHAR8 * +mMonthName[] = { + "Jan", + "Feb", + "Mar", + "Apr", + "May", + "Jun", + "Jul", + "Aug", + "Sep", + "Oct", + "Nov", + "Dec" +}; + +/** + Locate the handles that support SNP, then open one of them + to send the syslog packets. The caller isn't required to close + the SNP after use because the SNP is opened by HandleProtocol. + + @return The point to SNP if one is properly openned. Otherwise NULL + +**/ +EFI_SIMPLE_NETWORK_PROTOCOL * +SyslogLocateSnp ( + VOID + ) +{ + EFI_SIMPLE_NETWORK_PROTOCOL *Snp; + EFI_STATUS Status; + EFI_HANDLE *Handles; + UINTN HandleCount; + UINTN Index; + + // + // Locate the handles which has SNP installed. + // + Handles = NULL; + Status = gBS->LocateHandleBuffer ( + ByProtocol, + &gEfiSimpleNetworkProtocolGuid, + NULL, + &HandleCount, + &Handles + ); + + if (EFI_ERROR (Status) || (HandleCount == 0)) { + return NULL; + } + + // + // Try to open one of the ethernet SNP protocol to send packet + // + Snp = NULL; + + for (Index = 0; Index < HandleCount; Index++) { + Status = gBS->HandleProtocol ( + Handles[Index], + &gEfiSimpleNetworkProtocolGuid, + (VOID **) &Snp + ); + + if ((Status == EFI_SUCCESS) && (Snp != NULL) && + (Snp->Mode->IfType == NET_IFTYPE_ETHERNET) && + (Snp->Mode->MaxPacketSize >= NET_SYSLOG_PACKET_LEN)) { + + break; + } + + Snp = NULL; + } + + FreePool (Handles); + return Snp; +} + +/** + Transmit a syslog packet synchronously through SNP. The Packet + already has the ethernet header prepended. This function should + fill in the source MAC because it will try to locate a SNP each + time it is called to avoid the problem if SNP is unloaded. + This code snip is copied from MNP. + + @param[in] Packet - The Syslog packet + @param[in] Length - The length of the packet + + @retval EFI_DEVICE_ERROR - Failed to locate a usable SNP protocol + @retval EFI_TIMEOUT - Timeout happened to send the packet. + @retval EFI_SUCCESS - Packet is sent. + +**/ +EFI_STATUS +SyslogSendPacket ( + IN CHAR8 *Packet, + IN UINT32 Length + ) +{ + EFI_SIMPLE_NETWORK_PROTOCOL *Snp; + ETHER_HEAD *Ether; + EFI_STATUS Status; + EFI_EVENT TimeoutEvent; + UINT8 *TxBuf; + + Snp = SyslogLocateSnp (); + + if (Snp == NULL) { + return EFI_DEVICE_ERROR; + } + + Ether = (ETHER_HEAD *) Packet; + CopyMem (Ether->SrcMac, Snp->Mode->CurrentAddress.Addr, NET_ETHER_ADDR_LEN); + + // + // Start the timeout event. + // + Status = gBS->CreateEvent ( + EVT_TIMER, + TPL_NOTIFY, + NULL, + NULL, + &TimeoutEvent + ); + + if (EFI_ERROR (Status)) { + return Status; + } + + Status = gBS->SetTimer (TimeoutEvent, TimerRelative, NET_SYSLOG_TX_TIMEOUT); + + if (EFI_ERROR (Status)) { + goto ON_EXIT; + } + + for (;;) { + // + // Transmit the packet through SNP. + // + Status = Snp->Transmit (Snp, 0, Length, Packet, NULL, NULL, NULL); + + if ((Status != EFI_SUCCESS) && (Status != EFI_NOT_READY)) { + Status = EFI_DEVICE_ERROR; + break; + } + + // + // If Status is EFI_SUCCESS, the packet is put in the transmit queue. + // if Status is EFI_NOT_READY, the transmit engine of the network + // interface is busy. Both need to sync SNP. + // + TxBuf = NULL; + + do { + // + // Get the recycled transmit buffer status. + // + Snp->GetStatus (Snp, NULL, (VOID **) &TxBuf); + + if (!EFI_ERROR (gBS->CheckEvent (TimeoutEvent))) { + Status = EFI_TIMEOUT; + break; + } + + } while (TxBuf == NULL); + + if ((Status == EFI_SUCCESS) || (Status == EFI_TIMEOUT)) { + break; + } + + // + // Status is EFI_NOT_READY. Restart the timer event and + // call Snp->Transmit again. + // + gBS->SetTimer (TimeoutEvent, TimerRelative, NET_SYSLOG_TX_TIMEOUT); + } + + gBS->SetTimer (TimeoutEvent, TimerCancel, 0); + +ON_EXIT: + gBS->CloseEvent (TimeoutEvent); + return Status; +} + +/** + Build a syslog packet, including the Ethernet/Ip/Udp headers + and user's message. + + @param[in] Level - Syslog servity level + @param[in] Module - The module that generates the log + @param[in] File - The file that contains the current log + @param[in] Line - The line of code in the File that contains the current log + @param[in] Message - The log message + @param[in] BufLen - The lenght of the Buf + @param[out] Buf - The buffer to put the packet data + +Returns: + + The length of the syslog packet built. + +**/ +UINT32 +SyslogBuildPacket ( + IN UINT32 Level, + IN UINT8 *Module, + IN UINT8 *File, + IN UINT32 Line, + IN UINT8 *Message, + IN UINT32 BufLen, + OUT CHAR8 *Buf + ) +{ + ETHER_HEAD *Ether; + IP4_HEAD *Ip4; + EFI_UDP_HEADER *Udp4; + EFI_TIME Time; + UINT32 Pri; + UINT32 Len; + + // + // Fill in the Ethernet header. Leave alone the source MAC. + // SyslogSendPacket will fill in the address for us. + // + Ether = (ETHER_HEAD *) Buf; + CopyMem (Ether->DstMac, mSyslogDstMac, NET_ETHER_ADDR_LEN); + ZeroMem (Ether->SrcMac, NET_ETHER_ADDR_LEN); + + Ether->EtherType = HTONS (0x0800); // IPv4 protocol + + Buf += sizeof (ETHER_HEAD); + BufLen -= sizeof (ETHER_HEAD); + + // + // Fill in the IP header + // + Ip4 = (IP4_HEAD *) Buf; + Ip4->HeadLen = 5; + Ip4->Ver = 4; + Ip4->Tos = 0; + Ip4->TotalLen = 0; + Ip4->Id = (UINT16) mSyslogPacketSeq; + Ip4->Fragment = 0; + Ip4->Ttl = 16; + Ip4->Protocol = 0x11; + Ip4->Checksum = 0; + Ip4->Src = mSyslogSrcIp; + Ip4->Dst = mSyslogDstIp; + + Buf += sizeof (IP4_HEAD); + BufLen -= sizeof (IP4_HEAD); + + // + // Fill in the UDP header, Udp checksum is optional. Leave it zero. + // + Udp4 = (EFI_UDP_HEADER *) Buf; + Udp4->SrcPort = HTONS (514); + Udp4->DstPort = HTONS (514); + Udp4->Length = 0; + Udp4->Checksum = 0; + + Buf += sizeof (EFI_UDP_HEADER); + BufLen -= sizeof (EFI_UDP_HEADER); + + // + // Build the syslog message body with Timestamp machine module Message + // + Pri = ((NET_SYSLOG_FACILITY & 31) << 3) | (Level & 7); + gRT->GetTime (&Time, NULL); + + // + // Use %a to format the ASCII strings, %s to format UNICODE strings + // + Len = 0; + Len += (UINT32) AsciiSPrint ( + Buf, + BufLen, + "<%d> %a %d %d:%d:%d ", + Pri, + mMonthName [Time.Month-1], + Time.Day, + Time.Hour, + Time.Minute, + Time.Second + ); + Len--; + + Len += (UINT32) AsciiSPrint ( + Buf + Len, + BufLen - Len, + "Tiano %a: %a (Line: %d File: %a)", + Module, + Message, + Line, + File + ); + Len--; + + // + // OK, patch the IP length/checksum and UDP length fields. + // + Len += sizeof (EFI_UDP_HEADER); + Udp4->Length = HTONS ((UINT16) Len); + + Len += sizeof (IP4_HEAD); + Ip4->TotalLen = HTONS ((UINT16) Len); + Ip4->Checksum = (UINT16) (~NetblockChecksum ((UINT8 *) Ip4, sizeof (IP4_HEAD))); + + return Len + sizeof (ETHER_HEAD); +} + +/** + Allocate a buffer, then format the message to it. This is a + help function for the NET_DEBUG_XXX macros. The PrintArg of + these macros treats the variable length print parameters as a + single parameter, and pass it to the NetDebugASPrint. For + example, NET_DEBUG_TRACE ("Tcp", ("State transit to %a\n", Name)) + if extracted to: + + NetDebugOutput ( + NETDEBUG_LEVEL_TRACE, + "Tcp", + __FILE__, + __LINE__, + NetDebugASPrint ("State transit to %a\n", Name) + ) + + @param Format The ASCII format string. + @param ... The variable length parameter whose format is determined + by the Format string. + + @return The buffer containing the formatted message, + or NULL if failed to allocate memory. + +**/ +CHAR8 * +NetDebugASPrint ( + IN CHAR8 *Format, + ... + ) +{ + VA_LIST Marker; + CHAR8 *Buf; + + Buf = (CHAR8 *) AllocatePool (NET_DEBUG_MSG_LEN); + + if (Buf == NULL) { + return NULL; + } + + VA_START (Marker, Format); + AsciiVSPrint (Buf, NET_DEBUG_MSG_LEN, Format, Marker); + VA_END (Marker); + + return Buf; +} + +/** + Builds an UDP4 syslog packet and send it using SNP. + + This function will locate a instance of SNP then send the message through it. + Because it isn't open the SNP BY_DRIVER, apply caution when using it. + + @param Level The servity level of the message. + @param Module The Moudle that generates the log. + @param File The file that contains the log. + @param Line The exact line that contains the log. + @param Message The user message to log. + + @retval EFI_INVALID_PARAMETER Any input parameter is invalid. + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory for the packet + @retval EFI_SUCCESS The log is discard because that it is more verbose + than the mNetDebugLevelMax. Or, it has been sent out. +**/ +EFI_STATUS +NetDebugOutput ( + IN UINT32 Level, + IN UINT8 *Module, + IN UINT8 *File, + IN UINT32 Line, + IN UINT8 *Message + ) +{ + CHAR8 *Packet; + UINT32 Len; + EFI_STATUS Status; + + // + // Check whether the message should be sent out + // + if (Message == NULL) { + return EFI_INVALID_PARAMETER; + } + + if (Level > mNetDebugLevelMax) { + Status = EFI_SUCCESS; + goto ON_EXIT; + } + + // + // Allocate a maxium of 1024 bytes, the caller should ensure + // that the message plus the ethernet/ip/udp header is shorter + // than this + // + Packet = (CHAR8 *) AllocatePool (NET_SYSLOG_PACKET_LEN); + + if (Packet == NULL) { + Status = EFI_OUT_OF_RESOURCES; + goto ON_EXIT; + } + + // + // Build the message: Ethernet header + IP header + Udp Header + user data + // + Len = SyslogBuildPacket ( + Level, + Module, + File, + Line, + Message, + NET_SYSLOG_PACKET_LEN, + Packet + ); + + mSyslogPacketSeq++; + Status = SyslogSendPacket (Packet, Len); + FreePool (Packet); + +ON_EXIT: + FreePool (Message); + return Status; +} /** Return the length of the mask. @@ -179,7 +625,7 @@ NetGetIpClass ( **/ BOOLEAN EFIAPI -Ip4IsUnicast ( +NetIp4IsUnicast ( IN IP4_ADDR Ip, IN IP4_ADDR NetMask ) @@ -218,7 +664,7 @@ Ip4IsUnicast ( **/ BOOLEAN -Ip6IsValidUnicast ( +NetIp6IsValidUnicast ( IN EFI_IPv6_ADDRESS *Ip6 ) { @@ -244,6 +690,113 @@ Ip6IsValidUnicast ( return TRUE; } +/** + Check whether the incoming Ipv6 address is the unspecified address or not. + + @param[in] Ip6 - Ip6 address, in network order. + + @retval TRUE - Yes, unspecified + @retval FALSE - No + +**/ +BOOLEAN +NetIp6IsUnspecifiedAddr ( + IN EFI_IPv6_ADDRESS *Ip6 + ) +{ + UINT8 Index; + + for (Index = 0; Index < 16; Index++) { + if (Ip6->Addr[Index] != 0) { + return FALSE; + } + } + + return TRUE; +} + +/** + Check whether the incoming Ipv6 address is a link-local address. + + @param[in] Ip6 - Ip6 address, in network order. + + @retval TRUE - Yes, link-local address + @retval FALSE - No + +**/ +BOOLEAN +NetIp6IsLinkLocalAddr ( + IN EFI_IPv6_ADDRESS *Ip6 + ) +{ + UINT8 Index; + + ASSERT (Ip6 != NULL); + + if (Ip6->Addr[0] != 0xFE) { + return FALSE; + } + + if (Ip6->Addr[1] != 0x80) { + return FALSE; + } + + for (Index = 2; Index < 8; Index++) { + if (Ip6->Addr[Index] != 0) { + return FALSE; + } + } + + return TRUE; +} + +/** + Check whether the Ipv6 address1 and address2 are on the connected network. + + @param[in] Ip1 - Ip6 address1, in network order. + @param[in] Ip2 - Ip6 address2, in network order. + @param[in] PrefixLength - The prefix length of the checking net. + + @retval TRUE - Yes, connected. + @retval FALSE - No. + +**/ +BOOLEAN +NetIp6IsNetEqual ( + EFI_IPv6_ADDRESS *Ip1, + EFI_IPv6_ADDRESS *Ip2, + UINT8 PrefixLength + ) +{ + UINT8 Byte; + UINT8 Bit; + UINT8 Mask; + + ASSERT (Ip1 != NULL && Ip2 != NULL); + + if (PrefixLength == 0) { + return TRUE; + } + + Byte = (UINT8) (PrefixLength / 8); + Bit = (UINT8) (PrefixLength % 8); + + if (CompareMem (Ip1, Ip2, Byte) != 0) { + return FALSE; + } + + if (Bit > 0) { + Mask = (UINT8) (0xFF << (8 - Bit)); + + if ((Ip1->Addr[Byte] & Mask) != (Ip2->Addr[Byte] & Mask)) { + return FALSE; + } + } + + return TRUE; +} + + /** Switches the endianess of an IPv6 address @@ -1432,7 +1985,7 @@ ON_EXIT: Get other info from parameters to make up the whole IPv4 device path node. @param[in, out] Node Pointer to the IPv4 device path node. - @param[in] Controller The handle where the NIC IP4 config protocol resides. + @param[in] Controller The controller handle. @param[in] LocalIp The local IPv4 address. @param[in] LocalPort The local port. @param[in] RemoteIp The remote IPv4 address. @@ -1473,6 +2026,47 @@ NetLibCreateIPv4DPathNode ( } } +/** + Create an IPv6 device path node. + + The header type of IPv6 device path node is MESSAGING_DEVICE_PATH. + The header subtype of IPv6 device path node is MSG_IPv6_DP. + Get other info from parameters to make up the whole IPv6 device path node. + + @param[in, out] Node Pointer to the IPv6 device path node. + @param[in] Controller The controller handle. + @param[in] LocalIp The local IPv6 address. + @param[in] LocalPort The local port. + @param[in] RemoteIp The remote IPv6 address. + @param[in] RemotePort The remote port. + @param[in] Protocol The protocol type in the IP header. + +**/ +VOID +EFIAPI +NetLibCreateIPv6DPathNode ( + IN OUT IPv6_DEVICE_PATH *Node, + IN EFI_HANDLE Controller, + IN EFI_IPv6_ADDRESS *LocalIp, + IN UINT16 LocalPort, + IN EFI_IPv6_ADDRESS *RemoteIp, + IN UINT16 RemotePort, + IN UINT16 Protocol + ) +{ + Node->Header.Type = MESSAGING_DEVICE_PATH; + Node->Header.SubType = MSG_IPv6_DP; + SetDevicePathNodeLength (&Node->Header, sizeof (IPv6_DEVICE_PATH)); + + CopyMem (&Node->LocalIpAddress, LocalIp, sizeof (EFI_IPv6_ADDRESS)); + CopyMem (&Node->RemoteIpAddress, RemoteIp, sizeof (EFI_IPv6_ADDRESS)); + + Node->LocalPort = LocalPort; + Node->RemotePort = RemotePort; + + Node->Protocol = Protocol; + Node->StaticIpAddress = FALSE; +} /** Find the UNDI/SNP handle from controller and protocol GUID. diff --git a/MdeModulePkg/Library/DxeNetLib/NetBuffer.c b/MdeModulePkg/Library/DxeNetLib/NetBuffer.c index 907bdfd3ea..42e308a5a3 100644 --- a/MdeModulePkg/Library/DxeNetLib/NetBuffer.c +++ b/MdeModulePkg/Library/DxeNetLib/NetBuffer.c @@ -1803,3 +1803,41 @@ NetPseudoHeadChecksum ( return NetblockChecksum ((UINT8 *) &Hdr, sizeof (Hdr)); } + +/** + Compute the checksum for TCP6/UDP6 pseudo header. + + Src and Dst are in network byte order, and Len is in host byte order. + + @param[in] Src The source address of the packet. + @param[in] Dst The destination address of the packet. + @param[in] NextHeader The protocol type of the packet. + @param[in] Len The length of the packet. + + @return The computed checksum. + +**/ +UINT16 +NetIp6PseudoHeadChecksum ( + IN EFI_IPv6_ADDRESS *Src, + IN EFI_IPv6_ADDRESS *Dst, + IN UINT8 NextHeader, + IN UINT32 Len + ) +{ + NET_IP6_PSEUDO_HDR Hdr; + + // + // Zero the memory to relieve align problems + // + ZeroMem (&Hdr, sizeof (Hdr)); + + IP6_COPY_ADDRESS (&Hdr.SrcIp, Src); + IP6_COPY_ADDRESS (&Hdr.DstIp, Dst); + + Hdr.NextHeader = NextHeader; + Hdr.Len = HTONL (Len); + + return NetblockChecksum ((UINT8 *) &Hdr, sizeof (Hdr)); +} + diff --git a/MdeModulePkg/Universal/Network/ArpDxe/ArpImpl.c b/MdeModulePkg/Universal/Network/ArpDxe/ArpImpl.c index 9704f2139c..05884cab82 100644 --- a/MdeModulePkg/Universal/Network/ArpDxe/ArpImpl.c +++ b/MdeModulePkg/Universal/Network/ArpDxe/ArpImpl.c @@ -928,7 +928,7 @@ ArpConfigureInstance ( if (ConfigData->SwAddressType == IPV4_ETHER_PROTO_TYPE) { CopyMem (&Ip, ConfigData->StationAddress, sizeof (IP4_ADDR)); - if (!Ip4IsUnicast (NTOHL (Ip), 0)) { + if (!NetIp4IsUnicast (NTOHL (Ip), 0)) { // // The station address is not a valid IPv4 unicast address. // diff --git a/MdeModulePkg/Universal/Network/ArpDxe/ArpImpl.h b/MdeModulePkg/Universal/Network/ArpDxe/ArpImpl.h index bc9128d33b..6fc950771f 100644 --- a/MdeModulePkg/Universal/Network/ArpDxe/ArpImpl.h +++ b/MdeModulePkg/Universal/Network/ArpDxe/ArpImpl.h @@ -1,7 +1,7 @@ /** @file EFI Address Resolution Protocol (ARP) Protocol interface header file. -Copyright (c) 2006 - 2008, Intel Corporation.
+Copyright (c) 2006 - 2009, 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
@@ -186,17 +186,19 @@ typedef struct { #define ARP_MAX_PROTOCOL_ADDRESS_LEN sizeof(EFI_IP_ADDRESS) #define ARP_MAX_HARDWARE_ADDRESS_LEN sizeof(EFI_MAC_ADDRESS) +typedef union { + UINT8 ProtoAddress[ARP_MAX_PROTOCOL_ADDRESS_LEN]; + UINT8 HwAddress[ARP_MAX_HARDWARE_ADDRESS_LEN]; +} NET_ARP_ADDRESS_UNION; + // // ARP address structure in an ARP packet. // typedef struct { - UINT16 Type; - UINT8 Length; - UINT8 *AddressPtr; - union { - UINT8 ProtoAddress[ARP_MAX_PROTOCOL_ADDRESS_LEN]; - UINT8 HwAddress[ARP_MAX_HARDWARE_ADDRESS_LEN]; - } Buffer; + UINT16 Type; + UINT8 Length; + UINT8 *AddressPtr; + NET_ARP_ADDRESS_UNION Buffer; } NET_ARP_ADDRESS; // diff --git a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c index acacec7bb1..fb0332722e 100644 --- a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c +++ b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c @@ -661,7 +661,7 @@ EfiDhcp4Configure ( CopyMem (&Ip, &Dhcp4CfgData->ClientAddress, sizeof (IP4_ADDR)); - if ((Ip != 0) && !Ip4IsUnicast (NTOHL (Ip), 0)) { + if ((Ip != 0) && !NetIp4IsUnicast (NTOHL (Ip), 0)) { return EFI_INVALID_PARAMETER; } diff --git a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.h b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.h index 7d15b846c0..ed066ea833 100644 --- a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.h +++ b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.h @@ -43,18 +43,18 @@ typedef struct _DHCP_PROTOCOL DHCP_PROTOCOL; #define DHCP_SERVICE_SIGNATURE SIGNATURE_32 ('D', 'H', 'C', 'P') #define DHCP_PROTOCOL_SIGNATURE SIGNATURE_32 ('d', 'h', 'c', 'p') -typedef enum { - // - // The state of the DHCP service. It starts as UNCONFIGED. If - // and active child configures the service successfully, it - // goes to CONFIGED. If the active child configures NULL, it - // goes back to UNCONFIGED. It becomes DESTORY if it is (partly) - // destoried. - // - DHCP_UNCONFIGED = 0, - DHCP_CONFIGED, - DHCP_DESTORY -} DHCP_STATE; + +// +// The state of the DHCP service. It starts as UNCONFIGED. If +// and active child configures the service successfully, it +// goes to CONFIGED. If the active child configures NULL, it +// goes back to UNCONFIGED. It becomes DESTORY if it is (partly) +// destoried. +// +#define DHCP_UNCONFIGED 0 +#define DHCP_CONFIGED 1 +#define DHCP_DESTORY 2 + struct _DHCP_PROTOCOL { UINT32 Signature; diff --git a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.h b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.h index bc7ef689e1..ce1a80ba74 100644 --- a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.h +++ b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.h @@ -31,36 +31,30 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #define DHCP_SERVER_PORT 67 #define DHCP_CLIENT_PORT 68 -typedef enum { - // - // BOOTP header "op" field - // - BOOTP_REQUEST = 1, - BOOTP_REPLY = 2 -} DHCP_OP_TYPE; - -typedef enum { - // - // DHCP message types - // - DHCP_MSG_DISCOVER = 1, - DHCP_MSG_OFFER = 2, - DHCP_MSG_REQUEST = 3, - DHCP_MSG_DECLINE = 4, - DHCP_MSG_ACK = 5, - DHCP_MSG_NAK = 6, - DHCP_MSG_RELEASE = 7, - DHCP_MSG_INFORM = 8 -} DHCP_MSG_TYPE; - -typedef enum { - // - // DHCP notify user type - // - DHCP_NOTIFY_COMPLETION = 1, - DHCP_NOTIFY_RENEWREBIND, - DHCP_NOTIFY_ALL -} DHCP_NOTIFY_TYPE; +// +// BOOTP header "op" field +// +#define BOOTP_REQUEST 1 +#define BOOTP_REPLY 2 + +// +// DHCP message types +// +#define DHCP_MSG_DISCOVER 1 +#define DHCP_MSG_OFFER 2 +#define DHCP_MSG_REQUEST 3 +#define DHCP_MSG_DECLINE 4 +#define DHCP_MSG_ACK 5 +#define DHCP_MSG_NAK 6 +#define DHCP_MSG_RELEASE 7 +#define DHCP_MSG_INFORM 8 + +// +// DHCP notify user type +// +#define DHCP_NOTIFY_COMPLETION 1 +#define DHCP_NOTIFY_RENEWREBIND 2 +#define DHCP_NOTIFY_ALL 3 #define DHCP_IS_BOOTP(Parameter) (((Parameter) == NULL) || ((Parameter)->DhcpType == 0)) diff --git a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Option.h b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Option.h index 3685b379ef..e01f53e977 100644 --- a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Option.h +++ b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Option.h @@ -1,7 +1,7 @@ /** @file To validate, parse and process the DHCP options. -Copyright (c) 2006, Intel Corporation.
+Copyright (c) 2006 - 2009, 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 @@ -18,136 +18,133 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. /// /// DHCP option tags (types) /// -typedef enum { - // - // RFC1497 vendor extensions - // - DHCP_TAG_PAD = 0, // Pad Option - DHCP_TAG_EOP = 255, // End Option - DHCP_TAG_NETMASK = 1, // Subnet Mask - DHCP_TAG_TIME_OFFSET = 2, // Time Offset from UTC - DHCP_TAG_ROUTER = 3, // Router option, - DHCP_TAG_TIME_SERVER = 4, // Time Server - DHCP_TAG_NAME_SERVER = 5, // Name Server - DHCP_TAG_DNS_SERVER = 6, // Domain Name Server - DHCP_TAG_LOG_SERVER = 7, // Log Server - DHCP_TAG_COOKIE_SERVER = 8, // Cookie Server - DHCP_TAG_LPR_SERVER = 9, // LPR Print Server - DHCP_TAG_IMPRESS_SERVER = 10, // Impress Server - DHCP_TAG_RL_SERVER = 11, // Resource Location Server - DHCP_TAG_HOSTNAME = 12, // Host Name - DHCP_TAG_BOOTFILE_LEN = 13, // Boot File Size - DHCP_TAG_DUMP = 14, // Merit Dump File - DHCP_TAG_DOMAINNAME = 15, // Domain Name - DHCP_TAG_SWAP_SERVER = 16, // Swap Server - DHCP_TAG_ROOTPATH = 17, // Root path - DHCP_TAG_EXTEND_PATH = 18, // Extensions Path - - // - // IP Layer Parameters per Host - // - DHCP_TAG_IPFORWARD = 19, // IP Forwarding Enable/Disable - DHCP_TAG_NONLOCAL_SRR = 20, // on-Local Source Routing Enable/Disable - DHCP_TAG_POLICY_SRR = 21, // Policy Filter - DHCP_TAG_EMTU = 22, // Maximum Datagram Reassembly Size - DHCP_TAG_TTL = 23, // Default IP Time-to-live - DHCP_TAG_PATHMTU_AGE = 24, // Path MTU Aging Timeout - DHCP_TAG_PATHMTU_PLATEAU = 25, // Path MTU Plateau Table - - // - // IP Layer Parameters per Interface - // - DHCP_TAG_IFMTU = 26, // Interface MTU - DHCP_TAG_SUBNET_LOCAL = 27, // All Subnets are Local - DHCP_TAG_BROADCAST = 28, // Broadcast Address - DHCP_TAG_DISCOVER_MASK = 29, // Perform Mask Discovery - DHCP_TAG_SUPPLY_MASK = 30, // Mask Supplier - DHCP_TAG_DISCOVER_ROUTE = 31, // Perform Router Discovery - DHCP_TAG_ROUTER_SOLICIT = 32, // Router Solicitation Address - DHCP_TAG_STATIC_ROUTE = 33, // Static Route - - // - // Link Layer Parameters per Interface - // - DHCP_TAG_TRAILER = 34, // Trailer Encapsulation - DHCP_TAG_ARPAGE = 35, // ARP Cache Timeout - DHCP_TAG_ETHER_ENCAP = 36, // Ethernet Encapsulation - // - // TCP Parameters - // - DHCP_TAG_TCP_TTL = 37, // TCP Default TTL - DHCP_TAG_KEEP_INTERVAL = 38, // TCP Keepalive Interval - DHCP_TAG_KEEP_GARBAGE = 39, // TCP Keepalive Garbage - - // - // Application and Service Parameters - // - DHCP_TAG_NIS_DOMAIN = 40, // Network Information Service Domain - DHCP_TAG_NIS_SERVER = 41, // Network Information Servers - DHCP_TAG_NTP_SERVER = 42, // Network Time Protocol Servers - DHCP_TAG_VENDOR = 43, // Vendor Specific Information - DHCP_TAG_NBNS = 44, // NetBIOS over TCP/IP Name Server - DHCP_TAG_NBDD = 45, // NetBIOS Datagram Distribution Server - DHCP_TAG_NBTYPE = 46, // NetBIOS over TCP/IP Node Type - DHCP_TAG_NBSCOPE = 47, // NetBIOS over TCP/IP Scope - DHCP_TAG_XFONT = 48, // X Window System Font Server - DHCP_TAG_XDM = 49, // X Window System Display Manager - DHCP_TAG_NISPLUS = 64, // Network Information Service+ Domain - DHCP_TAG_NISPLUS_SERVER = 65, // Network Information Service+ Servers - DHCP_TAG_MOBILEIP = 68, // Mobile IP Home Agent - DHCP_TAG_SMTP = 69, // Simple Mail Transport Protocol Server - DHCP_TAG_POP3 = 70, // Post Office Protocol (POP3) Server - DHCP_TAG_NNTP = 71, // Network News Transport Protocol Server - DHCP_TAG_WWW = 72, // Default World Wide Web (WWW) Server - DHCP_TAG_FINGER = 73, // Default Finger Server - DHCP_TAG_IRC = 74, // Default Internet Relay Chat (IRC) Server - DHCP_TAG_STTALK = 75, // StreetTalk Server - DHCP_TAG_STDA = 76, // StreetTalk Directory Assistance Server - DHCP_TAG_CLASSLESS_ROUTE = 121, // Classless Route - - // - // DHCP Extensions - // - DHCP_TAG_REQUEST_IP = 50, // Requested IP Address - DHCP_TAG_LEASE = 51, // IP Address Lease Time - DHCP_TAG_OVERLOAD = 52, // Option Overload - DHCP_TAG_TFTP = 66, // TFTP server name - DHCP_TAG_BOOTFILE = 67, // Bootfile name - DHCP_TAG_TYPE = 53, // DHCP Message Type - DHCP_TAG_SERVER_ID = 54, // Server Identifier - DHCP_TAG_PARA_LIST = 55, // Parameter Request List - DHCP_TAG_MESSAGE = 56, // Message - DHCP_TAG_MAXMSG = 57, // Maximum DHCP Message Size - DHCP_TAG_T1 = 58, // Renewal (T1) Time Value - DHCP_TAG_T2 = 59, // Rebinding (T2) Time Value - DHCP_TAG_VENDOR_CLASS = 60, // Vendor class identifier - DHCP_TAG_CLIENT_ID = 61 // Client-identifier -} DHCP_TAGS; - -#define DHCP_OPTION_MAGIC 0x63538263 // Network byte order -#define DHCP_MAX_OPTIONS 256 - -typedef enum { - // - // DHCP option types, this is used to validate the DHCP options. - // - DHCP_OPTION_SWITCH = 1, - DHCP_OPTION_INT8, - DHCP_OPTION_INT16, - DHCP_OPTION_INT32, - DHCP_OPTION_IP, - DHCP_OPTION_IPPAIR -} DHCP_OPTION_TYPE; - -typedef enum { - // - // Value of DHCP overload option - // - DHCP_OVERLOAD_FILENAME = 1, - DHCP_OVERLOAD_SVRNAME = 2, - DHCP_OVERLOAD_BOTH = 3 -} DHCP_OVERLOAD_TYPE; +// +// RFC1497 vendor extensions +// +#define DHCP_TAG_PAD 0 // Pad Option +#define DHCP_TAG_EOP 255 // End Option +#define DHCP_TAG_NETMASK 1 // Subnet Mask +#define DHCP_TAG_TIME_OFFSET 2 // Time Offset from UTC +#define DHCP_TAG_ROUTER 3 // Router option, +#define DHCP_TAG_TIME_SERVER 4 // Time Server +#define DHCP_TAG_NAME_SERVER 5 // Name Server +#define DHCP_TAG_DNS_SERVER 6 // Domain Name Server +#define DHCP_TAG_LOG_SERVER 7 // Log Server +#define DHCP_TAG_COOKIE_SERVER 8 // Cookie Server +#define DHCP_TAG_LPR_SERVER 9 // LPR Print Server +#define DHCP_TAG_IMPRESS_SERVER 10 // Impress Server +#define DHCP_TAG_RL_SERVER 11 // Resource Location Server +#define DHCP_TAG_HOSTNAME 12 // Host Name +#define DHCP_TAG_BOOTFILE_LEN 13 // Boot File Size +#define DHCP_TAG_DUMP 14 // Merit Dump File +#define DHCP_TAG_DOMAINNAME 15 // Domain Name +#define DHCP_TAG_SWAP_SERVER 16 // Swap Server +#define DHCP_TAG_ROOTPATH 17 // Root path +#define DHCP_TAG_EXTEND_PATH 18 // Extensions Path + +// +// IP Layer Parameters per Host +// +#define DHCP_TAG_IPFORWARD 19 // IP Forwarding Enable/Disable +#define DHCP_TAG_NONLOCAL_SRR 20 // on-Local Source Routing Enable/Disable +#define DHCP_TAG_POLICY_SRR 21 // Policy Filter +#define DHCP_TAG_EMTU 22 // Maximum Datagram Reassembly Size +#define DHCP_TAG_TTL 23 // Default IP Time-to-live +#define DHCP_TAG_PATHMTU_AGE 24 // Path MTU Aging Timeout +#define DHCP_TAG_PATHMTU_PLATEAU 25 // Path MTU Plateau Table + +// +// IP Layer Parameters per Interface +// +#define DHCP_TAG_IFMTU 26 // Interface MTU +#define DHCP_TAG_SUBNET_LOCAL 27 // All Subnets are Local +#define DHCP_TAG_BROADCAST 28 // Broadcast Address +#define DHCP_TAG_DISCOVER_MASK 29 // Perform Mask Discovery +#define DHCP_TAG_SUPPLY_MASK 30 // Mask Supplier +#define DHCP_TAG_DISCOVER_ROUTE 31 // Perform Router Discovery +#define DHCP_TAG_ROUTER_SOLICIT 32 // Router Solicitation Address +#define DHCP_TAG_STATIC_ROUTE 33 // Static Route + +// +// Link Layer Parameters per Interface +// +#define DHCP_TAG_TRAILER 34 // Trailer Encapsulation +#define DHCP_TAG_ARPAGE 35 // ARP Cache Timeout +#define DHCP_TAG_ETHER_ENCAP 36 // Ethernet Encapsulation + +// +// TCP Parameters +// +#define DHCP_TAG_TCP_TTL 37 // TCP Default TTL +#define DHCP_TAG_KEEP_INTERVAL 38 // TCP Keepalive Interval +#define DHCP_TAG_KEEP_GARBAGE 39 // TCP Keepalive Garbage + +// +// Application and Service Parameters +// +#define DHCP_TAG_NIS_DOMAIN 40 // Network Information Service Domain +#define DHCP_TAG_NIS_SERVER 41 // Network Information Servers +#define DHCP_TAG_NTP_SERVER 42 // Network Time Protocol Servers +#define DHCP_TAG_VENDOR 43 // Vendor Specific Information +#define DHCP_TAG_NBNS 44 // NetBIOS over TCP/IP Name Server +#define DHCP_TAG_NBDD 45 // NetBIOS Datagram Distribution Server +#define DHCP_TAG_NBTYPE 46 // NetBIOS over TCP/IP Node Type +#define DHCP_TAG_NBSCOPE 47 // NetBIOS over TCP/IP Scope +#define DHCP_TAG_XFONT 48 // X Window System Font Server +#define DHCP_TAG_XDM 49 // X Window System Display Manager +#define DHCP_TAG_NISPLUS 64 // Network Information Service+ Domain +#define DHCP_TAG_NISPLUS_SERVER 65 // Network Information Service+ Servers +#define DHCP_TAG_MOBILEIP 68 // Mobile IP Home Agent +#define DHCP_TAG_SMTP 69 // Simple Mail Transport Protocol Server +#define DHCP_TAG_POP3 70 // Post Office Protocol (POP3) Server +#define DHCP_TAG_NNTP 71 // Network News Transport Protocol Server +#define DHCP_TAG_WWW 72 // Default World Wide Web (WWW) Server +#define DHCP_TAG_FINGER 73 // Default Finger Server +#define DHCP_TAG_IRC 74 // Default Internet Relay Chat (IRC) Server +#define DHCP_TAG_STTALK 75 // StreetTalk Server +#define DHCP_TAG_STDA 76 // StreetTalk Directory Assistance Server +#define DHCP_TAG_CLASSLESS_ROUTE 121 // Classless Route + +// +// DHCP Extensions +// +#define DHCP_TAG_REQUEST_IP 50 // Requested IP Address +#define DHCP_TAG_LEASE 51 // IP Address Lease Time +#define DHCP_TAG_OVERLOAD 52 // Option Overload +#define DHCP_TAG_TFTP 66 // TFTP server name +#define DHCP_TAG_BOOTFILE 67 // Bootfile name +#define DHCP_TAG_TYPE 53 // DHCP Message Type +#define DHCP_TAG_SERVER_ID 54 // Server Identifier +#define DHCP_TAG_PARA_LIST 55 // Parameter Request List +#define DHCP_TAG_MESSAGE 56 // Message +#define DHCP_TAG_MAXMSG 57 // Maximum DHCP Message Size +#define DHCP_TAG_T1 58 // Renewal (T1) Time Value +#define DHCP_TAG_T2 59 // Rebinding (T2) Time Value +#define DHCP_TAG_VENDOR_CLASS 60 // Vendor class identifier +#define DHCP_TAG_CLIENT_ID 61 // Client-identifier + + +#define DHCP_OPTION_MAGIC 0x63538263 // Network byte order +#define DHCP_MAX_OPTIONS 256 + + +// +// DHCP option types, this is used to validate the DHCP options. +// +#define DHCP_OPTION_SWITCH 1 +#define DHCP_OPTION_INT8 2 +#define DHCP_OPTION_INT16 3 +#define DHCP_OPTION_INT32 4 +#define DHCP_OPTION_IP 5 +#define DHCP_OPTION_IPPAIR 6 + +// +// Value of DHCP overload option +// +#define DHCP_OVERLOAD_FILENAME 1 +#define DHCP_OVERLOAD_SVRNAME 2 +#define DHCP_OVERLOAD_BOTH 3 /// /// The DHCP option structure. This structure extends the EFI_DHCP_OPTION diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiCHAP.h b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiCHAP.h index cce7e5a324..6de87d01b7 100644 --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiCHAP.h +++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiCHAP.h @@ -1,7 +1,7 @@ /** @file The header file of CHAP configuration. -Copyright (c) 2004 - 2007, Intel Corporation.
+Copyright (c) 2004 - 2009, 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 @@ -37,13 +37,12 @@ extern EFI_GUID mIScsiCHAPAuthInfoGuid; /// MD5_HASHSIZE /// #define ISCSI_CHAP_RSP_LEN 16 -typedef enum { - ISCSI_CHAP_INITIAL, - ISCSI_CHAP_STEP_ONE, - ISCSI_CHAP_STEP_TWO, - ISCSI_CHAP_STEP_THREE, - ISCSI_CHAP_STEP_FOUR -} ISCSI_CHAP_STEP; + +#define ISCSI_CHAP_INITIAL 0 +#define ISCSI_CHAP_STEP_ONE 1 +#define ISCSI_CHAP_STEP_TWO 2 +#define ISCSI_CHAP_STEP_THREE 3 +#define ISCSI_CHAP_STEP_FOUR 4 #pragma pack(1) diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c index 59840f7f06..62fc37a3d4 100644 --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c +++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiConfig.c @@ -1,7 +1,7 @@ /** @file Helper functions for configuring or getting the parameters relating to iSCSI. -Copyright (c) 2004 - 2008, Intel Corporation.
+Copyright (c) 2004 - 2009, 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 @@ -544,7 +544,7 @@ IScsiFormCallback ( case KEY_LOCAL_IP: IScsiUnicodeStrToAsciiStr (IfrNvData->LocalIp, Ip4String); Status = IScsiAsciiStrToIp (Ip4String, &HostIp.v4); - if (EFI_ERROR (Status) || !Ip4IsUnicast (NTOHL (HostIp.Addr[0]), 0)) { + if (EFI_ERROR (Status) || !NetIp4IsUnicast (NTOHL (HostIp.Addr[0]), 0)) { CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid IP address!", NULL); Status = EFI_INVALID_PARAMETER; } else { @@ -568,7 +568,7 @@ IScsiFormCallback ( case KEY_GATE_WAY: IScsiUnicodeStrToAsciiStr (IfrNvData->Gateway, Ip4String); Status = IScsiAsciiStrToIp (Ip4String, &Gateway.v4); - if (EFI_ERROR (Status) || ((Gateway.Addr[0] != 0) && !Ip4IsUnicast (NTOHL (Gateway.Addr[0]), 0))) { + if (EFI_ERROR (Status) || ((Gateway.Addr[0] != 0) && !NetIp4IsUnicast (NTOHL (Gateway.Addr[0]), 0))) { CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Gateway!", NULL); Status = EFI_INVALID_PARAMETER; } else { @@ -580,7 +580,7 @@ IScsiFormCallback ( case KEY_TARGET_IP: IScsiUnicodeStrToAsciiStr (IfrNvData->TargetIp, Ip4String); Status = IScsiAsciiStrToIp (Ip4String, &HostIp.v4); - if (EFI_ERROR (Status) || !Ip4IsUnicast (NTOHL (HostIp.Addr[0]), 0)) { + if (EFI_ERROR (Status) || !NetIp4IsUnicast (NTOHL (HostIp.Addr[0]), 0)) { CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid IP address!", NULL); Status = EFI_INVALID_PARAMETER; } else { @@ -678,7 +678,7 @@ IScsiFormCallback ( // if (!Private->Current->SessionConfigData.TargetInfoFromDhcp) { CopyMem (&HostIp.v4, &Private->Current->SessionConfigData.TargetIp, sizeof (HostIp.v4)); - if (!Ip4IsUnicast (NTOHL (HostIp.Addr[0]), 0)) { + if (!NetIp4IsUnicast (NTOHL (HostIp.Addr[0]), 0)) { CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Target IP is invalid!", NULL); Status = EFI_INVALID_PARAMETER; break; diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiDhcp.c b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiDhcp.c index dfb3209ea4..d0f2089246 100644 --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiDhcp.c +++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiDhcp.c @@ -1,7 +1,7 @@ /** @file iSCSI DHCP related configuration routines. -Copyright (c) 2004 - 2007, 2009, Intel Corporation.
+Copyright (c) 2004 - 2009, 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 @@ -38,7 +38,7 @@ IScsiDhcpExtractRootPath ( CHAR8 *TmpStr; ISCSI_ROOT_PATH_FIELD Fields[RP_FIELD_IDX_MAX]; ISCSI_ROOT_PATH_FIELD *Field; - RP_FIELD_IDX FieldIndex; + UINT32 FieldIndex; UINT8 Index; // diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiDhcp.h b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiDhcp.h index fd1fbe46ca..07b30a936c 100644 --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiDhcp.h +++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiDhcp.h @@ -1,7 +1,7 @@ /** @file The header file of IScsiDhcp. -Copyright (c) 2004 - 2008, Intel Corporation.
+Copyright (c) 2004 - 2009, 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 @@ -26,14 +26,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #define ISCSI_ROOT_PATH_ID "iscsi:" #define ISCSI_ROOT_PATH_FIELD_DELIMITER ':' -typedef enum { - RP_FIELD_IDX_SERVERNAME = 0, - RP_FIELD_IDX_PROTOCOL, - RP_FIELD_IDX_PORT, - RP_FIELD_IDX_LUN, - RP_FIELD_IDX_TARGETNAME, - RP_FIELD_IDX_MAX -} RP_FIELD_IDX; +#define RP_FIELD_IDX_SERVERNAME 0 +#define RP_FIELD_IDX_PROTOCOL 1 +#define RP_FIELD_IDX_PORT 2 +#define RP_FIELD_IDX_LUN 3 +#define RP_FIELD_IDX_TARGETNAME 4 +#define RP_FIELD_IDX_MAX 5 typedef struct _ISCSI_ROOT_PATH_FIELD { CHAR8 *Str; diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiIbft.c b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiIbft.c index d712331189..ca08da7fa4 100644 --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiIbft.c +++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiIbft.c @@ -20,7 +20,9 @@ UINTN mTableKey; /** Initialize the header of the iSCSI Boot Firmware Table. - @param[out] Header The header of the iSCSI Boot Firmware Table. + @param[out] Header The header of the iSCSI Boot Firmware Table. + @param[in] OemId The OEM ID. + @param[in] OemTableId The OEM table ID for the iBFT. **/ VOID IScsiInitIbfTableHeader ( diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c index 9eff1850be..519423320b 100644 --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c +++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c @@ -126,7 +126,7 @@ IScsiAsciiStrToLun ( UINTN Index, IndexValue, IndexNum, SizeStr; CHAR8 TemStr[2]; UINT8 TemValue; - UINT16 Value [4]; + UINT16 Value[4]; ZeroMem (Lun, 8); ZeroMem (TemStr, 2); diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c index a370e29a5c..d73a961465 100644 --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c +++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.c @@ -1,7 +1,7 @@ /** @file The implementation of iSCSI protocol based on RFC3720. -Copyright (c) 2004 - 2008, Intel Corporation.
+Copyright (c) 2004 - 2009, 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 @@ -225,8 +225,8 @@ IScsiCreateConnection ( // set the default connection-only parameters // Conn->MaxRecvDataSegmentLength = DEFAULT_MAX_RECV_DATA_SEG_LEN; - Conn->HeaderDigest = ISCSI_DIGEST_NONE; - Conn->DataDigest = ISCSI_DIGEST_NONE; + Conn->HeaderDigest = IScsiDigestNone; + Conn->DataDigest = IScsiDigestNone; CopyMem (&Tcp4IoConfig.LocalIp, &Session->ConfigData.NvData.LocalIp, sizeof (EFI_IPv4_ADDRESS)); CopyMem (&Tcp4IoConfig.SubnetMask, &Session->ConfigData.NvData.SubnetMask, sizeof (EFI_IPv4_ADDRESS)); @@ -1146,11 +1146,11 @@ IScsiCheckOpParams ( } if (AsciiStrCmp (Value, "CRC32") == 0) { - if (Conn->HeaderDigest != ISCSI_DIGEST_CRC32) { + if (Conn->HeaderDigest != IScsiDigestCRC32) { goto ON_ERROR; } } else if (AsciiStrCmp (Value, ISCSI_KEY_VALUE_NONE) == 0) { - Conn->HeaderDigest = ISCSI_DIGEST_NONE; + Conn->HeaderDigest = IScsiDigestNone; } else { goto ON_ERROR; } @@ -1163,11 +1163,11 @@ IScsiCheckOpParams ( } if (AsciiStrCmp (Value, "CRC32") == 0) { - if (Conn->DataDigest != ISCSI_DIGEST_CRC32) { + if (Conn->DataDigest != IScsiDigestCRC32) { goto ON_ERROR; } } else if (AsciiStrCmp (Value, ISCSI_KEY_VALUE_NONE) == 0) { - Conn->DataDigest = ISCSI_DIGEST_NONE; + Conn->DataDigest = IScsiDigestNone; } else { goto ON_ERROR; } @@ -1361,10 +1361,10 @@ IScsiFillOpParams ( Session = Conn->Session; - AsciiSPrint (Value, sizeof (Value), "%a", (Conn->HeaderDigest == ISCSI_DIGEST_CRC32) ? "None,CRC32" : "None"); + AsciiSPrint (Value, sizeof (Value), "%a", (Conn->HeaderDigest == IScsiDigestCRC32) ? "None,CRC32" : "None"); IScsiAddKeyValuePair (Pdu, ISCSI_KEY_HEADER_DIGEST, Value); - AsciiSPrint (Value, sizeof (Value), "%a", (Conn->DataDigest == ISCSI_DIGEST_CRC32) ? "None,CRC32" : "None"); + AsciiSPrint (Value, sizeof (Value), "%a", (Conn->DataDigest == IScsiDigestCRC32) ? "None,CRC32" : "None"); IScsiAddKeyValuePair (Pdu, ISCSI_KEY_DATA_DIGEST, Value); AsciiSPrint (Value, sizeof (Value), "%d", Session->ErrorRecoveryLevel); @@ -1854,7 +1854,7 @@ IScsiNewScsiCmdPdu ( ScsiCmd->CmdSN = NTOHL (Tcb->CmdSN); ScsiCmd->ExpStatSN = NTOHL (Tcb->Conn->ExpStatSN); - CopyMem (ScsiCmd->CDB, Packet->Cdb, sizeof (ScsiCmd->CDB)); + CopyMem (ScsiCmd->Cdb, Packet->Cdb, sizeof (ScsiCmd->Cdb)); if (Packet->CdbLength > 16) { Header->Length = NTOHS (Packet->CdbLength - 15); @@ -2258,7 +2258,7 @@ IScsiOnR2TRcvd ( R2THdr->InitiatorTaskTag = NTOHL (R2THdr->InitiatorTaskTag); R2THdr->TargetTransferTag = NTOHL (R2THdr->TargetTransferTag); R2THdr->StatSN = NTOHL (R2THdr->StatSN); - R2THdr->R2TSN = NTOHL (R2THdr->R2TSN); + R2THdr->R2TSeqNum = NTOHL (R2THdr->R2TSeqNum); R2THdr->BufferOffset = NTOHL (R2THdr->BufferOffset); R2THdr->DesiredDataTransferLength = NTOHL (R2THdr->DesiredDataTransferLength); @@ -2268,7 +2268,7 @@ IScsiOnR2TRcvd ( // // Check the sequence number. // - Status = IScsiCheckSN (&Tcb->ExpDataSN, R2THdr->R2TSN); + Status = IScsiCheckSN (&Tcb->ExpDataSN, R2THdr->R2TSeqNum); if (EFI_ERROR (Status)) { return Status; } diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.h b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.h index 3ffb2c47f1..93fe2af5b7 100644 --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.h +++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiProto.h @@ -1,7 +1,7 @@ /** @file The header file of iSCSI Protocol that defines many specific data structures. -Copyright (c) 2004 - 2008, Intel Corporation.
+Copyright (c) 2004 - 2009, 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 @@ -75,25 +75,22 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. /// /// connection state for initiator /// -typedef enum { - CONN_STATE_FREE, - CONN_STATE_XPT_WAIT, - CONN_STATE_IN_LOGIN, - CONN_STATE_LOGGED_IN, - CONN_STATE_IN_LOGOUT, - CONN_STATE_LOGOUT_REQUESTED, - CONN_STATE_CLEANUP_WAIT, - CONN_STATE_IN_CLEANUP -} CONNECTION_STATE; + +#define CONN_STATE_FREE 0 +#define CONN_STATE_XPT_WAIT 1 +#define CONN_STATE_IN_LOGIN 2 +#define CONN_STATE_LOGGED_IN 3 +#define CONN_STATE_IN_LOGOUT 4 +#define CONN_STATE_LOGOUT_REQUESTED 5 +#define CONN_STATE_CLEANUP_WAIT 6 +#define CONN_STATE_IN_CLEANUP 7 /// /// session state for initiator /// -typedef enum { - SESSION_STATE_FREE, - SESSION_STATE_LOGGED_IN, - SESSION_STATE_FAILED -} SESSION_STATE; +#define SESSION_STATE_FREE 0 +#define SESSION_STATE_LOGGED_IN 1 +#define SESSION_STATE_FAILED 2 typedef enum { DataIn = 0, @@ -227,7 +224,7 @@ typedef struct _SCSI_COMMAND { UINT32 ExpDataXferLength; UINT32 CmdSN; UINT32 ExpStatSN; - UINT8 CDB[16]; + UINT8 Cdb[16]; } SCSI_COMMAND; // @@ -378,7 +375,7 @@ typedef struct _ISCSI_READY_TO_TRANSFER { UINT32 StatSN; UINT32 ExpCmdSN; UINT32 MaxCmdSN; - UINT32 R2TSN; + UINT32 R2TSeqNum; UINT32 BufferOffset; UINT32 DesiredDataTransferLength; } ISCSI_READY_TO_TRANSFER; @@ -586,8 +583,8 @@ typedef struct _ISCSI_NOP_IN { #define ISCSI_FULL_FEATURE_PHASE 3 typedef enum { - ISCSI_DIGEST_NONE, - ISCSI_DIGEST_CRC32 + IScsiDigestNone, + IScsiDigestCRC32 } ISCSI_DIGEST_TYPE; typedef struct _ISCSI_XFER_CONTEXT { diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.h b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.h index 8cc789d273..e8814a1e9f 100644 --- a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.h +++ b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.h @@ -46,27 +46,24 @@ typedef struct _IP4_CONFIG_INSTANCE IP4_CONFIG_INSTANCE; // // Global variables // -extern EFI_DRIVER_BINDING_PROTOCOL gIp4ConfigDriverBinding; -extern EFI_COMPONENT_NAME_PROTOCOL gIp4ConfigComponentName; -extern EFI_COMPONENT_NAME2_PROTOCOL gIp4ConfigComponentName2; - -extern IP4_CONFIG_INSTANCE *mIp4ConfigNicList[MAX_IP4_CONFIG_IN_VARIABLE]; -extern EFI_IP4_CONFIG_PROTOCOL mIp4ConfigProtocolTemplate; +extern EFI_DRIVER_BINDING_PROTOCOL gIp4ConfigDriverBinding; +extern EFI_COMPONENT_NAME_PROTOCOL gIp4ConfigComponentName; +extern EFI_COMPONENT_NAME2_PROTOCOL gIp4ConfigComponentName2; + +extern IP4_CONFIG_INSTANCE *mIp4ConfigNicList[MAX_IP4_CONFIG_IN_VARIABLE]; +extern EFI_IP4_CONFIG_PROTOCOL mIp4ConfigProtocolTemplate; #define IP4_PROTO_ICMP 0x01 #define IP4_CONFIG_INSTANCE_SIGNATURE SIGNATURE_32 ('I', 'P', '4', 'C') -typedef enum { - IP4_CONFIG_STATE_IDLE = 0, - IP4_CONFIG_STATE_STARTED, - IP4_CONFIG_STATE_CONFIGURED -} IP4_CONFIG_STATE; - -typedef enum { - DHCP_TAG_PARA_LIST = 55, - DHCP_TAG_NETMASK = 1, - DHCP_TAG_ROUTER = 3 -} DHCP_TAGS; +#define IP4_CONFIG_STATE_IDLE 0 +#define IP4_CONFIG_STATE_STARTED 1 +#define IP4_CONFIG_STATE_CONFIGURED 2 + +#define DHCP_TAG_PARA_LIST 55 +#define DHCP_TAG_NETMASK 1 +#define DHCP_TAG_ROUTER 3 + // // Configure the DHCP to request the routers and netmask diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigNv.c b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigNv.c index a5b7c93ebe..c97184ae2d 100644 --- a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigNv.c +++ b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigNv.c @@ -198,8 +198,8 @@ Ip4ConfigIpToStr ( /** Convert the network configuration data into the IFR data. - @param[in] ConfigFormEntry The IP4 configuration form entry. - @param[out] IfrNvData The IFR nv data. + @param[in] Ip4ConfigInstance The IP4Config instance + @param[out] IfrFormNvData The IFR nv data. **/ VOID Ip4ConfigConvertDeviceConfigDataToIfrNvData ( @@ -700,7 +700,7 @@ Ip4FormCallback ( case KEY_LOCAL_IP: UnicodeStrToAsciiStr (IfrFormNvData->StationAddress, Ip4String); Status = Ip4AsciiStrToIp (Ip4String, &HostIp.v4); - if (EFI_ERROR (Status) || !Ip4IsUnicast (NTOHL (HostIp.Addr[0]), 0)) { + if (EFI_ERROR (Status) || !NetIp4IsUnicast (NTOHL (HostIp.Addr[0]), 0)) { CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid IP address!", NULL); Status = EFI_INVALID_PARAMETER; } else { @@ -724,7 +724,7 @@ Ip4FormCallback ( case KEY_GATE_WAY: UnicodeStrToAsciiStr (IfrFormNvData->GatewayAddress, Ip4String); Status = Ip4AsciiStrToIp (Ip4String, &Gateway.v4); - if (EFI_ERROR (Status) || ((Gateway.Addr[0] != 0) && !Ip4IsUnicast (NTOHL (Gateway.Addr[0]), 0))) { + if (EFI_ERROR (Status) || ((Gateway.Addr[0] != 0) && !NetIp4IsUnicast (NTOHL (Gateway.Addr[0]), 0))) { CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Gateway!", NULL); Status = EFI_INVALID_PARAMETER; } else { diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/NicIp4Variable.c b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/NicIp4Variable.c index a5f00ee645..17709af107 100644 --- a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/NicIp4Variable.c +++ b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/NicIp4Variable.c @@ -1,7 +1,7 @@ /** @file Routines used to operate the Ip4 configure variable. -Copyright (c) 2006 - 2008, Intel Corporation.
+Copyright (c) 2006 - 2009, 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
@@ -45,7 +45,7 @@ Ip4ConfigIsValid ( Netmask = EFI_NTOHL (IpConfig->SubnetMask); if ((Netmask == 0) || !IP4_IS_VALID_NETMASK (Netmask) || - (Station == 0) || !Ip4IsUnicast (Station, Netmask)) { + (Station == 0) || !NetIp4IsUnicast (Station, Netmask)) { return FALSE; } @@ -57,7 +57,7 @@ Ip4ConfigIsValid ( Gateway = EFI_NTOHL (IpConfig->RouteTable[Index].GatewayAddress); if ((Gateway != 0) && (!IP4_NET_EQUAL (Station, Gateway, Netmask) || - !Ip4IsUnicast (Gateway, Netmask))) { + !NetIp4IsUnicast (Gateway, Netmask))) { return FALSE; } } diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Common.h b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Common.h index af01a03b00..0e221f7c62 100644 --- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Common.h +++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Common.h @@ -1,7 +1,7 @@ /** @file Common definition for IP4. -Copyright (c) 2005 - 2006, Intel Corporation.
+Copyright (c) 2005 - 2009, 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 @@ -19,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 diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Icmp.c b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Icmp.c index 757d7aadc0..76208e071b 100644 --- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Icmp.c +++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Icmp.c @@ -1,6 +1,6 @@ /** @file -Copyright (c) 2005 - 2006, Intel Corporation.
+Copyright (c) 2005 - 2009, 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 @@ -62,7 +62,7 @@ mIp4SupportedIcmp[23] = { {ICMP_ECHO_REQUEST, ICMP_DEFAULT_CODE }, {ICMP_TIME_EXCEEDED, ICMP_TIMEOUT_IN_TRANSIT }, - {ICMP_TIME_EXCEEDED, ICMp_TIMEOUT_REASSEMBLE }, + {ICMP_TIME_EXCEEDED, ICMP_TIMEOUT_REASSEMBLE }, {ICMP_PARAMETER_PROBLEM, ICMP_DEFAULT_CODE }, }; @@ -247,7 +247,7 @@ Ip4IcmpReplyEcho ( ReplyHead.Tos = 0; ReplyHead.Fragment = 0; ReplyHead.Ttl = 64; - ReplyHead.Protocol = IP4_PROTO_ICMP; + ReplyHead.Protocol = EFI_IP_PROTO_ICMP; ReplyHead.Src = 0; // diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Icmp.h b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Icmp.h index f9db6a3da4..2488e61060 100644 --- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Icmp.h +++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Icmp.h @@ -1,7 +1,7 @@ /** @file Header file for ICMP protocol. -Copyright (c) 2005 - 2006, Intel Corporation.
+Copyright (c) 2005 - 2009, 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 @@ -15,63 +15,61 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #ifndef __EFI_IP4_ICMP_H__ #define __EFI_IP4_ICMP_H__ -typedef enum { // // ICMP type definations // - ICMP_ECHO_REPLY = 0, - ICMP_DEST_UNREACHABLE = 3, - ICMP_SOURCE_QUENCH = 4, - ICMP_REDIRECT = 5, - ICMP_ECHO_REQUEST = 8, - ICMP_TIME_EXCEEDED = 11, - ICMP_PARAMETER_PROBLEM = 12, - ICMP_TIMESTAMP = 13, - ICMP_INFO_REQUEST = 15, - ICMP_INFO_REPLY = 16, - ICMP_TYPE_MAX = ICMP_INFO_REPLY, +#define ICMP_ECHO_REPLY 0 +#define ICMP_DEST_UNREACHABLE 3 +#define ICMP_SOURCE_QUENCH 4 +#define ICMP_REDIRECT 5 +#define ICMP_ECHO_REQUEST 8 +#define ICMP_TIME_EXCEEDED 11 +#define ICMP_PARAMETER_PROBLEM 12 +#define ICMP_TIMESTAMP 13 +#define ICMP_INFO_REQUEST 15 +#define ICMP_INFO_REPLY 16 +#define ICMP_TYPE_MAX ICMP_INFO_REPLY - ICMP_DEFAULT_CODE = 0, +#define ICMP_DEFAULT_CODE 0 // // ICMP code definations for ICMP_DEST_UNREACHABLE // - ICMP_NET_UNREACHABLE = 0, - ICMP_HOST_UNREACHABLE = 1, - ICMP_PROTO_UNREACHABLE = 2, // Host may generate - ICMP_PORT_UNREACHABLE = 3, // Host may generate - ICMP_FRAGMENT_FAILED = 4, - ICMP_SOURCEROUTE_FAILED = 5, // Host may generate - ICMP_NET_UNKNOWN = 6, - ICMP_HOST_UNKNOWN = 7, - ICMP_SOURCE_ISOLATED = 8, - ICMP_NET_PROHIBITED = 9, - ICMP_HOST_PROHIBITED = 10, - ICMP_NET_UNREACHABLE_TOS = 11, - ICMP_HOST_UNREACHABLE_TOS = 12, +#define ICMP_NET_UNREACHABLE 0 +#define ICMP_HOST_UNREACHABLE 1 +#define ICMP_PROTO_UNREACHABLE 2 // Host may generate +#define ICMP_PORT_UNREACHABLE 3 // Host may generate +#define ICMP_FRAGMENT_FAILED 4 +#define ICMP_SOURCEROUTE_FAILED 5 // Host may generate +#define ICMP_NET_UNKNOWN 6 +#define ICMP_HOST_UNKNOWN 7 +#define ICMP_SOURCE_ISOLATED 8 +#define ICMP_NET_PROHIBITED 9 +#define ICMP_HOST_PROHIBITED 10 +#define ICMP_NET_UNREACHABLE_TOS 11 +#define ICMP_HOST_UNREACHABLE_TOS 12 // // ICMP code definations for ICMP_TIME_EXCEEDED // - ICMP_TIMEOUT_IN_TRANSIT = 0, - ICMp_TIMEOUT_REASSEMBLE = 1, // Host may generate +#define ICMP_TIMEOUT_IN_TRANSIT 0 +#define ICMP_TIMEOUT_REASSEMBLE 1 // Host may generate // // ICMP code definations for ICMP_TIME_EXCEEDED // - ICMP_NET_REDIRECT = 0, - ICMP_HOST_REDIRECT = 1, - ICMP_NET_TOS_REDIRECT = 2, - ICMP_HOST_TOS_REDIRECT = 3, +#define ICMP_NET_REDIRECT 0 +#define ICMP_HOST_REDIRECT 1 +#define ICMP_NET_TOS_REDIRECT 2 +#define ICMP_HOST_TOS_REDIRECT 3 // // ICMP message classes, each class of ICMP message shares // a common message format. INVALID_MESSAGE is only a flag. // - ICMP_INVALID_MESSAGE = 0, - ICMP_ERROR_MESSAGE = 1, - ICMP_QUERY_MESSAGE = 2 -} ICMP_ENUM_TYPES; +#define ICMP_INVALID_MESSAGE 0 +#define ICMP_ERROR_MESSAGE 1 +#define ICMP_QUERY_MESSAGE 2 typedef struct { UINT8 IcmpType; diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.h b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.h index 305e826a8d..2032c6d28d 100644 --- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.h +++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4If.h @@ -1,7 +1,7 @@ /** @file Definition for IP4 pesudo interface structure. -Copyright (c) 2005 - 2006, Intel Corporation.
+Copyright (c) 2005 - 2009, 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 @@ -15,12 +15,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #ifndef __EFI_IP4_IF_H__ #define __EFI_IP4_IF_H__ -typedef enum { - IP4_FRAME_RX_SIGNATURE = SIGNATURE_32 ('I', 'P', 'F', 'R'), - IP4_FRAME_TX_SIGNATURE = SIGNATURE_32 ('I', 'P', 'F', 'T'), - IP4_FRAME_ARP_SIGNATURE = SIGNATURE_32 ('I', 'P', 'F', 'A'), - IP4_INTERFACE_SIGNATURE = SIGNATURE_32 ('I', 'P', 'I', 'F') -} IP4_IF_ENUM_TYPES; +#define IP4_FRAME_RX_SIGNATURE SIGNATURE_32 ('I', 'P', 'F', 'R') +#define IP4_FRAME_TX_SIGNATURE SIGNATURE_32 ('I', 'P', 'F', 'T') +#define IP4_FRAME_ARP_SIGNATURE SIGNATURE_32 ('I', 'P', 'F', 'A') +#define IP4_INTERFACE_SIGNATURE SIGNATURE_32 ('I', 'P', 'I', 'F') /** This prototype is used by both receive and transmission. diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Igmp.h b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Igmp.h index b82d3cc3ea..549d4a2176 100644 --- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Igmp.h +++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Igmp.h @@ -1,6 +1,6 @@ /** @file -Copyright (c) 2005 - 2006, Intel Corporation.
+Copyright (c) 2005 - 2009, 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 @@ -14,6 +14,17 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #ifndef __EFI_IP4_IGMP_H__ #define __EFI_IP4_IGMP_H__ +// +// IGMP message type +// +#define IGMP_MEMBERSHIP_QUERY 0x11 +#define IGMP_V1_MEMBERSHIP_REPORT 0x12 +#define IGMP_V2_MEMBERSHIP_REPORT 0x16 +#define IGMP_LEAVE_GROUP 0x17 + +#define IGMP_V1ROUTER_PRESENT 400 +#define IGMP_UNSOLICIATED_REPORT 10 + #pragma pack(1) typedef struct { UINT8 Type; @@ -48,19 +59,6 @@ typedef struct { LIST_ENTRY Groups; } IGMP_SERVICE_DATA; -typedef enum { - // - // IGMP message type - // - IGMP_MEMBERSHIP_QUERY = 0x11, - IGMP_V1_MEMBERSHIP_REPORT = 0x12, - IGMP_V2_MEMBERSHIP_REPORT = 0x16, - IGMP_LEAVE_GROUP = 0x17, - - IGMP_V1ROUTER_PRESENT = 400, - IGMP_UNSOLICIATED_REPORT = 10 -} IGMP_ENUM_TYPES; - /** Init the IGMP control data of the IP4 service instance, configure MNP to receive ALL SYSTEM multicast. diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c index 714f3d9b82..4788d403fe 100644 --- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c +++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c @@ -1962,7 +1962,7 @@ EfiIp4Transmit ( // a IP4_TXTOKEN_WRAP and the data in a netbuf // Status = EFI_OUT_OF_RESOURCES; - Wrap = AllocatePool (sizeof (IP4_TXTOKEN_WRAP)); + Wrap = AllocateZeroPool (sizeof (IP4_TXTOKEN_WRAP)); if (Wrap == NULL) { goto ON_EXIT; } diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.h b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.h index 615e5ae2a8..8b2e286f0c 100644 --- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.h +++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.h @@ -1,7 +1,7 @@ /** @file Ip4 internal functions and type defintions. -Copyright (c) 2005 - 2007, Intel Corporation.
+Copyright (c) 2005 - 2009, 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 @@ -43,34 +43,31 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include "Ip4Input.h" #include "Ip4Output.h" +#define IP4_PROTOCOL_SIGNATURE SIGNATURE_32 ('I', 'P', '4', 'P') +#define IP4_SERVICE_SIGNATURE SIGNATURE_32 ('I', 'P', '4', 'S') + +// +// The state of IP4 protocol. It starts from UNCONFIGED. if it is +// successfully configured, it goes to CONFIGED. if configure NULL +// is called, it becomes UNCONFIGED again. If (partly) destoried, it +// becomes DESTORY. +// +#define IP4_STATE_UNCONFIGED 0 +#define IP4_STATE_CONFIGED 1 +#define IP4_STATE_DESTORY 2 + +// +// The state of IP4 service. It starts from UNSTARTED. It transits +// to STARTED if autoconfigure is started. If default address is +// configured, it becomes CONFIGED. and if partly destoried, it goes +// to DESTORY. +// +#define IP4_SERVICE_UNSTARTED 0 +#define IP4_SERVICE_STARTED 1 +#define IP4_SERVICE_CONFIGED 2 +#define IP4_SERVICE_DESTORY 3 -typedef enum { - IP4_PROTOCOL_SIGNATURE = SIGNATURE_32 ('I', 'P', '4', 'P'), - IP4_SERVICE_SIGNATURE = SIGNATURE_32 ('I', 'P', '4', 'S'), - - // - // The state of IP4 protocol. It starts from UNCONFIGED. if it is - // successfully configured, it goes to CONFIGED. if configure NULL - // is called, it becomes UNCONFIGED again. If (partly) destoried, it - // becomes DESTORY. - // - IP4_STATE_UNCONFIGED = 0, - IP4_STATE_CONFIGED, - IP4_STATE_DESTORY, - - // - // The state of IP4 service. It starts from UNSTARTED. It transits - // to STARTED if autoconfigure is started. If default address is - // configured, it becomes CONFIGED. and if partly destoried, it goes - // to DESTORY. - // - IP4_SERVICE_UNSTARTED = 0, - IP4_SERVICE_STARTED, - IP4_SERVICE_CONFIGED, - IP4_SERVICE_DESTORY -} IP4_IMPL_ENUM_TYPES; - /// /// IP4_TXTOKEN_WRAP wraps the upper layer's transmit token. /// The user's data is kept in the Packet. When fragment is diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Input.c b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Input.c index b495e75deb..7257353301 100644 --- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Input.c +++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Input.c @@ -228,7 +228,7 @@ Ip4Reassemble ( NET_BUF *NewPacket; INTN Index; - IpHead = Packet->Ip; + IpHead = Packet->Ip.Ip4; This = IP4_GET_CLIP_INFO (Packet); ASSERT (IpHead != NULL); @@ -417,7 +417,7 @@ Ip4Reassemble ( return NULL; } - NewPacket->Ip = Assemble->Head; + NewPacket->Ip.Ip4 = Assemble->Head; CopyMem (IP4_GET_CLIP_INFO (NewPacket), Assemble->Info, sizeof (*IP4_GET_CLIP_INFO (NewPacket))); return NewPacket; } @@ -501,7 +501,7 @@ Ip4AccpetFrame ( // // Convert the IP header to host byte order, then get the per packet info. // - Packet->Ip = Ip4NtohHead (Head); + Packet->Ip.Ip4 = Ip4NtohHead (Head); Info = IP4_GET_CLIP_INFO (Packet); Info->LinkFlag = Flag; @@ -570,11 +570,11 @@ Ip4AccpetFrame ( // info must be reloaded bofore use. The ownership of the packet // is transfered to the packet process logic. // - Head = Packet->Ip; + Head = Packet->Ip.Ip4; IP4_GET_CLIP_INFO (Packet)->Status = EFI_SUCCESS; switch (Head->Protocol) { - case IP4_PROTO_ICMP: + case EFI_IP_PROTO_ICMP: Ip4IcmpHandle (IpSb, Head, Packet); break; @@ -655,7 +655,7 @@ Ip4InstanceFrameAcceptable ( // Proto = Head->Protocol; - if (Proto == IP4_PROTO_ICMP) { + if (Proto == EFI_IP_PROTO_ICMP) { NetbufCopy (Packet, 0, sizeof (Icmp.Head), (UINT8 *) &Icmp.Head); if (mIcmpClass[Icmp.Head.Type].IcmpClass == ICMP_ERROR_MESSAGE) { @@ -850,13 +850,13 @@ Ip4WrapRxData ( return NULL; } - ASSERT (Packet->Ip != NULL); + ASSERT (Packet->Ip.Ip4 != NULL); // // The application expects a network byte order header. // - RxData->HeaderLength = (Packet->Ip->HeadLen << 2); - RxData->Header = (EFI_IP4_HEADER *) Ip4NtohHead (Packet->Ip); + RxData->HeaderLength = (Packet->Ip.Ip4->HeadLen << 2); + RxData->Header = (EFI_IP4_HEADER *) Ip4NtohHead (Packet->Ip.Ip4); RxData->OptionsLength = RxData->HeaderLength - IP4_MIN_HEADLEN; RxData->Options = NULL; @@ -938,9 +938,9 @@ Ip4InstanceDeliverPacket ( // may be not continuous before the data. // Head = NetbufAllocSpace (Dup, IP4_MAX_HEADLEN, NET_BUF_HEAD); - Dup->Ip = (IP4_HEAD *) Head; + Dup->Ip.Ip4 = (IP4_HEAD *) Head; - CopyMem (Head, Packet->Ip, Packet->Ip->HeadLen << 2); + CopyMem (Head, Packet->Ip.Ip4, Packet->Ip.Ip4->HeadLen << 2); NetbufTrim (Dup, IP4_MAX_HEADLEN, TRUE); Wrap = Ip4WrapRxData (IpInstance, Dup); diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Input.h b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Input.h index eea4d7e0cf..cd1367b012 100644 --- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Input.h +++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Input.h @@ -1,6 +1,6 @@ /** @file -Copyright (c) 2005 - 2006, Intel Corporation.
+Copyright (c) 2005 - 2009, 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 @@ -14,14 +14,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #ifndef __EFI_IP4_INPUT_H__ #define __EFI_IP4_INPUT_H__ -typedef enum { - IP4_MIN_HEADLEN = 20, - IP4_MAX_HEADLEN = 60, +#define IP4_MIN_HEADLEN 20 +#define IP4_MAX_HEADLEN 60 - IP4_ASSEMLE_HASH_SIZE = 31, - IP4_FRAGMENT_LIFE = 120, - IP4_MAX_PACKET_SIZE = 65535 -} IP4_INPUT_ENUM_TYPES; +#define IP4_ASSEMLE_HASH_SIZE 31 +#define IP4_FRAGMENT_LIFE 120 +#define IP4_MAX_PACKET_SIZE 65535 /// /// Per packet information for input process. LinkFlag specifies whether diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Option.h b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Option.h index 206c92031d..421872c2ed 100644 --- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Option.h +++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Option.h @@ -1,7 +1,7 @@ /** @file IP4 option support routines. -Copyright (c) 2005 - 2006, Intel Corporation.
+Copyright (c) 2005 - 2009, 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 @@ -15,15 +15,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #ifndef __EFI_IP4_OPTION_H__ #define __EFI_IP4_OPTION_H__ -typedef enum { - IP4_OPTION_EOP = 0, - IP4_OPTION_NOP = 1, - IP4_OPTION_LSRR = 131, // Loss source and record routing, 10000011 - IP4_OPTION_SSRR = 137, // Strict source and record routing, 10001001 - IP4_OPTION_RR = 7, // Record routing, 00000111 +#define IP4_OPTION_EOP 0 +#define IP4_OPTION_NOP 1 +#define IP4_OPTION_LSRR 131 // Loss source and record routing, 10000011 +#define IP4_OPTION_SSRR 137 // Strict source and record routing, 10001001 +#define IP4_OPTION_RR 7 // Record routing, 00000111 - IP4_OPTION_COPY_MASK = 0x80 -} IP4_OPTION_ENUM_TYPES; +#define IP4_OPTION_COPY_MASK 0x80 /** Validate the IP4 option format for both the packets we received diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Output.c b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Output.c index 306ab2ddf6..53317c829b 100644 --- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Output.c +++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Output.c @@ -1,7 +1,7 @@ /** @file Transmit the IP4 packet. -Copyright (c) 2005 - 2006, Intel Corporation.
+Copyright (c) 2005 - 2009, 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 @@ -83,7 +83,7 @@ Ip4PrependHead ( PacketHead->Dst = HTONL (Head->Dst); PacketHead->Checksum = (UINT16) (~NetblockChecksum ((UINT8 *) PacketHead, HeadLen)); - Packet->Ip = PacketHead; + Packet->Ip.Ip4 = PacketHead; return EFI_SUCCESS; } diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Route.c b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Route.c index 4c238a6e02..0c901e8266 100644 --- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Route.c +++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Route.c @@ -1,6 +1,6 @@ /** @file -Copyright (c) 2005 - 2006, Intel Corporation.
+Copyright (c) 2005 - 2009, 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 @@ -145,7 +145,7 @@ Ip4InitRouteCache ( { UINT32 Index; - for (Index = 0; Index < IP4_ROUTE_CACHE_HASH; Index++) { + for (Index = 0; Index < IP4_ROUTE_CACHE_HASH_VALUE; Index++) { InitializeListHead (&(RtCache->CacheBucket[Index])); } } @@ -168,7 +168,7 @@ Ip4CleanRouteCache ( IP4_ROUTE_CACHE_ENTRY *RtCacheEntry; UINT32 Index; - for (Index = 0; Index < IP4_ROUTE_CACHE_HASH; Index++) { + for (Index = 0; Index < IP4_ROUTE_CACHE_HASH_VALUE; Index++) { NET_LIST_FOR_EACH_SAFE (Entry, Next, &(RtCache->CacheBucket[Index])) { RtCacheEntry = NET_LIST_USER_STRUCT (Entry, IP4_ROUTE_CACHE_ENTRY, Link); @@ -278,7 +278,7 @@ Ip4PurgeRouteCache ( IP4_ROUTE_CACHE_ENTRY *RtCacheEntry; UINT32 Index; - for (Index = 0; Index < IP4_ROUTE_CACHE_HASH; Index++) { + for (Index = 0; Index < IP4_ROUTE_CACHE_HASH_VALUE; Index++) { NET_LIST_FOR_EACH_SAFE (Entry, Next, &RtCache->CacheBucket[Index]) { RtCacheEntry = NET_LIST_USER_STRUCT (Entry, IP4_ROUTE_CACHE_ENTRY, Link); diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Route.h b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Route.h index ee1f6a907f..774dd60842 100644 --- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Route.h +++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Route.h @@ -1,7 +1,7 @@ /** @file EFI IP4 route table and route cache table defintions. -Copyright (c) 2005 - 2006, Intel Corporation.
+Copyright (c) 2005 - 2009, 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 @@ -17,14 +17,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include "Ip4Common.h" -typedef enum { - IP4_DIRECT_ROUTE = 0x00000001, +#define IP4_DIRECT_ROUTE 0x00000001 - IP4_ROUTE_CACHE_HASH = 31, - IP4_ROUTE_CACHE_MAX = 64 // Max NO. of cache entry per hash bucket -} IP4_ROUTE_ENUM_TYPES; +#define IP4_ROUTE_CACHE_HASH_VALUE 31 +#define IP4_ROUTE_CACHE_MAX 64 // Max NO. of cache entry per hash bucket -#define IP4_ROUTE_CACHE_HASH(Dst, Src) (((Dst) ^ (Src)) % IP4_ROUTE_CACHE_HASH) +#define IP4_ROUTE_CACHE_HASH(Dst, Src) (((Dst) ^ (Src)) % IP4_ROUTE_CACHE_HASH_VALUE) /// /// The route entry in the route table. Dest/Netmask is the destion @@ -69,7 +67,7 @@ typedef struct { /// detach them later. /// typedef struct { - LIST_ENTRY CacheBucket[IP4_ROUTE_CACHE_HASH]; + LIST_ENTRY CacheBucket[IP4_ROUTE_CACHE_HASH_VALUE]; } IP4_ROUTE_CACHE; /// diff --git a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c index 06f0231e8b..229a35578a 100644 --- a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c +++ b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.c @@ -178,7 +178,7 @@ Mtftp4OverrideValid ( IP4_ADDR Gateway; CopyMem (&Ip, &Override->ServerIp, sizeof (IP4_ADDR)); - if (!Ip4IsUnicast (NTOHL (Ip), 0)) { + if (!NetIp4IsUnicast (NTOHL (Ip), 0)) { return FALSE; } @@ -194,7 +194,7 @@ Mtftp4OverrideValid ( Netmask = NTOHL (Netmask); Ip = NTOHL (Ip); - if (!Ip4IsUnicast (Gateway, Netmask) || !IP4_NET_EQUAL (Gateway, Ip, Netmask)) { + if (!NetIp4IsUnicast (Gateway, Netmask) || !IP4_NET_EQUAL (Gateway, Ip, Netmask)) { return FALSE; } } @@ -653,18 +653,18 @@ EfiMtftp4Configure ( Gateway = NTOHL (Gateway); ServerIp = NTOHL (ServerIp); - if (!Ip4IsUnicast (ServerIp, 0)) { + if (!NetIp4IsUnicast (ServerIp, 0)) { return EFI_INVALID_PARAMETER; } if (!ConfigData->UseDefaultSetting && - ((!IP4_IS_VALID_NETMASK (Netmask) || !Ip4IsUnicast (Ip, Netmask)))) { + ((!IP4_IS_VALID_NETMASK (Netmask) || !NetIp4IsUnicast (Ip, Netmask)))) { return EFI_INVALID_PARAMETER; } if ((Gateway != 0) && - (!IP4_NET_EQUAL (Gateway, Ip, Netmask) || !Ip4IsUnicast (Gateway, Netmask))) { + (!IP4_NET_EQUAL (Gateway, Ip, Netmask) || !NetIp4IsUnicast (Gateway, Netmask))) { return EFI_INVALID_PARAMETER; } diff --git a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.h b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.h index d4644c7084..a1abf6fd65 100644 --- a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.h +++ b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Impl.h @@ -48,20 +48,18 @@ typedef struct _MTFTP4_PROTOCOL MTFTP4_PROTOCOL; /// /// Some constant value of Mtftp service. /// -typedef enum { - MTFTP4_SERVICE_SIGNATURE = SIGNATURE_32 ('T', 'F', 'T', 'P'), - MTFTP4_PROTOCOL_SIGNATURE = SIGNATURE_32 ('t', 'f', 't', 'p'), - - MTFTP4_DEFAULT_SERVER_PORT = 69, - MTFTP4_DEFAULT_TIMEOUT = 3, - MTFTP4_DEFAULT_RETRY = 5, - MTFTP4_DEFAULT_BLKSIZE = 512, - MTFTP4_TIME_TO_GETMAP = 5, - - MTFTP4_STATE_UNCONFIGED = 0, - MTFTP4_STATE_CONFIGED, - MTFTP4_STATE_DESTORY -} MTFTP4_SERVICE_CONST_VALUE; +#define MTFTP4_SERVICE_SIGNATURE SIGNATURE_32 ('T', 'F', 'T', 'P') +#define MTFTP4_PROTOCOL_SIGNATURE SIGNATURE_32 ('t', 'f', 't', 'p') + +#define MTFTP4_DEFAULT_SERVER_PORT 69 +#define MTFTP4_DEFAULT_TIMEOUT 3 +#define MTFTP4_DEFAULT_RETRY 5 +#define MTFTP4_DEFAULT_BLKSIZE 512 +#define MTFTP4_TIME_TO_GETMAP 5 + +#define MTFTP4_STATE_UNCONFIGED 0 +#define MTFTP4_STATE_CONFIGED 1 +#define MTFTP4_STATE_DESTORY 2 /// /// Mtftp service block diff --git a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Option.h b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Option.h index 3e450101cd..48687c1814 100644 --- a/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Option.h +++ b/MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Option.h @@ -1,7 +1,7 @@ /** @file Routines to process MTFTP4 options. -Copyright (c) 2006 - 2007, Intel Corporation
+Copyright (c) 2006 - 2009, 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 @@ -16,20 +16,16 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #ifndef __EFI_MTFTP4_OPTION_H__ #define __EFI_MTFTP4_OPTION_H__ +#define MTFTP4_SUPPORTED_OPTIONS 4 +#define MTFTP4_OPCODE_LEN 2 +#define MTFTP4_ERRCODE_LEN 2 +#define MTFTP4_BLKNO_LEN 2 +#define MTFTP4_DATA_HEAD_LEN 4 - -typedef enum { - MTFTP4_SUPPORTED_OPTIONS = 4, - MTFTP4_OPCODE_LEN = 2, - MTFTP4_ERRCODE_LEN = 2, - MTFTP4_BLKNO_LEN = 2, - MTFTP4_DATA_HEAD_LEN = 4, - - MTFTP4_BLKSIZE_EXIST = 0x01, - MTFTP4_TIMEOUT_EXIST = 0x02, - MTFTP4_TSIZE_EXIST = 0x04, - MTFTP4_MCAST_EXIST = 0x08 -} MTFTP4_OPTION_CONST_VALUE; +#define MTFTP4_BLKSIZE_EXIST 0x01 +#define MTFTP4_TIMEOUT_EXIST 0x02 +#define MTFTP4_TSIZE_EXIST 0x04 +#define MTFTP4_MCAST_EXIST 0x08 typedef struct { UINT16 BlkSize; diff --git a/MdeModulePkg/Universal/Network/SnpDxe/Snp.h b/MdeModulePkg/Universal/Network/SnpDxe/Snp.h index 5fd0a4f06f..37de65ab05 100644 --- a/MdeModulePkg/Universal/Network/SnpDxe/Snp.h +++ b/MdeModulePkg/Universal/Network/SnpDxe/Snp.h @@ -135,13 +135,15 @@ extern EFI_COMPONENT_NAME2_PROTOCOL gSimpleNetworkComponentName2; // // Virtual to physical mapping for all UNDI 3.0s. // -typedef struct _V2P { - struct _V2P *Next; +typedef struct _V2P V2P; + +struct _V2P { + V2P *Next; VOID *VirtualAddress; UINTN BufferSize; EFI_PHYSICAL_ADDRESS PhysicalAddress; VOID *Unmap; -} V2P; +}; /** This routine maps the given CPU address to a Device address. It creates a diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.c b/MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.c index 243cb681ac..dad64ae447 100644 --- a/MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.c +++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/SockImpl.c @@ -1,7 +1,7 @@ /** @file Implementation of the Socket. -Copyright (c) 2005 - 2006, Intel Corporation
+Copyright (c) 2005 - 2009, 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 @@ -215,7 +215,7 @@ SockProcessRcvToken ( ASSERT (Sock != NULL); - ASSERT (SOCK_STREAM == Sock->Type); + ASSERT (SockStream == Sock->Type); RxData = RcvToken->Packet.RxData; @@ -481,7 +481,7 @@ SockProcessSndToken ( EFI_TCP4_TRANSMIT_DATA *TxData; EFI_STATUS Status; - ASSERT ((Sock != NULL) && (SOCK_STREAM == Sock->Type)); + ASSERT ((Sock != NULL) && (SockStream == Sock->Type)); FreeSpace = SockGetFreeSpace (Sock, SOCK_SND_BUF); @@ -557,7 +557,7 @@ SockCreate ( EFI_STATUS Status; ASSERT ((SockInitData != NULL) && (SockInitData->ProtoHandler != NULL)); - ASSERT (SockInitData->Type == SOCK_STREAM); + ASSERT (SockInitData->Type == SockStream); ASSERT ((SockInitData->ProtoData != NULL) && (SockInitData->DataSize <= PROTO_RESERVED_LEN)); Parent = SockInitData->Parent; @@ -720,7 +720,7 @@ SockDestroy ( EFI_GUID *ProtocolGuid; EFI_STATUS Status; - ASSERT (SOCK_STREAM == Sock->Type); + ASSERT (SockStream == Sock->Type); if (Sock->DestroyCallback != NULL) { Sock->DestroyCallback (Sock, Sock->Context); @@ -873,13 +873,13 @@ SockConnFlush ( Set the state of the socket. @param Sock Pointer to the socket. - @param State The new state to be set. + @param State The new socket state to be set. **/ VOID SockSetState ( IN OUT SOCKET *Sock, - IN SOCK_STATE State + IN UINT8 State ) { Sock->State = State; @@ -1070,7 +1070,7 @@ SockGetDataToSend ( IN UINT8 *Dest ) { - ASSERT ((Sock != NULL) && SOCK_STREAM == Sock->Type); + ASSERT ((Sock != NULL) && SockStream == Sock->Type); return NetbufQueCopy ( Sock->SndBuffer.DataQueue, diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/SockInterface.c b/MdeModulePkg/Universal/Network/Tcp4Dxe/SockInterface.c index 17227424a1..017d6e4328 100644 --- a/MdeModulePkg/Universal/Network/Tcp4Dxe/SockInterface.c +++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/SockInterface.c @@ -1,7 +1,7 @@ /** @file Interface function of the Socket. -Copyright (c) 2005 - 2006, Intel Corporation
+Copyright (c) 2005 - 2009, 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 @@ -397,7 +397,7 @@ SockAccept ( SOCKET *Socket; EFI_EVENT Event; - ASSERT (SOCK_STREAM == Sock->Type); + ASSERT (SockStream == Sock->Type); Status = EfiAcquireLockOrFail (&(Sock->Lock)); if (EFI_ERROR (Status)) { @@ -510,7 +510,7 @@ SockSend ( SOCK_TOKEN *SockToken; UINT32 DataLen; - ASSERT (SOCK_STREAM == Sock->Type); + ASSERT (SockStream == Sock->Type); Status = EfiAcquireLockOrFail (&(Sock->Lock)); if (EFI_ERROR (Status)) { @@ -633,7 +633,7 @@ SockRcv ( EFI_STATUS Status; EFI_EVENT Event; - ASSERT (SOCK_STREAM == Sock->Type); + ASSERT (SockStream == Sock->Type); Status = EfiAcquireLockOrFail (&(Sock->Lock)); if (EFI_ERROR (Status)) { @@ -733,7 +733,7 @@ SockFlush ( { EFI_STATUS Status; - ASSERT (SOCK_STREAM == Sock->Type); + ASSERT (SockStream == Sock->Type); Status = EfiAcquireLockOrFail (&(Sock->Lock)); if (EFI_ERROR (Status)) { @@ -798,7 +798,7 @@ SockClose ( EFI_STATUS Status; EFI_EVENT Event; - ASSERT (SOCK_STREAM == Sock->Type); + ASSERT (SockStream == Sock->Type); Status = EfiAcquireLockOrFail (&(Sock->Lock)); if (EFI_ERROR (Status)) { diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Socket.h b/MdeModulePkg/Universal/Network/Tcp4Dxe/Socket.h index a5576a5aad..e98fb62324 100644 --- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Socket.h +++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Socket.h @@ -1,7 +1,7 @@ /** @file Socket header file. -Copyright (c) 2005 - 2006, Intel Corporation
+Copyright (c) 2005 - 2009, 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 @@ -68,23 +68,19 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. /// /// Socket state /// -typedef enum { - SO_CLOSED = 0, - SO_LISTENING, - SO_CONNECTING, - SO_CONNECTED, - SO_DISCONNECTING -} SOCK_STATE; +#define SO_CLOSED 0 +#define SO_LISTENING 1 +#define SO_CONNECTING 2 +#define SO_CONNECTED 3 +#define SO_DISCONNECTING 4 /// /// Socket configure state /// -typedef enum { - SO_UNCONFIGURED = 0, - SO_CONFIGURED_ACTIVE, - SO_CONFIGURED_PASSIVE, - SO_NO_MAPPING -} SOCK_CONFIGURE_STATE; +#define SO_UNCONFIGURED 0 +#define SO_CONFIGURED_ACTIVE 1 +#define SO_CONFIGURED_PASSIVE 2 +#define SO_NO_MAPPING 3 /** Set socket SO_NO_MORE_DATA flag. @@ -331,44 +327,44 @@ typedef struct _SOCK_COMPLETION_TOKEN { EFI_STATUS Status; ///< The status to be issued } SOCK_COMPLETION_TOKEN; +typedef union { + VOID *RxData; + VOID *TxData; +} SOCK_IO_DATA; + /// /// The application token with data packet /// typedef struct _SOCK_IO_TOKEN { SOCK_COMPLETION_TOKEN Token; - union { - VOID *RxData; - VOID *TxData; - } Packet; + SOCK_IO_DATA Packet; } SOCK_IO_TOKEN; /// /// The request issued from socket layer to protocol layer. /// -typedef enum { - SOCK_ATTACH, ///< Attach current socket to a new PCB - SOCK_DETACH, ///< Detach current socket from the PCB - SOCK_CONFIGURE, ///< Configure attached PCB - SOCK_FLUSH, ///< Flush attached PCB - SOCK_SND, ///< Need protocol to send something - SOCK_SNDPUSH, ///< Need protocol to send pushed data - SOCK_SNDURG, ///< Need protocol to send urgent data - SOCK_CONSUMED, ///< Application has retrieved data from socket - SOCK_CONNECT, ///< Need to connect to a peer - SOCK_CLOSE, ///< Need to close the protocol process - SOCK_ABORT, ///< Need to reset the protocol process - SOCK_POLL, ///< Need to poll to the protocol layer - SOCK_ROUTE, ///< Need to add a route information - SOCK_MODE, ///< Need to get the mode data of the protocol - SOCK_GROUP ///< Need to join a mcast group -} SOCK_REQUEST; +#define SOCK_ATTACH 0 ///< Attach current socket to a new PCB +#define SOCK_DETACH 1 ///< Detach current socket from the PCB +#define SOCK_CONFIGURE 2 ///< Configure attached PCB +#define SOCK_FLUSH 3 ///< Flush attached PCB +#define SOCK_SND 4 ///< Need protocol to send something +#define SOCK_SNDPUSH 5 ///< Need protocol to send pushed data +#define SOCK_SNDURG 6 ///< Need protocol to send urgent data +#define SOCK_CONSUMED 7 ///< Application has retrieved data from socket +#define SOCK_CONNECT 8 ///< Need to connect to a peer +#define SOCK_CLOSE 9 ///< Need to close the protocol process +#define SOCK_ABORT 10 ///< Need to reset the protocol process +#define SOCK_POLL 11 ///< Need to poll to the protocol layer +#define SOCK_ROUTE 12 ///< Need to add a route information +#define SOCK_MODE 13 ///< Need to get the mode data of the protocol +#define SOCK_GROUP 14 ///< Need to join a mcast group /// /// The socket type. /// typedef enum { - SOCK_DGRAM, ///< This socket providing datagram service - SOCK_STREAM ///< This socket providing stream service + SockDgram, ///< This socket providing datagram service + SockStream ///< This socket providing stream service } SOCK_TYPE; /// @@ -396,7 +392,7 @@ typedef EFI_STATUS (*SOCK_PROTO_HANDLER) ( IN SOCKET *Socket, - IN SOCK_REQUEST Request, + IN UINT8 Request, IN VOID *RequestData ); @@ -413,13 +409,13 @@ EFI_STATUS Set the state of the socket. @param Sock Pointer to the socket. - @param State The new state to be set. + @param State The new socket state to be set. **/ VOID SockSetState ( IN OUT SOCKET *Sock, - IN SOCK_STATE State + IN UINT8 State ); /** @@ -592,7 +588,7 @@ VOID /// typedef struct _SOCK_INIT_DATA { SOCK_TYPE Type; - SOCK_STATE State; + UINT8 State; SOCKET *Parent; ///< The parent of this socket UINT32 BackLog; ///< The connection limit for listening socket @@ -641,9 +637,9 @@ struct _SOCKET { EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath; EFI_DEVICE_PATH_PROTOCOL *DevicePath; LIST_ENTRY Link; - SOCK_CONFIGURE_STATE ConfigureState; + UINT8 ConfigureState; SOCK_TYPE Type; - SOCK_STATE State; + UINT8 State; UINT16 Flag; EFI_LOCK Lock; ///< The lock of socket SOCK_BUFFER SndBuffer; ///< Send buffer of application's data diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dispatcher.c b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dispatcher.c index a6acd267ef..fb224f4ad3 100644 --- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dispatcher.c +++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dispatcher.c @@ -592,7 +592,7 @@ OnExit: EFI_STATUS Tcp4Dispatcher ( IN SOCKET *Sock, - IN SOCK_REQUEST Request, + IN UINT8 Request, IN VOID *Data OPTIONAL ) { diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.c b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.c index cffd53e9a8..f48eb8c096 100644 --- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.c +++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.c @@ -38,8 +38,8 @@ EFI_TCP4_PROTOCOL mTcp4ProtocolTemplate = { }; SOCK_INIT_DATA mTcp4DefaultSockData = { - SOCK_STREAM, - (SOCK_STATE) 0, + SockStream, + 0, NULL, TCP_BACKLOG, TCP_SND_BUF_SIZE, diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.h b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.h index f43043758e..c744870d57 100644 --- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.h +++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Driver.h @@ -122,7 +122,7 @@ TcpSendIpPacket ( EFI_STATUS Tcp4Dispatcher ( IN SOCKET *Sock, - IN SOCK_REQUEST Request, + IN UINT8 Request, IN VOID *Data OPTIONAL ); diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Main.c b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Main.c index 25ca2101a8..8339189aca 100644 --- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Main.c +++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Main.c @@ -1,7 +1,7 @@ /** @file Implementation of TCP4 protocol services. -Copyright (c) 2005 - 2006, Intel Corporation
+Copyright (c) 2005 - 2009, 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 @@ -170,7 +170,7 @@ Tcp4Configure ( if (NULL != TcpConfigData) { CopyMem (&Ip, &TcpConfigData->AccessPoint.RemoteAddress, sizeof (IP4_ADDR)); - if ((Ip != 0) && !Ip4IsUnicast (NTOHL (Ip), 0)) { + if ((Ip != 0) && !NetIp4IsUnicast (NTOHL (Ip), 0)) { return EFI_INVALID_PARAMETER; } @@ -183,7 +183,7 @@ Tcp4Configure ( CopyMem (&Ip, &TcpConfigData->AccessPoint.StationAddress, sizeof (IP4_ADDR)); CopyMem (&SubnetMask, &TcpConfigData->AccessPoint.SubnetMask, sizeof (IP4_ADDR)); - if (!Ip4IsUnicast (NTOHL (Ip), 0) || !IP4_IS_VALID_NETMASK (NTOHL (SubnetMask))) { + if (!NetIp4IsUnicast (NTOHL (Ip), 0) || !IP4_IS_VALID_NETMASK (NTOHL (SubnetMask))) { return EFI_INVALID_PARAMETER; } } diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Main.h b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Main.h index 763789e410..af44042ff4 100644 --- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Main.h +++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Main.h @@ -1,7 +1,7 @@ /** @file TCP4 protocol services header file. -Copyright (c) 2005 - 2006, Intel Corporation
+Copyright (c) 2005 - 2009, 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 @@ -50,7 +50,7 @@ extern CHAR16 *mTcpStateName[]; EFI_STATUS Tcp4Dispatcher ( IN SOCKET *Sock, - IN SOCK_REQUEST Request, + IN UINT8 Request, IN VOID *Data OPTIONAL ); diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Option.h b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Option.h index 243def839a..e7da405796 100644 --- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Option.h +++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Option.h @@ -1,7 +1,7 @@ /** @file Tcp option's routine header file. -Copyright (c) 2005 - 2006, Intel Corporation
+Copyright (c) 2005 - 2009, 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 @@ -27,47 +27,44 @@ typedef struct _TCP_OPTION { UINT32 TSEcr; ///< The TSEcr field in a timestamp option } TCP_OPTION; -typedef enum { - - // - // supported TCP option type and their length - // - TCP_OPTION_EOP = 0, ///< End Of oPtion - TCP_OPTION_NOP = 1, ///< No-Option. - TCP_OPTION_MSS = 2, ///< Maximum Segment Size - TCP_OPTION_WS = 3, ///< Window scale - TCP_OPTION_TS = 8, ///< Timestamp - TCP_OPTION_MSS_LEN = 4, ///< Length of MSS option - TCP_OPTION_WS_LEN = 3, ///< Length of window scale option - TCP_OPTION_TS_LEN = 10, ///< Length of timestamp option - TCP_OPTION_WS_ALIGNED_LEN = 4, ///< Length of window scale option, aligned - TCP_OPTION_TS_ALIGNED_LEN = 12, ///< Length of timestamp option, aligned - - // - // recommend format of timestamp window scale - // option for fast process. - // - TCP_OPTION_TS_FAST = ((TCP_OPTION_NOP << 24) | - (TCP_OPTION_NOP << 16) | - (TCP_OPTION_TS << 8) | - TCP_OPTION_TS_LEN), - - TCP_OPTION_WS_FAST = ((TCP_OPTION_NOP << 24) | - (TCP_OPTION_WS << 16) | - (TCP_OPTION_WS_LEN << 8)), - - TCP_OPTION_MSS_FAST = ((TCP_OPTION_MSS << 24) | - (TCP_OPTION_MSS_LEN << 16)), - - // - // Other misc definations - // - TCP_OPTION_RCVD_MSS = 0x01, - TCP_OPTION_RCVD_WS = 0x02, - TCP_OPTION_RCVD_TS = 0x04, - TCP_OPTION_MAX_WS = 14, ///< Maxium window scale value - TCP_OPTION_MAX_WIN = 0xffff ///< Max window size in TCP header -} TCP_OPTION_TYPE; +// +// supported TCP option type and their length +// +#define TCP_OPTION_EOP 0 ///< End Of oPtion +#define TCP_OPTION_NOP 1 ///< No-Option. +#define TCP_OPTION_MSS 2 ///< Maximum Segment Size +#define TCP_OPTION_WS 3 ///< Window scale +#define TCP_OPTION_TS 8 ///< Timestamp +#define TCP_OPTION_MSS_LEN 4 ///< Length of MSS option +#define TCP_OPTION_WS_LEN 3 ///< Length of window scale option +#define TCP_OPTION_TS_LEN 10 ///< Length of timestamp option +#define TCP_OPTION_WS_ALIGNED_LEN 4 ///< Length of window scale option, aligned +#define TCP_OPTION_TS_ALIGNED_LEN 12 ///< Length of timestamp option, aligned + +// +// recommend format of timestamp window scale +// option for fast process. +// +#define TCP_OPTION_TS_FAST ((TCP_OPTION_NOP << 24) | \ + (TCP_OPTION_NOP << 16) | \ + (TCP_OPTION_TS << 8) | \ + (TCP_OPTION_TS_LEN)) + +#define TCP_OPTION_WS_FAST ((TCP_OPTION_NOP << 24) | \ + (TCP_OPTION_WS << 16) | \ + (TCP_OPTION_WS_LEN << 8)) + +#define TCP_OPTION_MSS_FAST ((TCP_OPTION_MSS << 24) | (TCP_OPTION_MSS_LEN << 16)) + +// +// Other misc definations +// +#define TCP_OPTION_RCVD_MSS 0x01 +#define TCP_OPTION_RCVD_WS 0x02 +#define TCP_OPTION_RCVD_TS 0x04 +#define TCP_OPTION_MAX_WS 14 ///< Maxium window scale value +#define TCP_OPTION_MAX_WIN 0xffff ///< Max window size in TCP header + /** Compute the window scale value according to the given buffer size. diff --git a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Proto.h b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Proto.h index 78d2eb3799..da88bff194 100644 --- a/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Proto.h +++ b/MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Proto.h @@ -1,7 +1,7 @@ /** @file Tcp Protocol header file. -Copyright (c) 2005 - 2006, Intel Corporation
+Copyright (c) 2005 - 2009, 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 @@ -27,122 +27,116 @@ typedef struct _TCP_CB TCP_CB; /// Tcp states, Don't change their order, it is used as /// index to mTcpOutFlag and other macros /// -typedef enum { - TCP_CLOSED = 0, - TCP_LISTEN, - TCP_SYN_SENT, - TCP_SYN_RCVD, - TCP_ESTABLISHED, - TCP_FIN_WAIT_1, - TCP_FIN_WAIT_2, - TCP_CLOSING, - TCP_TIME_WAIT, - TCP_CLOSE_WAIT, - TCP_LAST_ACK -} TCP_STATES; +#define TCP_CLOSED 0 +#define TCP_LISTEN 1 +#define TCP_SYN_SENT 2 +#define TCP_SYN_RCVD 3 +#define TCP_ESTABLISHED 4 +#define TCP_FIN_WAIT_1 5 +#define TCP_FIN_WAIT_2 6 +#define TCP_CLOSING 7 +#define TCP_TIME_WAIT 8 +#define TCP_CLOSE_WAIT 9 +#define TCP_LAST_ACK 10 + /// /// Flags in the TCP header /// -typedef enum { - - TCP_FLG_FIN = 0x01, - TCP_FLG_SYN = 0x02, - TCP_FLG_RST = 0x04, - TCP_FLG_PSH = 0x08, - TCP_FLG_ACK = 0x10, - TCP_FLG_URG = 0x20, - - // - // mask for all the flags - // - TCP_FLG_FLAG = 0x3F -} TCP_HEADER_FLAG; - -typedef enum { +#define TCP_FLG_FIN 0x01 +#define TCP_FLG_SYN 0x02 +#define TCP_FLG_RST 0x04 +#define TCP_FLG_PSH 0x08 +#define TCP_FLG_ACK 0x10 +#define TCP_FLG_URG 0x20 + + // + // mask for all the flags + // +#define TCP_FLG_FLAG 0x3F + + +#define TCP_CONNECT_REFUSED (-1) ///< TCP error status +#define TCP_CONNECT_RESET (-2) ///< TCP error status +#define TCP_CONNECT_CLOSED (-3) ///< TCP error status - TCP_CONNECT_REFUSED = -1, ///< TCP error status - TCP_CONNECT_RESET = -2, ///< TCP error status - TCP_CONNECT_CLOSED = -3, ///< TCP error status - - // - // Current congestion status as suggested by RFC3782. - // - TCP_CONGEST_RECOVER = 1, ///< During the NewReno fast recovery - TCP_CONGEST_LOSS = 2, ///< Retxmit because of retxmit time out - TCP_CONGEST_OPEN = 3, ///< TCP is opening its congestion window +// +// Current congestion status as suggested by RFC3782. +// +#define TCP_CONGEST_RECOVER 1 ///< During the NewReno fast recovery +#define TCP_CONGEST_LOSS 2 ///< Retxmit because of retxmit time out +#define TCP_CONGEST_OPEN 3 ///< TCP is opening its congestion window - // - // TCP control flags - // - TCP_CTRL_NO_NAGLE = 0x0001, ///< Disable Nagle algorithm - TCP_CTRL_NO_KEEPALIVE = 0x0002, ///< Disable keepalive timer - TCP_CTRL_NO_WS = 0x0004, ///< Disable window scale option - TCP_CTRL_RCVD_WS = 0x0008, ///< Received a wnd scale option in syn - TCP_CTRL_NO_TS = 0x0010, ///< Disable Timestamp option - TCP_CTRL_RCVD_TS = 0x0020, ///< Received a Timestamp option in syn - TCP_CTRL_SND_TS = 0x0040, ///< Send Timestamp option to remote - TCP_CTRL_SND_URG = 0x0080, ///< In urgent send mode - TCP_CTRL_RCVD_URG = 0x0100, ///< In urgent receive mode - TCP_CTRL_SND_PSH = 0x0200, ///< In PUSH send mode - TCP_CTRL_FIN_SENT = 0x0400, ///< FIN is sent - TCP_CTRL_FIN_ACKED = 0x0800, ///< FIN is ACKed. - TCP_CTRL_TIMER_ON = 0x1000, ///< At least one of the timer is on - TCP_CTRL_RTT_ON = 0x2000, ///< The RTT measurement is on - TCP_CTRL_ACK_NOW = 0x4000, ///< Send the ACK now, don't delay +// +// TCP control flags +// +#define TCP_CTRL_NO_NAGLE 0x0001 ///< Disable Nagle algorithm +#define TCP_CTRL_NO_KEEPALIVE 0x0002 ///< Disable keepalive timer +#define TCP_CTRL_NO_WS 0x0004 ///< Disable window scale option +#define TCP_CTRL_RCVD_WS 0x0008 ///< Received a wnd scale option in syn +#define TCP_CTRL_NO_TS 0x0010 ///< Disable Timestamp option +#define TCP_CTRL_RCVD_TS 0x0020 ///< Received a Timestamp option in syn +#define TCP_CTRL_SND_TS 0x0040 ///< Send Timestamp option to remote +#define TCP_CTRL_SND_URG 0x0080 ///< In urgent send mode +#define TCP_CTRL_RCVD_URG 0x0100 ///< In urgent receive mode +#define TCP_CTRL_SND_PSH 0x0200 ///< In PUSH send mode +#define TCP_CTRL_FIN_SENT 0x0400 ///< FIN is sent +#define TCP_CTRL_FIN_ACKED 0x0800 ///< FIN is ACKed. +#define TCP_CTRL_TIMER_ON 0x1000 ///< At least one of the timer is on +#define TCP_CTRL_RTT_ON 0x2000 ///< The RTT measurement is on +#define TCP_CTRL_ACK_NOW 0x4000 ///< Send the ACK now, don't delay - // - // Timer related values - // - TCP_TIMER_CONNECT = 0, ///< Connection establishment timer - TCP_TIMER_REXMIT = 1, ///< Retransmit timer - TCP_TIMER_PROBE = 2, ///< Window probe timer - TCP_TIMER_KEEPALIVE = 3, ///< Keepalive timer - TCP_TIMER_FINWAIT2 = 4, ///< FIN_WAIT_2 timer - TCP_TIMER_2MSL = 5, ///< TIME_WAIT tiemr - TCP_TIMER_NUMBER = 6, ///< The total number of TCP timer. - TCP_TICK = 200, ///< Every TCP tick is 200ms - TCP_TICK_HZ = 5, ///< The frequence of TCP tick - TCP_RTT_SHIFT = 3, ///< SRTT & RTTVAR scaled by 8 - TCP_RTO_MIN = TCP_TICK_HZ, ///< The minium value of RTO - TCP_RTO_MAX = (TCP_TICK_HZ * 60), ///< The maxium value of RTO - TCP_FOLD_RTT = 4, ///< Timeout threshod to fold RTT +// +// Timer related values +// +#define TCP_TIMER_CONNECT 0 ///< Connection establishment timer +#define TCP_TIMER_REXMIT 1 ///< Retransmit timer +#define TCP_TIMER_PROBE 2 ///< Window probe timer +#define TCP_TIMER_KEEPALIVE 3 ///< Keepalive timer +#define TCP_TIMER_FINWAIT2 4 ///< FIN_WAIT_2 timer +#define TCP_TIMER_2MSL 5 ///< TIME_WAIT tiemr +#define TCP_TIMER_NUMBER 6 ///< The total number of TCP timer. +#define TCP_TICK 200 ///< Every TCP tick is 200ms +#define TCP_TICK_HZ 5 ///< The frequence of TCP tick +#define TCP_RTT_SHIFT 3 ///< SRTT & RTTVAR scaled by 8 +#define TCP_RTO_MIN TCP_TICK_HZ ///< The minium value of RTO +#define TCP_RTO_MAX (TCP_TICK_HZ * 60) ///< The maxium value of RTO +#define TCP_FOLD_RTT 4 ///< Timeout threshod to fold RTT - // - // Default values for some timers - // - TCP_MAX_LOSS = 12, ///< Default max times to retxmit - TCP_KEEPALIVE_IDLE_MIN = (TCP_TICK_HZ * 60 * 60 * 2), ///< First keep alive - TCP_KEEPALIVE_PERIOD = (TCP_TICK_HZ * 60), - TCP_MAX_KEEPALIVE = 8, - TCP_FIN_WAIT2_TIME = (2 * TCP_TICK_HZ), - TCP_TIME_WAIT_TIME = (2 * TCP_TICK_HZ), - TCP_PAWS_24DAY = (24 * 24 * 60 * 60 * TCP_TICK_HZ), - TCP_CONNECT_TIME = (75 * TCP_TICK_HZ), +// +// Default values for some timers +// +#define TCP_MAX_LOSS 12 ///< Default max times to retxmit +#define TCP_KEEPALIVE_IDLE_MIN (TCP_TICK_HZ * 60 * 60 * 2) ///< First keep alive +#define TCP_KEEPALIVE_PERIOD (TCP_TICK_HZ * 60) +#define TCP_MAX_KEEPALIVE 8 +#define TCP_FIN_WAIT2_TIME (2 * TCP_TICK_HZ) +#define TCP_TIME_WAIT_TIME (2 * TCP_TICK_HZ) +#define TCP_PAWS_24DAY (24 * 24 * 60 * 60 * TCP_TICK_HZ) +#define TCP_CONNECT_TIME (75 * TCP_TICK_HZ) - // - // The header space to be reserved before TCP data to accomodate : - // 60byte IP head + 60byte TCP head + link layer head - // - TCP_MAX_HEAD = 192, +// +// The header space to be reserved before TCP data to accomodate : +// 60byte IP head + 60byte TCP head + link layer head +// +#define TCP_MAX_HEAD 192 - // - // Value ranges for some control option - // - TCP_RCV_BUF_SIZE = (2 * 1024 * 1024), - TCP_RCV_BUF_SIZE_MIN = (8 * 1024), - TCP_SND_BUF_SIZE = (2 * 1024 * 1024), - TCP_SND_BUF_SIZE_MIN = (8 * 1024), - TCP_BACKLOG = 10, - TCP_BACKLOG_MIN = 5, - TCP_MAX_LOSS_MIN = 6, - TCP_CONNECT_TIME_MIN = (60 * TCP_TICK_HZ), - TCP_MAX_KEEPALIVE_MIN = 4, - TCP_KEEPALIVE_IDLE_MAX = (TCP_TICK_HZ * 60 * 60 * 4), - TCP_KEEPALIVE_PERIOD_MIN= (TCP_TICK_HZ * 30), - TCP_FIN_WAIT2_TIME_MAX = (4 * TCP_TICK_HZ), - TCP_TIME_WAIT_TIME_MAX = (60 * TCP_TICK_HZ) -} TCP_MISC_VALUES; +// +// Value ranges for some control option +// +#define TCP_RCV_BUF_SIZE (2 * 1024 * 1024) +#define TCP_RCV_BUF_SIZE_MIN (8 * 1024) +#define TCP_SND_BUF_SIZE (2 * 1024 * 1024) +#define TCP_SND_BUF_SIZE_MIN (8 * 1024) +#define TCP_BACKLOG 10 +#define TCP_BACKLOG_MIN 5 +#define TCP_MAX_LOSS_MIN 6 +#define TCP_CONNECT_TIME_MIN (60 * TCP_TICK_HZ) +#define TCP_MAX_KEEPALIVE_MIN 4 +#define TCP_KEEPALIVE_IDLE_MAX (TCP_TICK_HZ * 60 * 60 * 4) +#define TCP_KEEPALIVE_PERIOD_MIN (TCP_TICK_HZ * 30) +#define TCP_FIN_WAIT2_TIME_MAX (4 * TCP_TICK_HZ) +#define TCP_TIME_WAIT_TIME_MAX (60 * TCP_TICK_HZ) /// /// TCP segmentation data diff --git a/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.c b/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.c index c923117a1c..3c0e65f717 100644 --- a/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.c +++ b/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.c @@ -824,7 +824,7 @@ Udp4ValidateTxToken ( if (TxData->GatewayAddress != NULL) { CopyMem (&GatewayAddress, TxData->GatewayAddress, sizeof (IP4_ADDR)); - if (!Ip4IsUnicast (NTOHL (GatewayAddress), 0)) { + if (!NetIp4IsUnicast (NTOHL (GatewayAddress), 0)) { // // The specified GatewayAddress is not a unicast IPv4 address while it's not 0. // @@ -839,7 +839,7 @@ Udp4ValidateTxToken ( CopyMem (&SourceAddress, &UdpSessionData->SourceAddress, sizeof (IP4_ADDR)); - if ((SourceAddress != 0) && !Ip4IsUnicast (HTONL (SourceAddress), 0)) { + if ((SourceAddress != 0) && !NetIp4IsUnicast (HTONL (SourceAddress), 0)) { // // Check whether SourceAddress is a valid IPv4 address in case it's not zero. // The configured station address is used if SourceAddress is zero. diff --git a/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Main.c b/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Main.c index 582d6f6d44..5002f6f17f 100644 --- a/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Main.c +++ b/MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Main.c @@ -171,8 +171,8 @@ Udp4Configure ( if (!UdpConfigData->UseDefaultAddress && (!IP4_IS_VALID_NETMASK (SubnetMask) || - !((StationAddress == 0) || Ip4IsUnicast (StationAddress, SubnetMask)) || - !((RemoteAddress == 0) || Ip4IsUnicast (RemoteAddress, 0)))) { + !((StationAddress == 0) || NetIp4IsUnicast (StationAddress, SubnetMask)) || + !((RemoteAddress == 0) || NetIp4IsUnicast (RemoteAddress, 0)))) { // // Don't use default address, and subnet mask is invalid or StationAddress is not // a valid unicast IPv4 address or RemoteAddress is not a valid unicast IPv4 address diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.h b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.h index 103ae2f57d..829caa8bbf 100644 --- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.h +++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.h @@ -15,115 +15,109 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #ifndef __EFI_PXEBC_DHCP_H__ #define __EFI_PXEBC_DHCP_H__ -typedef enum { - PXEBC_DHCP4_MAX_OPTION_NUM = 16, - PXEBC_DHCP4_MAX_OPTION_SIZE = 312, - PXEBC_DHCP4_MAX_PACKET_SIZE = 1472, - - PXEBC_DHCP4_S_PORT = 67, - PXEBC_DHCP4_C_PORT = 68, - PXEBC_BS_DOWNLOAD_PORT = 69, - PXEBC_BS_DISCOVER_PORT = 4011, - - PXEBC_DHCP4_OPCODE_REQUEST = 1, - PXEBC_DHCP4_OPCODE_REPLY = 2, - PXEBC_DHCP4_MSG_TYPE_REQUEST = 3, - PXEBC_DHCP4_MAGIC = 0x63538263, // network byte order - // - // Dhcp Options - // - PXEBC_DHCP4_TAG_PAD = 0, // Pad Option - PXEBC_DHCP4_TAG_EOP = 255, // End Option - PXEBC_DHCP4_TAG_NETMASK = 1, // Subnet Mask - PXEBC_DHCP4_TAG_TIME_OFFSET = 2, // Time Offset from UTC - PXEBC_DHCP4_TAG_ROUTER = 3, // Router option, - PXEBC_DHCP4_TAG_TIME_SERVER = 4, // Time Server - PXEBC_DHCP4_TAG_NAME_SERVER = 5, // Name Server - PXEBC_DHCP4_TAG_DNS_SERVER = 6, // Domain Name Server - PXEBC_DHCP4_TAG_HOSTNAME = 12, // Host Name - PXEBC_DHCP4_TAG_BOOTFILE_LEN = 13, // Boot File Size - PXEBC_DHCP4_TAG_DUMP = 14, // Merit Dump File - PXEBC_DHCP4_TAG_DOMAINNAME = 15, // Domain Name - PXEBC_DHCP4_TAG_ROOTPATH = 17, // Root path - PXEBC_DHCP4_TAG_EXTEND_PATH = 18, // Extensions Path - PXEBC_DHCP4_TAG_EMTU = 22, // Maximum Datagram Reassembly Size - PXEBC_DHCP4_TAG_TTL = 23, // Default IP Time-to-live - PXEBC_DHCP4_TAG_BROADCAST = 28, // Broadcast Address - PXEBC_DHCP4_TAG_NIS_DOMAIN = 40, // Network Information Service Domain - PXEBC_DHCP4_TAG_NIS_SERVER = 41, // Network Information Servers - PXEBC_DHCP4_TAG_NTP_SERVER = 42, // Network Time Protocol Servers - PXEBC_DHCP4_TAG_VENDOR = 43, // Vendor Specific Information - PXEBC_DHCP4_TAG_REQUEST_IP = 50, // Requested IP Address - PXEBC_DHCP4_TAG_LEASE = 51, // IP Address Lease Time - PXEBC_DHCP4_TAG_OVERLOAD = 52, // Option Overload - PXEBC_DHCP4_TAG_MSG_TYPE = 53, // DHCP Message Type - PXEBC_DHCP4_TAG_SERVER_ID = 54, // Server Identifier - PXEBC_DHCP4_TAG_PARA_LIST = 55, // Parameter Request List - PXEBC_DHCP4_TAG_MAXMSG = 57, // Maximum DHCP Message Size - PXEBC_DHCP4_TAG_T1 = 58, // Renewal (T1) Time Value - PXEBC_DHCP4_TAG_T2 = 59, // Rebinding (T2) Time Value - PXEBC_DHCP4_TAG_CLASS_ID = 60, // Vendor class identifier - PXEBC_DHCP4_TAG_CLIENT_ID = 61, // Client-identifier - PXEBC_DHCP4_TAG_TFTP = 66, // TFTP server name - PXEBC_DHCP4_TAG_BOOTFILE = 67, // Bootfile name - PXEBC_PXE_DHCP4_TAG_ARCH = 93, - PXEBC_PXE_DHCP4_TAG_UNDI = 94, - PXEBC_PXE_DHCP4_TAG_UUID = 97, - // - // Sub-Options in Dhcp Vendor Option - // - PXEBC_VENDOR_TAG_MTFTP_IP = 1, - PXEBC_VENDOR_TAG_MTFTP_CPORT = 2, - PXEBC_VENDOR_TAG_MTFTP_SPORT = 3, - PXEBC_VENDOR_TAG_MTFTP_TIMEOUT = 4, - PXEBC_VENDOR_TAG_MTFTP_DELAY = 5, - PXEBC_VENDOR_TAG_DISCOVER_CTRL = 6, - PXEBC_VENDOR_TAG_DISCOVER_MCAST = 7, - PXEBC_VENDOR_TAG_BOOT_SERVERS = 8, - PXEBC_VENDOR_TAG_BOOT_MENU = 9, - PXEBC_VENDOR_TAG_MENU_PROMPT = 10, - PXEBC_VENDOR_TAG_MCAST_ALLOC = 11, - PXEBC_VENDOR_TAG_CREDENTIAL_TYPES = 12, - PXEBC_VENDOR_TAG_BOOT_ITEM = 71, - - PXEBC_DHCP4_DISCOVER_INIT_TIMEOUT = 4, - PXEBC_DHCP4_DISCOVER_RETRIES = 4, - - PXEBC_MAX_MENU_NUM = 24, - PXEBC_MAX_OFFER_NUM = 16, - - PXEBC_BOOT_REQUEST_TIMEOUT = 1, - PXEBC_BOOT_REQUEST_RETRIES = 4, - - PXEBC_DHCP4_OVERLOAD_FILE = 1, - PXEBC_DHCP4_OVERLOAD_SERVER_NAME = 2 -} PXEBC_ENUM_TYPES; +#define PXEBC_DHCP4_MAX_OPTION_NUM 16 +#define PXEBC_DHCP4_MAX_OPTION_SIZE 312 +#define PXEBC_DHCP4_MAX_PACKET_SIZE 1472 + +#define PXEBC_DHCP4_S_PORT 67 +#define PXEBC_DHCP4_C_PORT 68 +#define PXEBC_BS_DOWNLOAD_PORT 69 +#define PXEBC_BS_DISCOVER_PORT 4011 + +#define PXEBC_DHCP4_OPCODE_REQUEST 1 +#define PXEBC_DHCP4_OPCODE_REPLY 2 +#define PXEBC_DHCP4_MSG_TYPE_REQUEST 3 +#define PXEBC_DHCP4_MAGIC 0x63538263 // network byte order +// +// Dhcp Options +// +#define PXEBC_DHCP4_TAG_PAD 0 // Pad Option +#define PXEBC_DHCP4_TAG_EOP 255 // End Option +#define PXEBC_DHCP4_TAG_NETMASK 1 // Subnet Mask +#define PXEBC_DHCP4_TAG_TIME_OFFSET 2 // Time Offset from UTC +#define PXEBC_DHCP4_TAG_ROUTER 3 // Router option, +#define PXEBC_DHCP4_TAG_TIME_SERVER 4 // Time Server +#define PXEBC_DHCP4_TAG_NAME_SERVER 5 // Name Server +#define PXEBC_DHCP4_TAG_DNS_SERVER 6 // Domain Name Server +#define PXEBC_DHCP4_TAG_HOSTNAME 12 // Host Name +#define PXEBC_DHCP4_TAG_BOOTFILE_LEN 13 // Boot File Size +#define PXEBC_DHCP4_TAG_DUMP 14 // Merit Dump File +#define PXEBC_DHCP4_TAG_DOMAINNAME 15 // Domain Name +#define PXEBC_DHCP4_TAG_ROOTPATH 17 // Root path +#define PXEBC_DHCP4_TAG_EXTEND_PATH 18 // Extensions Path +#define PXEBC_DHCP4_TAG_EMTU 22 // Maximum Datagram Reassembly Size +#define PXEBC_DHCP4_TAG_TTL 23 // Default IP Time-to-live +#define PXEBC_DHCP4_TAG_BROADCAST 28 // Broadcast Address +#define PXEBC_DHCP4_TAG_NIS_DOMAIN 40 // Network Information Service Domain +#define PXEBC_DHCP4_TAG_NIS_SERVER 41 // Network Information Servers +#define PXEBC_DHCP4_TAG_NTP_SERVER 42 // Network Time Protocol Servers +#define PXEBC_DHCP4_TAG_VENDOR 43 // Vendor Specific Information +#define PXEBC_DHCP4_TAG_REQUEST_IP 50 // Requested IP Address +#define PXEBC_DHCP4_TAG_LEASE 51 // IP Address Lease Time +#define PXEBC_DHCP4_TAG_OVERLOAD 52 // Option Overload +#define PXEBC_DHCP4_TAG_MSG_TYPE 53 // DHCP Message Type +#define PXEBC_DHCP4_TAG_SERVER_ID 54 // Server Identifier +#define PXEBC_DHCP4_TAG_PARA_LIST 55 // Parameter Request List +#define PXEBC_DHCP4_TAG_MAXMSG 57 // Maximum DHCP Message Size +#define PXEBC_DHCP4_TAG_T1 58 // Renewal (T1) Time Value +#define PXEBC_DHCP4_TAG_T2 59 // Rebinding (T2) Time Value +#define PXEBC_DHCP4_TAG_CLASS_ID 60 // Vendor class identifier +#define PXEBC_DHCP4_TAG_CLIENT_ID 61 // Client-identifier +#define PXEBC_DHCP4_TAG_TFTP 66 // TFTP server name +#define PXEBC_DHCP4_TAG_BOOTFILE 67 // Bootfile name +#define PXEBC_PXE_DHCP4_TAG_ARCH 93 +#define PXEBC_PXE_DHCP4_TAG_UNDI 94 +#define PXEBC_PXE_DHCP4_TAG_UUID 97 +// +// Sub-Options in Dhcp Vendor Option +// +#define PXEBC_VENDOR_TAG_MTFTP_IP 1 +#define PXEBC_VENDOR_TAG_MTFTP_CPORT 2 +#define PXEBC_VENDOR_TAG_MTFTP_SPORT 3 +#define PXEBC_VENDOR_TAG_MTFTP_TIMEOUT 4 +#define PXEBC_VENDOR_TAG_MTFTP_DELAY 5 +#define PXEBC_VENDOR_TAG_DISCOVER_CTRL 6 +#define PXEBC_VENDOR_TAG_DISCOVER_MCAST 7 +#define PXEBC_VENDOR_TAG_BOOT_SERVERS 8 +#define PXEBC_VENDOR_TAG_BOOT_MENU 9 +#define PXEBC_VENDOR_TAG_MENU_PROMPT 10 +#define PXEBC_VENDOR_TAG_MCAST_ALLOC 11 +#define PXEBC_VENDOR_TAG_CREDENTIAL_TYPES 12 +#define PXEBC_VENDOR_TAG_BOOT_ITEM 71 + +#define PXEBC_DHCP4_DISCOVER_INIT_TIMEOUT 4 +#define PXEBC_DHCP4_DISCOVER_RETRIES 4 + +#define PXEBC_MAX_MENU_NUM 24 +#define PXEBC_MAX_OFFER_NUM 16 + +#define PXEBC_BOOT_REQUEST_TIMEOUT 1 +#define PXEBC_BOOT_REQUEST_RETRIES 4 + +#define PXEBC_DHCP4_OVERLOAD_FILE 1 +#define PXEBC_DHCP4_OVERLOAD_SERVER_NAME 2 // // The array index of the DHCP4 option tag interested // -typedef enum { - PXEBC_DHCP4_TAG_INDEX_BOOTFILE_LEN, - PXEBC_DHCP4_TAG_INDEX_VENDOR, - PXEBC_DHCP4_TAG_INDEX_OVERLOAD, - PXEBC_DHCP4_TAG_INDEX_MSG_TYPE, - PXEBC_DHCP4_TAG_INDEX_SERVER_ID, - PXEBC_DHCP4_TAG_INDEX_CLASS_ID, - PXEBC_DHCP4_TAG_INDEX_BOOTFILE, - PXEBC_DHCP4_TAG_INDEX_MAX -} PXEBC_DHCP4_TAG_INDEX_ENUM_TYPES; +#define PXEBC_DHCP4_TAG_INDEX_BOOTFILE_LEN 0 +#define PXEBC_DHCP4_TAG_INDEX_VENDOR 1 +#define PXEBC_DHCP4_TAG_INDEX_OVERLOAD 2 +#define PXEBC_DHCP4_TAG_INDEX_MSG_TYPE 3 +#define PXEBC_DHCP4_TAG_INDEX_SERVER_ID 4 +#define PXEBC_DHCP4_TAG_INDEX_CLASS_ID 5 +#define PXEBC_DHCP4_TAG_INDEX_BOOTFILE 6 +#define PXEBC_DHCP4_TAG_INDEX_MAX 7 // // The type of DHCP OFFER, arranged by priority, PXE10 has the highest priority. // -typedef enum { - DHCP4_PACKET_TYPE_PXE10, - DHCP4_PACKET_TYPE_WFM11A, - DHCP4_PACKET_TYPE_BINL, - DHCP4_PACKET_TYPE_DHCP_ONLY, - DHCP4_PACKET_TYPE_MAX, - DHCP4_PACKET_TYPE_BOOTP = DHCP4_PACKET_TYPE_MAX -} DHCP4_PACKET_TYPE_ENUM_TYPES; +#define DHCP4_PACKET_TYPE_PXE10 0 +#define DHCP4_PACKET_TYPE_WFM11A 1 +#define DHCP4_PACKET_TYPE_BINL 2 +#define DHCP4_PACKET_TYPE_DHCP_ONLY 3 +#define DHCP4_PACKET_TYPE_MAX 4 +#define DHCP4_PACKET_TYPE_BOOTP DHCP4_PACKET_TYPE_MAX #define BIT(x) (1 << x) #define CTRL(x) (0x1F & (x)) @@ -274,13 +268,14 @@ typedef struct { #define PXEBC_CACHED_DHCP4_PACKET_MAX_SIZE (OFFSET_OF (EFI_DHCP4_PACKET, Dhcp4) + PXEBC_DHCP4_MAX_PACKET_SIZE) -typedef struct { - union { - EFI_DHCP4_PACKET Offer; - EFI_DHCP4_PACKET Ack; - UINT8 Buffer[PXEBC_CACHED_DHCP4_PACKET_MAX_SIZE]; - } Packet; +typedef union { + EFI_DHCP4_PACKET Offer; + EFI_DHCP4_PACKET Ack; + UINT8 Buffer[PXEBC_CACHED_DHCP4_PACKET_MAX_SIZE]; +} PXEBC_DHCP4_PACKET; +typedef struct { + PXEBC_DHCP4_PACKET Packet; BOOLEAN IsPxeOffer; UINT8 OfferType; EFI_DHCP4_PACKET_OPTION *Dhcp4Option[PXEBC_DHCP4_TAG_INDEX_MAX]; @@ -438,7 +433,7 @@ PxeBcBuildDhcpOptions ( /** - Create the boot options + Create the boot options. @param OptList Pointer to the list of the options @param Type the type of option diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c index 659f638930..e04ae3a8ae 100644 --- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c +++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c @@ -176,7 +176,7 @@ IcmpErrorListenHandlerDpc ( } if (EFI_IP4 (RxData->Header->SourceAddress) != 0 && - !Ip4IsUnicast (EFI_NTOHL (RxData->Header->SourceAddress), 0)) { + !NetIp4IsUnicast (EFI_NTOHL (RxData->Header->SourceAddress), 0)) { // // The source address is not zero and it's not a unicast IP address, discard it. // @@ -1044,11 +1044,11 @@ EfiPxeBcMtftp ( EFI_PXE_BASE_CODE_MODE *Mode; EFI_MAC_ADDRESS TempMacAddr; - if ((This == NULL) || - (Filename == NULL) || - (BufferSize == NULL) || - ((ServerIp == NULL) || !Ip4IsUnicast (NTOHL (ServerIp->Addr[0]), 0)) || - ((BufferPtr == NULL) && DontUseBuffer) || + if ((This == NULL) || + (Filename == NULL) || + (BufferSize == NULL) || + ((ServerIp == NULL) || !NetIp4IsUnicast (NTOHL (ServerIp->Addr[0]), 0)) || + ((BufferPtr == NULL) && DontUseBuffer) || ((BlockSize != NULL) && (*BlockSize < 512))) { return EFI_INVALID_PARAMETER; @@ -1243,7 +1243,7 @@ EfiPxeBcUdpWrite ( return EFI_INVALID_PARAMETER; } - if ((GatewayIp != NULL) && !Ip4IsUnicast (NTOHL (GatewayIp->Addr[0]), 0)) { + if ((GatewayIp != NULL) && !NetIp4IsUnicast (NTOHL (GatewayIp->Addr[0]), 0)) { // // Gateway is provided but it's not a unicast IP address. // @@ -1783,7 +1783,7 @@ EfiPxeBcSetIpFilter ( DEBUG ((EFI_D_ERROR, "There is broadcast address in NewFilter.\n")); return EFI_INVALID_PARAMETER; } - if (Ip4IsUnicast (EFI_IP4 (NewFilter->IpList[Index].v4), 0) && + if (NetIp4IsUnicast (EFI_IP4 (NewFilter->IpList[Index].v4), 0) && (NewFilter->Filters & EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP) ) { // @@ -2110,7 +2110,7 @@ EfiPxeBcSetStationIP ( return EFI_INVALID_PARAMETER; } - if (NewStationIp != NULL && !Ip4IsUnicast (NTOHL (NewStationIp->Addr[0]), 0)) { + if (NewStationIp != NULL && !NetIp4IsUnicast (NTOHL (NewStationIp->Addr[0]), 0)) { return EFI_INVALID_PARAMETER; } diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcMtftp.h b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcMtftp.h index 2ef0450626..4d795a239d 100644 --- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcMtftp.h +++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcMtftp.h @@ -1,7 +1,7 @@ /** @file Mtftp routines for PxeBc. -Copyright (c) 2007, Intel Corporation.
+Copyright (c) 2007 - 2009, 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 @@ -15,13 +15,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #ifndef __EFI_PXEBC_MTFTP_H__ #define __EFI_PXEBC_MTFTP_H__ -typedef enum { - PXE_MTFTP_OPTION_BLKSIZE_INDEX, - PXE_MTFTP_OPTION_TIMEOUT_INDEX, - PXE_MTFTP_OPTION_TSIZE_INDEX, - PXE_MTFTP_OPTION_MULTICAST_INDEX, - PXE_MTFTP_OPTION_MAXIMUM_INDEX -} PXE_MTFTP_OPTION_ENUM_TYPES; +#define PXE_MTFTP_OPTION_BLKSIZE_INDEX 0 +#define PXE_MTFTP_OPTION_TIMEOUT_INDEX 1 +#define PXE_MTFTP_OPTION_TSIZE_INDEX 2 +#define PXE_MTFTP_OPTION_MULTICAST_INDEX 3 +#define PXE_MTFTP_OPTION_MAXIMUM_INDEX 4 /** -- 2.30.2