/** @file\r
Support routines for PxeBc.\r
\r
-Copyright (c) 2007 - 2010, Intel Corporation.<BR>\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
http://opensource.org/licenses/bsd-license.php\r
#include "PxeBcImpl.h"\r
\r
\r
-/**\r
- This function returns SMBIOS string given the string number.\r
-\r
- @param Smbios Pointer to SMBIOS structure\r
- @param StringNumber String number to return. 0 is used to skip all\r
- strings and point to the next SMBIOS structure.\r
-\r
- @return Pointer to string, or pointer to next SMBIOS strcuture if StringNumber == 0\r
-\r
-**/\r
-CHAR8 *\r
-GetSmbiosString (\r
- IN SMBIOS_STRUCTURE_POINTER *Smbios,\r
- IN UINT16 StringNumber\r
- )\r
-{\r
- UINT16 Index;\r
- CHAR8 *String;\r
-\r
- //\r
- // Skip over formatted section\r
- //\r
- String = (CHAR8 *) (Smbios->Raw + Smbios->Hdr->Length);\r
-\r
- //\r
- // Look through unformated section\r
- //\r
- for (Index = 1; Index <= StringNumber || StringNumber == 0; Index++) {\r
- if (StringNumber == Index) {\r
- return String;\r
- }\r
- //\r
- // Skip string\r
- //\r
- for (; *String != 0; String++)\r
- ;\r
- String++;\r
-\r
- if (*String == 0) {\r
- //\r
- // If double NULL then we are done.\r
- // Return pointer to next structure in Smbios.\r
- // if you pass in a 0 you will always get here\r
- //\r
- Smbios->Raw = (UINT8 *)++String;\r
- return NULL;\r
- }\r
- }\r
-\r
- return NULL;\r
-}\r
-\r
-\r
-/**\r
- This function gets system guid and serial number from the smbios table.\r
-\r
- @param SystemGuid The pointer of returned system guid.\r
- @param SystemSerialNumber The pointer of returned system serial number.\r
-\r
- @retval EFI_SUCCESS Successfully get the system guid and system serial\r
- number.\r
- @retval EFI_NOT_FOUND Not find the SMBIOS table.\r
-\r
-**/\r
-EFI_STATUS\r
-GetSmbiosSystemGuidAndSerialNumber (\r
- IN EFI_GUID *SystemGuid,\r
- OUT CHAR8 **SystemSerialNumber\r
- )\r
-{\r
- EFI_STATUS Status;\r
- SMBIOS_TABLE_ENTRY_POINT *SmbiosTable;\r
- SMBIOS_STRUCTURE_POINTER Smbios;\r
- SMBIOS_STRUCTURE_POINTER SmbiosEnd;\r
- UINT16 Index;\r
-\r
- Status = EfiGetSystemConfigurationTable (&gEfiSmbiosTableGuid, (VOID **) &SmbiosTable);\r
-\r
- if (EFI_ERROR (Status)) {\r
- return EFI_NOT_FOUND;\r
- }\r
- ASSERT (SmbiosTable != NULL);\r
-\r
- Smbios.Hdr = (SMBIOS_STRUCTURE *) (UINTN) SmbiosTable->TableAddress;\r
- SmbiosEnd.Raw = (UINT8 *) (UINTN) (SmbiosTable->TableAddress + SmbiosTable->TableLength);\r
-\r
- for (Index = 0; Index < SmbiosTable->TableLength; Index++) {\r
- if (Smbios.Hdr->Type == 1) {\r
- if (Smbios.Hdr->Length < 0x19) {\r
- //\r
- // Older version did not support Guid and Serial number\r
- //\r
- continue;\r
- }\r
- //\r
- // SMBIOS tables are byte packed so we need to do a byte copy to\r
- // prevend alignment faults on Itanium-based platform.\r
- //\r
- CopyMem (SystemGuid, &Smbios.Type1->Uuid, sizeof (EFI_GUID));\r
- *SystemSerialNumber = GetSmbiosString (&Smbios, Smbios.Type1->SerialNumber);\r
-\r
- return EFI_SUCCESS;\r
- }\r
- //\r
- // Make Smbios point to the next record\r
- //\r
- GetSmbiosString (&Smbios, 0);\r
-\r
- if (Smbios.Raw >= SmbiosEnd.Raw) {\r
- //\r
- // SMBIOS 2.1 incorrectly stated the length of SmbiosTable as 0x1e.\r
- // given this we must double check against the length of the structure.\r
- //\r
- return EFI_SUCCESS;\r
- }\r
- }\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
/**\r
The common notify function associated with various PxeBc events.\r
\r
@param SubnetMask Pointer to the subnetmask of the station ip address.\r
@param Gateway Pointer to the gateway ip address.\r
@param SrcPort Pointer to the srouce port of the station.\r
+ @param Ttl The time to live field of the IP header. \r
+ @param ToS The type of service field of the IP header.\r
\r
@retval EFI_SUCCESS The configuration settings were set, changed, or reset successfully.\r
@retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,\r
IN EFI_IPv4_ADDRESS *StationIp,\r
IN EFI_IPv4_ADDRESS *SubnetMask,\r
IN EFI_IPv4_ADDRESS *Gateway,\r
- IN OUT UINT16 *SrcPort\r
+ IN OUT UINT16 *SrcPort,\r
+ IN UINT8 Ttl,\r
+ IN UINT8 ToS\r
)\r
{\r
EFI_UDP4_CONFIG_DATA Udp4CfgData;\r
ZeroMem (&Udp4CfgData, sizeof (Udp4CfgData));\r
\r
Udp4CfgData.ReceiveTimeout = PXEBC_DEFAULT_LIFETIME;\r
- Udp4CfgData.TypeOfService = DEFAULT_ToS;\r
- Udp4CfgData.TimeToLive = DEFAULT_TTL;\r
+ Udp4CfgData.TypeOfService = ToS;\r
+ Udp4CfgData.TimeToLive = TTL;\r
Udp4CfgData.AllowDuplicatePort = TRUE;\r
\r
CopyMem (&Udp4CfgData.StationAddress, StationIp, sizeof (*StationIp));\r
/**\r
Convert unsigned int number to decimal number.\r
\r
- @param Number The unsigned int number will be converted.\r
- @param Buffer Pointer to the buffer to store the decimal number after transform.\r
-\r
+ @param Number The unsigned int number will be converted.\r
+ @param Buffer Pointer to the buffer to store the decimal number after transform.\r
+ @param[in] BufferSize The maxsize of the buffer.\r
+ \r
@return the length of the number after transform.\r
\r
**/\r
UINTN\r
UtoA10 (\r
IN UINTN Number,\r
- IN CHAR8 *Buffer\r
+ IN CHAR8 *Buffer,\r
+ IN UINTN BufferSize\r
)\r
{\r
UINTN Index;\r
Number = Number / 10;\r
} while (Number != 0);\r
\r
- AsciiStrCpy (Buffer, &TempStr[Index]);\r
+ AsciiStrCpyS (Buffer, BufferSize, &TempStr[Index]);\r
\r
return AsciiStrLen (Buffer);\r
}\r