mirror of https://github.com/acidanthera/audk.git
Add Socket Library applications.
Modify AppPkg.dsc file to include StdLib.inc which contains the Boilerplate text for Standard Library based Applications. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12062 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
d7ce700605
commit
4684b66f26
|
@ -41,6 +41,7 @@
|
||||||
#
|
#
|
||||||
UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf
|
UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf
|
||||||
ShellCEntryLib|ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.inf
|
ShellCEntryLib|ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.inf
|
||||||
|
UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf
|
||||||
#
|
#
|
||||||
# Common Libraries
|
# Common Libraries
|
||||||
#
|
#
|
||||||
|
@ -64,45 +65,11 @@
|
||||||
UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf
|
UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf
|
||||||
PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf
|
PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf
|
||||||
HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
|
HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
|
||||||
|
|
||||||
ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
|
ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
|
||||||
FileHandleLib|ShellPkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
|
FileHandleLib|ShellPkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
|
||||||
SortLib|ShellPkg/Library/UefiSortLib/UefiSortLib.inf
|
SortLib|ShellPkg/Library/UefiSortLib/UefiSortLib.inf
|
||||||
|
PathLib|ShellPkg/Library/BasePathLib/BasePathLib.inf
|
||||||
#
|
|
||||||
# C Standard Libraries
|
|
||||||
#
|
|
||||||
LibC|StdLib/LibC/LibC.inf
|
|
||||||
LibStdLib|StdLib/LibC/StdLib/StdLib.inf
|
|
||||||
LibString|StdLib/LibC/String/String.inf
|
|
||||||
LibWchar|StdLib/LibC/Wchar/Wchar.inf
|
|
||||||
LibCType|StdLib/LibC/Ctype/Ctype.inf
|
|
||||||
LibTime|StdLib/LibC/Time/Time.inf
|
|
||||||
LibStdio|StdLib/LibC/Stdio/Stdio.inf
|
|
||||||
LibGdtoa|StdLib/LibC/gdtoa/gdtoa.inf
|
|
||||||
LibLocale|StdLib/LibC/Locale/Locale.inf
|
|
||||||
LibUefi|StdLib/LibC/Uefi/Uefi.inf
|
|
||||||
LibMath|StdLib/LibC/Math/Math.inf
|
|
||||||
LibSignal|StdLib/LibC/Signal/Signal.inf
|
|
||||||
LibNetUtil|StdLib/LibC/NetUtil/NetUtil.inf
|
|
||||||
|
|
||||||
# Libraries for device abstractions within the Standard C Library
|
|
||||||
# Applications should not directly access any functions defined in these libraries.
|
|
||||||
DevUtility|StdLib/LibC/Uefi/Devices/daUtility.inf
|
|
||||||
DevConsole|StdLib/LibC/Uefi/Devices/daConsole.inf
|
|
||||||
DevShell|StdLib/LibC/Uefi/Devices/daShell.inf
|
|
||||||
|
|
||||||
[LibraryClasses.IA32]
|
|
||||||
TimerLib|PerformancePkg/Library/DxeTscTimerLib/DxeTscTimerLib.inf
|
|
||||||
# To run in an emulation environment, such as Nt32Pkg, comment out the TimerLib
|
|
||||||
# description above and un-comment the line below.
|
|
||||||
# TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf
|
|
||||||
|
|
||||||
[LibraryClasses.X64]
|
|
||||||
TimerLib|PerformancePkg/Library/DxeTscTimerLib/DxeTscTimerLib.inf
|
|
||||||
|
|
||||||
[LibraryClasses.IPF]
|
|
||||||
PalLib|MdePkg/Library/UefiPalLib/UefiPalLib.inf
|
|
||||||
TimerLib|MdePkg/Library/SecPeiDxeTimerLibCpu/SecPeiDxeTimerLibCpu.inf
|
|
||||||
|
|
||||||
###################################################################################################
|
###################################################################################################
|
||||||
#
|
#
|
||||||
|
@ -124,44 +91,41 @@
|
||||||
###################################################################################################
|
###################################################################################################
|
||||||
|
|
||||||
[Components]
|
[Components]
|
||||||
# BaseLib and BaseMemoryLib need to be built with the /GL- switch when using the Microsoft
|
|
||||||
# tool chain. This is required so that the library functions can be resolved during
|
|
||||||
# the second pass of the linker during Link-time-code-generation.
|
|
||||||
###
|
|
||||||
MdePkg/Library/BaseLib/BaseLib.inf {
|
|
||||||
<BuildOptions>
|
|
||||||
MSFT:*_*_*_CC_FLAGS = /X /Zc:wchar_t /GL-
|
|
||||||
}
|
|
||||||
|
|
||||||
MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf {
|
|
||||||
<BuildOptions>
|
|
||||||
MSFT:*_*_*_CC_FLAGS = /X /Zc:wchar_t /GL-
|
|
||||||
}
|
|
||||||
|
|
||||||
#### Sample Applications.
|
#### Sample Applications.
|
||||||
AppPkg/Applications/Hello/Hello.inf # No LibC includes or functions.
|
AppPkg/Applications/Hello/Hello.inf # No LibC includes or functions.
|
||||||
AppPkg/Applications/Main/Main.inf # Simple invocation. No other LibC functions.
|
AppPkg/Applications/Main/Main.inf # Simple invocation. No other LibC functions.
|
||||||
AppPkg/Applications/Enquire/Enquire.inf
|
AppPkg/Applications/Enquire/Enquire.inf
|
||||||
|
|
||||||
# After extracting the Python distribution, un-comment the following line to build Python.
|
#### After extracting the Python distribution, un-comment the following line to build Python.
|
||||||
# AppPkg/Applications/Python/PythonCore.inf
|
# AppPkg/Applications/Python/PythonCore.inf
|
||||||
|
|
||||||
################################################################
|
##########
|
||||||
|
# Socket Applications - LibC based
|
||||||
|
##########
|
||||||
|
AppPkg/Applications/Sockets/DataSink/DataSink.inf
|
||||||
|
AppPkg/Applications/Sockets/DataSource/DataSource.inf
|
||||||
|
# SocketPkg/Application/FtpNew/FTP.inf
|
||||||
|
AppPkg/Applications/Sockets/GetHostByAddr/GetHostByAddr.inf
|
||||||
|
AppPkg/Applications/Sockets/GetHostByDns/GetHostByDns.inf
|
||||||
|
AppPkg/Applications/Sockets/GetHostByName/GetHostByName.inf
|
||||||
|
AppPkg/Applications/Sockets/GetNetByAddr/GetNetByAddr.inf
|
||||||
|
AppPkg/Applications/Sockets/GetNetByName/GetNetByName.inf
|
||||||
|
AppPkg/Applications/Sockets/GetServByName/GetServByName.inf
|
||||||
|
AppPkg/Applications/Sockets/GetServByPort/GetServByPort.inf
|
||||||
|
AppPkg/Applications/Sockets/RecvDgram/RecvDgram.inf
|
||||||
|
# SocketPkg/Application/route/route.inf
|
||||||
|
AppPkg/Applications/Sockets/SetHostName/SetHostName.inf
|
||||||
|
AppPkg/Applications/Sockets/SetSockOpt/SetSockOpt.inf
|
||||||
|
AppPkg/Applications/Sockets/TftpServer/TftpServer.inf
|
||||||
|
AppPkg/Applications/Sockets/WebServer/WebServer.inf {
|
||||||
|
<PcdsFixedAtBuild>
|
||||||
|
gStdLibTokenSpaceGuid.WebServer_HttpPort|80
|
||||||
|
}
|
||||||
|
|
||||||
|
###################################################################################################
|
||||||
#
|
#
|
||||||
# See the additional comments below if you plan to run applications under the
|
# Include Boilerplate text required for building with the Standard Libraries.
|
||||||
# Nt32 emulation environment.
|
|
||||||
#
|
#
|
||||||
|
###################################################################################################
|
||||||
[BuildOptions]
|
!include StdLib/StdLib.inc
|
||||||
INTEL:*_*_*_CC_FLAGS = /Qfreestanding
|
|
||||||
MSFT:*_*_*_CC_FLAGS = /X /Zc:wchar_t
|
|
||||||
GCC:*_*_*_CC_FLAGS = -ffreestanding -nostdinc -nostdlib
|
|
||||||
|
|
||||||
# The Build Options, below, are only used when building the C library
|
|
||||||
# to be run under an emulation environment, such as Nt32Pkg. The clock()
|
|
||||||
# system call is modified to return -1 indicating that it is unsupported.
|
|
||||||
# Just uncomment the lines below and select the correct TimerLib instance, above.
|
|
||||||
|
|
||||||
# INTEL:*_*_IA32_CC_FLAGS = /D NT32dvm
|
|
||||||
# MSFT:*_*_IA32_CC_FLAGS = /D NT32dvm
|
|
||||||
# GCC:*_*_IA32_CC_FLAGS = -DNT32dvm
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,67 @@
|
||||||
|
#/** @file
|
||||||
|
# DataSink Application
|
||||||
|
#
|
||||||
|
# This file contains an 'Intel Peripheral Driver' and is
|
||||||
|
# licensed for Intel CPUs and chipsets under the terms of your
|
||||||
|
# license agreement with Intel or your vendor. This file may
|
||||||
|
# be modified by the user, subject to additional terms of the
|
||||||
|
# license agreement
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Copyright (c) 20011 Intel Corporation. All rights reserved
|
||||||
|
# This software and associated documentation (if any) is furnished
|
||||||
|
# under a license and may only be used or copied in accordance
|
||||||
|
# with the terms of the license. Except as permitted by such
|
||||||
|
# license, no part of this software or documentation may be
|
||||||
|
# reproduced, stored in a retrieval system, or transmitted in any
|
||||||
|
# form or by any means without the express written consent of
|
||||||
|
# Intel Corporation.
|
||||||
|
#
|
||||||
|
##
|
||||||
|
|
||||||
|
|
||||||
|
[Defines]
|
||||||
|
INF_VERSION = 0x00010005
|
||||||
|
BASE_NAME = DataSink
|
||||||
|
FILE_GUID = A85DCA1B-198F-4e14-A673-874264687E85
|
||||||
|
MODULE_TYPE = UEFI_APPLICATION
|
||||||
|
VERSION_STRING = 1.0
|
||||||
|
ENTRY_POINT = ShellCEntryLib
|
||||||
|
|
||||||
|
#
|
||||||
|
# The following information is for reference only and not required by the build tools.
|
||||||
|
#
|
||||||
|
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||||
|
#
|
||||||
|
|
||||||
|
[Sources]
|
||||||
|
DataSink.c
|
||||||
|
|
||||||
|
|
||||||
|
[Pcd]
|
||||||
|
gStdLibTokenSpaceGuid.DataSource_Port
|
||||||
|
|
||||||
|
|
||||||
|
[Packages]
|
||||||
|
MdePkg/MdePkg.dec
|
||||||
|
ShellPkg/ShellPkg.dec
|
||||||
|
StdLib/StdLib.dec
|
||||||
|
|
||||||
|
|
||||||
|
[LibraryClasses]
|
||||||
|
BaseMemoryLib
|
||||||
|
BsdSocketLib
|
||||||
|
DebugLib
|
||||||
|
EfiSocketLib
|
||||||
|
LibC
|
||||||
|
LibMath
|
||||||
|
ShellCEntryLib
|
||||||
|
UefiBootServicesTableLib
|
||||||
|
UefiLib
|
||||||
|
# UseSocketDxe
|
||||||
|
|
||||||
|
[BuildOptions]
|
||||||
|
INTEL:*_*_*_CC_FLAGS = /Qdiag-disable:181,186
|
||||||
|
MSFT:*_*_*_CC_FLAGS = /Od
|
||||||
|
GCC:*_*_*_CC_FLAGS = -O0 -Wno-unused-variable
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,70 @@
|
||||||
|
#/** @file
|
||||||
|
# DataSource Application
|
||||||
|
#
|
||||||
|
# This file contains an 'Intel Peripheral Driver' and is
|
||||||
|
# licensed for Intel CPUs and chipsets under the terms of your
|
||||||
|
# license agreement with Intel or your vendor. This file may
|
||||||
|
# be modified by the user, subject to additional terms of the
|
||||||
|
# license agreement
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Copyright (c) 20011 Intel Corporation. All rights reserved
|
||||||
|
# This software and associated documentation (if any) is furnished
|
||||||
|
# under a license and may only be used or copied in accordance
|
||||||
|
# with the terms of the license. Except as permitted by such
|
||||||
|
# license, no part of this software or documentation may be
|
||||||
|
# reproduced, stored in a retrieval system, or transmitted in any
|
||||||
|
# form or by any means without the express written consent of
|
||||||
|
# Intel Corporation.
|
||||||
|
#
|
||||||
|
##
|
||||||
|
|
||||||
|
|
||||||
|
[Defines]
|
||||||
|
INF_VERSION = 0x00010005
|
||||||
|
BASE_NAME = DataSource
|
||||||
|
FILE_GUID = 30EB0F26-FC0A-4fd2-B9C9-751EA2BB1980
|
||||||
|
MODULE_TYPE = UEFI_APPLICATION
|
||||||
|
VERSION_STRING = 1.0
|
||||||
|
ENTRY_POINT = ShellCEntryLib
|
||||||
|
|
||||||
|
#
|
||||||
|
# The following information is for reference only and not required by the build tools.
|
||||||
|
#
|
||||||
|
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||||
|
#
|
||||||
|
|
||||||
|
[Sources]
|
||||||
|
DataSource.c
|
||||||
|
|
||||||
|
|
||||||
|
[Pcd]
|
||||||
|
gStdLibTokenSpaceGuid.DataSource_Port
|
||||||
|
|
||||||
|
|
||||||
|
[Packages]
|
||||||
|
MdePkg/MdePkg.dec
|
||||||
|
ShellPkg/ShellPkg.dec
|
||||||
|
StdLib/StdLib.dec
|
||||||
|
|
||||||
|
|
||||||
|
[LibraryClasses]
|
||||||
|
BaseMemoryLib
|
||||||
|
BsdSocketLib
|
||||||
|
EfiSocketLib
|
||||||
|
DebugLib
|
||||||
|
LibC
|
||||||
|
ShellCEntryLib
|
||||||
|
UefiBootServicesTableLib
|
||||||
|
UefiLib
|
||||||
|
# UseSocketDxe
|
||||||
|
|
||||||
|
[Protocols]
|
||||||
|
gEfiTcp4ProtocolGuid
|
||||||
|
gEfiTcp4ServiceBindingProtocolGuid
|
||||||
|
|
||||||
|
[BuildOptions]
|
||||||
|
INTEL:*_*_*_CC_FLAGS = /Qdiag-disable:181,186
|
||||||
|
MSFT:*_*_*_CC_FLAGS = /Od
|
||||||
|
GCC:*_*_*_CC_FLAGS = -O0 -Wno-unused-variable
|
||||||
|
|
|
@ -0,0 +1,133 @@
|
||||||
|
/** @file
|
||||||
|
Translate the port number into a service name
|
||||||
|
|
||||||
|
Copyright (c) 2011, Intel Corporation
|
||||||
|
All rights reserved. This program and the accompanying materials
|
||||||
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <Uefi.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <arpa\nameser.h>
|
||||||
|
#include <arpa\nameser_compat.h>
|
||||||
|
|
||||||
|
#include <Library/DebugLib.h>
|
||||||
|
#include <Library/UefiLib.h>
|
||||||
|
|
||||||
|
#include <sys/socket.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
Translate the IP address into a host name
|
||||||
|
|
||||||
|
@param [in] Argc The number of arguments
|
||||||
|
@param [in] Argv The argument value array
|
||||||
|
|
||||||
|
@retval 0 The application exited normally.
|
||||||
|
@retval Other An error occurred.
|
||||||
|
**/
|
||||||
|
int
|
||||||
|
main (
|
||||||
|
IN int Argc,
|
||||||
|
IN char **Argv
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UINTN Index;
|
||||||
|
UINT8 IpAddress[4];
|
||||||
|
struct hostent * pHost;
|
||||||
|
UINT8 * pIpAddress;
|
||||||
|
char ** ppName;
|
||||||
|
UINT32 RemoteAddress[4];
|
||||||
|
|
||||||
|
//
|
||||||
|
// Determine if the IPv4 address is specified
|
||||||
|
//
|
||||||
|
if (( 2 != Argc )
|
||||||
|
|| ( 4 != sscanf ( Argv[1],
|
||||||
|
"%d.%d.%d.%d",
|
||||||
|
&RemoteAddress[0],
|
||||||
|
&RemoteAddress[1],
|
||||||
|
&RemoteAddress[2],
|
||||||
|
&RemoteAddress[3]))
|
||||||
|
|| ( 255 < RemoteAddress [0])
|
||||||
|
|| ( 255 < RemoteAddress [1])
|
||||||
|
|| ( 255 < RemoteAddress [2])
|
||||||
|
|| ( 255 < RemoteAddress [3])) {
|
||||||
|
Print ( L"%a <IPv4 Address>\r\n", Argv[0]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//
|
||||||
|
// Translate the address into a host name
|
||||||
|
//
|
||||||
|
IpAddress[0] = (UINT8)RemoteAddress[0];
|
||||||
|
IpAddress[1] = (UINT8)RemoteAddress[1];
|
||||||
|
IpAddress[2] = (UINT8)RemoteAddress[2];
|
||||||
|
IpAddress[3] = (UINT8)RemoteAddress[3];
|
||||||
|
pHost = gethostbyaddr ( &IpAddress[0], INADDRSZ, AF_INET );
|
||||||
|
if ( NULL == pHost ) {
|
||||||
|
Print ( L"ERROR - host not found, errno: %d\r\n", errno );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
pIpAddress = (UINT8 *)pHost->h_addr_list [ 0 ];
|
||||||
|
Print ( L"%d.%d.%d.%d, %a\r\n",
|
||||||
|
pIpAddress[0],
|
||||||
|
pIpAddress[1],
|
||||||
|
pIpAddress[2],
|
||||||
|
pIpAddress[3],
|
||||||
|
pHost->h_name );
|
||||||
|
|
||||||
|
//
|
||||||
|
// Display the other addresses
|
||||||
|
//
|
||||||
|
for ( Index = 1; NULL != pHost->h_addr_list[Index]; Index++ ) {
|
||||||
|
pIpAddress = (UINT8 *)pHost->h_addr_list[Index];
|
||||||
|
Print ( L"%d.%d.%d.%d\r\n",
|
||||||
|
pIpAddress[0],
|
||||||
|
pIpAddress[1],
|
||||||
|
pIpAddress[2],
|
||||||
|
pIpAddress[3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Display the list of aliases
|
||||||
|
//
|
||||||
|
ppName = pHost->h_aliases;
|
||||||
|
if (( NULL == ppName ) || ( NULL == *ppName )) {
|
||||||
|
Print ( L"No aliases\r\n" );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Print ( L"Aliases: " );
|
||||||
|
while ( NULL != *ppName ) {
|
||||||
|
//
|
||||||
|
// Display the alias
|
||||||
|
//
|
||||||
|
Print ( L"%a", *ppName );
|
||||||
|
|
||||||
|
//
|
||||||
|
// Set the next alias
|
||||||
|
//
|
||||||
|
ppName += 1;
|
||||||
|
if ( NULL != *ppName ) {
|
||||||
|
Print ( L", " );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Print ( L"\r\n" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// All done
|
||||||
|
//
|
||||||
|
return errno;
|
||||||
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
#/** @file
|
||||||
|
# GetHostByAddr Application
|
||||||
|
#
|
||||||
|
# This file contains an 'Intel Peripheral Driver' and is
|
||||||
|
# licensed for Intel CPUs and chipsets under the terms of your
|
||||||
|
# license agreement with Intel or your vendor. This file may
|
||||||
|
# be modified by the user, subject to additional terms of the
|
||||||
|
# license agreement
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Copyright (c) 20011 Intel Corporation. All rights reserved
|
||||||
|
# This software and associated documentation (if any) is furnished
|
||||||
|
# under a license and may only be used or copied in accordance
|
||||||
|
# with the terms of the license. Except as permitted by such
|
||||||
|
# license, no part of this software or documentation may be
|
||||||
|
# reproduced, stored in a retrieval system, or transmitted in any
|
||||||
|
# form or by any means without the express written consent of
|
||||||
|
# Intel Corporation.
|
||||||
|
#
|
||||||
|
##
|
||||||
|
|
||||||
|
|
||||||
|
[Defines]
|
||||||
|
INF_VERSION = 0x00010005
|
||||||
|
BASE_NAME = GetHostByAddr
|
||||||
|
FILE_GUID = C31A6189-639A-458b-B040-D7D506CA8F4F
|
||||||
|
MODULE_TYPE = UEFI_APPLICATION
|
||||||
|
VERSION_STRING = 1.0
|
||||||
|
ENTRY_POINT = ShellCEntryLib
|
||||||
|
|
||||||
|
#
|
||||||
|
# The following information is for reference only and not required by the build tools.
|
||||||
|
#
|
||||||
|
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||||
|
#
|
||||||
|
|
||||||
|
[Sources]
|
||||||
|
GetHostByAddr.c
|
||||||
|
|
||||||
|
|
||||||
|
[Packages]
|
||||||
|
MdePkg/MdePkg.dec
|
||||||
|
ShellPkg/ShellPkg.dec
|
||||||
|
StdLib/StdLib.dec
|
||||||
|
|
||||||
|
|
||||||
|
[LibraryClasses]
|
||||||
|
BaseMemoryLib
|
||||||
|
BsdSocketLib
|
||||||
|
DebugLib
|
||||||
|
DevShell
|
||||||
|
EfiSocketLib
|
||||||
|
LibC
|
||||||
|
LibMath
|
||||||
|
LibNetUtil
|
||||||
|
ShellCEntryLib
|
||||||
|
UefiBootServicesTableLib
|
||||||
|
UefiLib
|
||||||
|
# UseSocketDxe
|
||||||
|
|
||||||
|
[BuildOptions]
|
||||||
|
INTEL:*_*_*_CC_FLAGS = /Qdiag-disable:181,186
|
||||||
|
MSFT:*_*_*_CC_FLAGS = /Od
|
||||||
|
GCC:*_*_*_CC_FLAGS = -O0 -Wno-unused-variable
|
||||||
|
|
|
@ -0,0 +1,85 @@
|
||||||
|
/** @file
|
||||||
|
Translate the host name into an IP address
|
||||||
|
|
||||||
|
Copyright (c) 2011, Intel Corporation
|
||||||
|
All rights reserved. This program and the accompanying materials
|
||||||
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <Uefi.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <Library/DebugLib.h>
|
||||||
|
#include <Library/UefiLib.h>
|
||||||
|
|
||||||
|
#include <sys/socket.h>
|
||||||
|
|
||||||
|
struct hostent * _gethostbydnsname(const char *, int);
|
||||||
|
|
||||||
|
char mBuffer [65536];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Translate the host name into an IP address
|
||||||
|
|
||||||
|
@param [in] Argc The number of arguments
|
||||||
|
@param [in] Argv The argument value array
|
||||||
|
|
||||||
|
@retval 0 The application exited normally.
|
||||||
|
@retval Other An error occurred.
|
||||||
|
**/
|
||||||
|
int
|
||||||
|
main (
|
||||||
|
IN int Argc,
|
||||||
|
IN char **Argv
|
||||||
|
)
|
||||||
|
{
|
||||||
|
int AppStatus;
|
||||||
|
UINT8 * pIpAddress;
|
||||||
|
struct hostent * pHost;
|
||||||
|
|
||||||
|
DEBUG (( DEBUG_INFO,
|
||||||
|
"%a starting\r\n",
|
||||||
|
Argv[0]));
|
||||||
|
|
||||||
|
//
|
||||||
|
// Determine if the host name is specified
|
||||||
|
//
|
||||||
|
AppStatus = 0;
|
||||||
|
if ( 1 == Argc ) {
|
||||||
|
Print ( L"%a <host name>\r\n", Argv[0]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//
|
||||||
|
// Translate the host name
|
||||||
|
//
|
||||||
|
pHost = _gethostbydnsname ( Argv[1], AF_INET );
|
||||||
|
if ( NULL == pHost ) {
|
||||||
|
Print ( L"ERROR - host not found, errno: %d\r\n", errno );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
pIpAddress = (UINT8 *)pHost->h_addr;
|
||||||
|
Print ( L"%a: Type %d, %d.%d.%d.%d\r\n",
|
||||||
|
pHost->h_name,
|
||||||
|
pHost->h_addrtype,
|
||||||
|
pIpAddress[0],
|
||||||
|
pIpAddress[1],
|
||||||
|
pIpAddress[2],
|
||||||
|
pIpAddress[3]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// All done
|
||||||
|
//
|
||||||
|
return errno;
|
||||||
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
#/** @file
|
||||||
|
# GetHostByDns Application
|
||||||
|
#
|
||||||
|
# This file contains an 'Intel Peripheral Driver' and is
|
||||||
|
# licensed for Intel CPUs and chipsets under the terms of your
|
||||||
|
# license agreement with Intel or your vendor. This file may
|
||||||
|
# be modified by the user, subject to additional terms of the
|
||||||
|
# license agreement
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Copyright (c) 20011 Intel Corporation. All rights reserved
|
||||||
|
# This software and associated documentation (if any) is furnished
|
||||||
|
# under a license and may only be used or copied in accordance
|
||||||
|
# with the terms of the license. Except as permitted by such
|
||||||
|
# license, no part of this software or documentation may be
|
||||||
|
# reproduced, stored in a retrieval system, or transmitted in any
|
||||||
|
# form or by any means without the express written consent of
|
||||||
|
# Intel Corporation.
|
||||||
|
#
|
||||||
|
##
|
||||||
|
|
||||||
|
|
||||||
|
[Defines]
|
||||||
|
INF_VERSION = 0x00010005
|
||||||
|
BASE_NAME = GetHostByDns
|
||||||
|
FILE_GUID = 3698D2B0-E727-4537-A636-A8770736ABFB
|
||||||
|
MODULE_TYPE = UEFI_APPLICATION
|
||||||
|
VERSION_STRING = 1.0
|
||||||
|
ENTRY_POINT = ShellCEntryLib
|
||||||
|
|
||||||
|
#
|
||||||
|
# The following information is for reference only and not required by the build tools.
|
||||||
|
#
|
||||||
|
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||||
|
#
|
||||||
|
|
||||||
|
[Sources]
|
||||||
|
GetHostByDns.c
|
||||||
|
|
||||||
|
|
||||||
|
[Packages]
|
||||||
|
MdePkg/MdePkg.dec
|
||||||
|
ShellPkg/ShellPkg.dec
|
||||||
|
StdLib/StdLib.dec
|
||||||
|
|
||||||
|
|
||||||
|
[LibraryClasses]
|
||||||
|
BaseMemoryLib
|
||||||
|
BsdSocketLib
|
||||||
|
DebugLib
|
||||||
|
DevShell
|
||||||
|
EfiSocketLib
|
||||||
|
LibC
|
||||||
|
LibMath
|
||||||
|
LibNetUtil
|
||||||
|
ShellCEntryLib
|
||||||
|
UefiBootServicesTableLib
|
||||||
|
UefiLib
|
||||||
|
# UseSocketDxe
|
||||||
|
|
||||||
|
[BuildOptions]
|
||||||
|
INTEL:*_*_*_CC_FLAGS = /Qdiag-disable:181,186
|
||||||
|
MSFT:*_*_*_CC_FLAGS = /Od
|
||||||
|
GCC:*_*_*_CC_FLAGS = -O0 -Wno-unused-variable
|
||||||
|
|
|
@ -0,0 +1,123 @@
|
||||||
|
/** @file
|
||||||
|
Translate the host name into an IP address
|
||||||
|
|
||||||
|
Copyright (c) 2011, Intel Corporation
|
||||||
|
All rights reserved. This program and the accompanying materials
|
||||||
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <Uefi.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <Library/DebugLib.h>
|
||||||
|
#include <Library/UefiLib.h>
|
||||||
|
|
||||||
|
#include <sys/socket.h>
|
||||||
|
|
||||||
|
char mBuffer [65536];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Translate the host name into an IP address
|
||||||
|
|
||||||
|
@param [in] Argc The number of arguments
|
||||||
|
@param [in] Argv The argument value array
|
||||||
|
|
||||||
|
@retval 0 The application exited normally.
|
||||||
|
@retval Other An error occurred.
|
||||||
|
**/
|
||||||
|
int
|
||||||
|
main (
|
||||||
|
IN int Argc,
|
||||||
|
IN char **Argv
|
||||||
|
)
|
||||||
|
{
|
||||||
|
int AppStatus;
|
||||||
|
UINTN Index;
|
||||||
|
struct hostent * pHost;
|
||||||
|
UINT8 * pIpAddress;
|
||||||
|
char ** ppName;
|
||||||
|
|
||||||
|
DEBUG (( DEBUG_INFO,
|
||||||
|
"%a starting\r\n",
|
||||||
|
Argv[0]));
|
||||||
|
|
||||||
|
//
|
||||||
|
// Determine if the host name is specified
|
||||||
|
//
|
||||||
|
AppStatus = 0;
|
||||||
|
if ( 1 == Argc ) {
|
||||||
|
Print ( L"%a <host name>\r\n", Argv[0]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//
|
||||||
|
// Translate the host name
|
||||||
|
//
|
||||||
|
pHost = gethostbyname ( Argv[1]);
|
||||||
|
if ( NULL == pHost ) {
|
||||||
|
Print ( L"ERROR - host not found, errno: %d\r\n", errno );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
pIpAddress = (UINT8 *)pHost->h_addr;
|
||||||
|
Print ( L"%d.%d.%d.%d, Type %d, %a\r\n",
|
||||||
|
pIpAddress[0],
|
||||||
|
pIpAddress[1],
|
||||||
|
pIpAddress[2],
|
||||||
|
pIpAddress[3],
|
||||||
|
pHost->h_addrtype,
|
||||||
|
pHost->h_name );
|
||||||
|
|
||||||
|
//
|
||||||
|
// Display the other addresses
|
||||||
|
//
|
||||||
|
for ( Index = 1; NULL != pHost->h_addr_list[Index]; Index++ ) {
|
||||||
|
pIpAddress = (UINT8 *)pHost->h_addr_list[Index];
|
||||||
|
Print ( L"%d.%d.%d.%d\r\n",
|
||||||
|
pIpAddress[0],
|
||||||
|
pIpAddress[1],
|
||||||
|
pIpAddress[2],
|
||||||
|
pIpAddress[3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Display the list of aliases
|
||||||
|
//
|
||||||
|
ppName = pHost->h_aliases;
|
||||||
|
if (( NULL == ppName ) || ( NULL == *ppName )) {
|
||||||
|
Print ( L"No aliases\r\n" );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Print ( L"Aliases: " );
|
||||||
|
while ( NULL != *ppName ) {
|
||||||
|
//
|
||||||
|
// Display the alias
|
||||||
|
//
|
||||||
|
Print ( L"%a", *ppName );
|
||||||
|
|
||||||
|
//
|
||||||
|
// Set the next alias
|
||||||
|
//
|
||||||
|
ppName += 1;
|
||||||
|
if ( NULL != *ppName ) {
|
||||||
|
Print ( L", " );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Print ( L"\r\n" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// All done
|
||||||
|
//
|
||||||
|
return errno;
|
||||||
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
#/** @file
|
||||||
|
# GetHostByName Application
|
||||||
|
#
|
||||||
|
# This file contains an 'Intel Peripheral Driver' and is
|
||||||
|
# licensed for Intel CPUs and chipsets under the terms of your
|
||||||
|
# license agreement with Intel or your vendor. This file may
|
||||||
|
# be modified by the user, subject to additional terms of the
|
||||||
|
# license agreement
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Copyright (c) 20011 Intel Corporation. All rights reserved
|
||||||
|
# This software and associated documentation (if any) is furnished
|
||||||
|
# under a license and may only be used or copied in accordance
|
||||||
|
# with the terms of the license. Except as permitted by such
|
||||||
|
# license, no part of this software or documentation may be
|
||||||
|
# reproduced, stored in a retrieval system, or transmitted in any
|
||||||
|
# form or by any means without the express written consent of
|
||||||
|
# Intel Corporation.
|
||||||
|
#
|
||||||
|
##
|
||||||
|
|
||||||
|
|
||||||
|
[Defines]
|
||||||
|
INF_VERSION = 0x00010005
|
||||||
|
BASE_NAME = GetHostByName
|
||||||
|
FILE_GUID = 70FB9CE0-2CB1-4fd7-80EE-AB4B6CF4B43F
|
||||||
|
MODULE_TYPE = UEFI_APPLICATION
|
||||||
|
VERSION_STRING = 1.0
|
||||||
|
ENTRY_POINT = ShellCEntryLib
|
||||||
|
|
||||||
|
#
|
||||||
|
# The following information is for reference only and not required by the build tools.
|
||||||
|
#
|
||||||
|
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||||
|
#
|
||||||
|
|
||||||
|
[Sources]
|
||||||
|
GetHostByName.c
|
||||||
|
|
||||||
|
|
||||||
|
[Packages]
|
||||||
|
MdePkg/MdePkg.dec
|
||||||
|
ShellPkg/ShellPkg.dec
|
||||||
|
StdLib/StdLib.dec
|
||||||
|
|
||||||
|
|
||||||
|
[LibraryClasses]
|
||||||
|
BaseMemoryLib
|
||||||
|
BsdSocketLib
|
||||||
|
DebugLib
|
||||||
|
DevShell
|
||||||
|
EfiSocketLib
|
||||||
|
LibC
|
||||||
|
LibMath
|
||||||
|
LibNetUtil
|
||||||
|
ShellCEntryLib
|
||||||
|
UefiBootServicesTableLib
|
||||||
|
UefiLib
|
||||||
|
# UseSocketDxe
|
||||||
|
|
||||||
|
[BuildOptions]
|
||||||
|
INTEL:*_*_*_CC_FLAGS = /Qdiag-disable:181,186
|
||||||
|
MSFT:*_*_*_CC_FLAGS = /Od
|
||||||
|
GCC:*_*_*_CC_FLAGS = -O0 -Wno-unused-variable
|
||||||
|
|
|
@ -0,0 +1,89 @@
|
||||||
|
/** @file
|
||||||
|
Translate the IPv4 address into a network name
|
||||||
|
|
||||||
|
Copyright (c) 2011, Intel Corporation
|
||||||
|
All rights reserved. This program and the accompanying materials
|
||||||
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <Uefi.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <Library/DebugLib.h>
|
||||||
|
#include <Library/UefiLib.h>
|
||||||
|
|
||||||
|
#include <sys/socket.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
Translate the IPv4 address into a network name
|
||||||
|
|
||||||
|
@param [in] Argc The number of arguments
|
||||||
|
@param [in] Argv The argument value array
|
||||||
|
|
||||||
|
@retval 0 The application exited normally.
|
||||||
|
@retval Other An error occurred.
|
||||||
|
**/
|
||||||
|
int
|
||||||
|
main (
|
||||||
|
IN int Argc,
|
||||||
|
IN char **Argv
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UINT32 RemoteAddress[4];
|
||||||
|
UINT8 IpAddress[4];
|
||||||
|
struct netent * pNetwork;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Determine if the IPv4 address is specified
|
||||||
|
//
|
||||||
|
if (( 2 != Argc )
|
||||||
|
|| ( 4 != sscanf ( Argv[1],
|
||||||
|
"%d.%d.%d.%d",
|
||||||
|
&RemoteAddress[0],
|
||||||
|
&RemoteAddress[1],
|
||||||
|
&RemoteAddress[2],
|
||||||
|
&RemoteAddress[3]))
|
||||||
|
|| ( 255 < RemoteAddress [0])
|
||||||
|
|| ( 255 < RemoteAddress [1])
|
||||||
|
|| ( 255 < RemoteAddress [2])
|
||||||
|
|| ( 255 < RemoteAddress [3])) {
|
||||||
|
Print ( L"%a <IPv4 Address>\r\n", Argv[0]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//
|
||||||
|
// Translate the address into a network name
|
||||||
|
//
|
||||||
|
IpAddress[0] = (UINT8)RemoteAddress[0];
|
||||||
|
IpAddress[1] = (UINT8)RemoteAddress[1];
|
||||||
|
IpAddress[2] = (UINT8)RemoteAddress[2];
|
||||||
|
IpAddress[3] = (UINT8)RemoteAddress[3];
|
||||||
|
pNetwork = getnetbyaddr ( *(uint32_t *)&IpAddress[0], AF_INET );
|
||||||
|
if ( NULL == pNetwork ) {
|
||||||
|
Print ( L"ERROR - network not found, errno: %d\r\n", errno );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Print ( L"%a: %d.%d.%d.%d, 0x%08x\r\n",
|
||||||
|
pNetwork->n_name,
|
||||||
|
IpAddress[0],
|
||||||
|
IpAddress[1],
|
||||||
|
IpAddress[2],
|
||||||
|
IpAddress[3],
|
||||||
|
pNetwork->n_net );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// All done
|
||||||
|
//
|
||||||
|
return errno;
|
||||||
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
#/** @file
|
||||||
|
# GetNetByAddr Application
|
||||||
|
#
|
||||||
|
# This file contains an 'Intel Peripheral Driver' and is
|
||||||
|
# licensed for Intel CPUs and chipsets under the terms of your
|
||||||
|
# license agreement with Intel or your vendor. This file may
|
||||||
|
# be modified by the user, subject to additional terms of the
|
||||||
|
# license agreement
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Copyright (c) 20011 Intel Corporation. All rights reserved
|
||||||
|
# This software and associated documentation (if any) is furnished
|
||||||
|
# under a license and may only be used or copied in accordance
|
||||||
|
# with the terms of the license. Except as permitted by such
|
||||||
|
# license, no part of this software or documentation may be
|
||||||
|
# reproduced, stored in a retrieval system, or transmitted in any
|
||||||
|
# form or by any means without the express written consent of
|
||||||
|
# Intel Corporation.
|
||||||
|
#
|
||||||
|
##
|
||||||
|
|
||||||
|
|
||||||
|
[Defines]
|
||||||
|
INF_VERSION = 0x00010005
|
||||||
|
BASE_NAME = GetNetByAddr
|
||||||
|
FILE_GUID = 22198FD5-4835-4842-BF31-EB957C7DD70D
|
||||||
|
MODULE_TYPE = UEFI_APPLICATION
|
||||||
|
VERSION_STRING = 1.0
|
||||||
|
ENTRY_POINT = ShellCEntryLib
|
||||||
|
|
||||||
|
#
|
||||||
|
# The following information is for reference only and not required by the build tools.
|
||||||
|
#
|
||||||
|
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||||
|
#
|
||||||
|
|
||||||
|
[Sources]
|
||||||
|
GetNetByAddr.c
|
||||||
|
|
||||||
|
|
||||||
|
[Packages]
|
||||||
|
MdePkg/MdePkg.dec
|
||||||
|
ShellPkg/ShellPkg.dec
|
||||||
|
StdLib/StdLib.dec
|
||||||
|
|
||||||
|
|
||||||
|
[LibraryClasses]
|
||||||
|
BaseMemoryLib
|
||||||
|
BsdSocketLib
|
||||||
|
DebugLib
|
||||||
|
DevShell
|
||||||
|
EfiSocketLib
|
||||||
|
LibC
|
||||||
|
LibMath
|
||||||
|
LibNetUtil
|
||||||
|
ShellCEntryLib
|
||||||
|
UefiBootServicesTableLib
|
||||||
|
UefiLib
|
||||||
|
# UseSocketDxe
|
||||||
|
|
||||||
|
[BuildOptions]
|
||||||
|
INTEL:*_*_*_CC_FLAGS = /Qdiag-disable:181,186
|
||||||
|
MSFT:*_*_*_CC_FLAGS = /Od
|
||||||
|
GCC:*_*_*_CC_FLAGS = -O0 -Wno-unused-variable
|
||||||
|
|
|
@ -0,0 +1,83 @@
|
||||||
|
/** @file
|
||||||
|
Translate the network name into an IP address
|
||||||
|
|
||||||
|
Copyright (c) 2011, Intel Corporation
|
||||||
|
All rights reserved. This program and the accompanying materials
|
||||||
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <Uefi.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <Library/DebugLib.h>
|
||||||
|
#include <Library/UefiLib.h>
|
||||||
|
|
||||||
|
#include <sys/socket.h>
|
||||||
|
|
||||||
|
char mBuffer [65536];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Translate the network name into an IP address
|
||||||
|
|
||||||
|
@param [in] Argc The number of arguments
|
||||||
|
@param [in] Argv The argument value array
|
||||||
|
|
||||||
|
@retval 0 The application exited normally.
|
||||||
|
@retval Other An error occurred.
|
||||||
|
**/
|
||||||
|
int
|
||||||
|
main (
|
||||||
|
IN int Argc,
|
||||||
|
IN char **Argv
|
||||||
|
)
|
||||||
|
{
|
||||||
|
int AppStatus;
|
||||||
|
UINT8 * pIpAddress;
|
||||||
|
struct netent * pNetwork;
|
||||||
|
|
||||||
|
DEBUG (( DEBUG_INFO,
|
||||||
|
"%a starting\r\n",
|
||||||
|
Argv[0]));
|
||||||
|
|
||||||
|
//
|
||||||
|
// Determine if the network name is specified
|
||||||
|
//
|
||||||
|
AppStatus = 0;
|
||||||
|
if ( 1 == Argc ) {
|
||||||
|
Print ( L"%a <network name>\r\n", Argv[0]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//
|
||||||
|
// Translate the net name
|
||||||
|
//
|
||||||
|
pNetwork = getnetbyname ( Argv[1]);
|
||||||
|
if ( NULL == pNetwork ) {
|
||||||
|
Print ( L"ERROR - network not found, errno: %d\r\n", errno );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
pIpAddress = (UINT8 *)pNetwork->n_net;
|
||||||
|
Print ( L"%a: Type %d, %d.%d.%d.%d\r\n",
|
||||||
|
pNetwork->n_name,
|
||||||
|
pNetwork->n_addrtype,
|
||||||
|
pIpAddress[0],
|
||||||
|
pIpAddress[1],
|
||||||
|
pIpAddress[2],
|
||||||
|
pIpAddress[3]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// All done
|
||||||
|
//
|
||||||
|
return errno;
|
||||||
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
#/** @file
|
||||||
|
# GetNetByName Application
|
||||||
|
#
|
||||||
|
# This file contains an 'Intel Peripheral Driver' and is
|
||||||
|
# licensed for Intel CPUs and chipsets under the terms of your
|
||||||
|
# license agreement with Intel or your vendor. This file may
|
||||||
|
# be modified by the user, subject to additional terms of the
|
||||||
|
# license agreement
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Copyright (c) 20011 Intel Corporation. All rights reserved
|
||||||
|
# This software and associated documentation (if any) is furnished
|
||||||
|
# under a license and may only be used or copied in accordance
|
||||||
|
# with the terms of the license. Except as permitted by such
|
||||||
|
# license, no part of this software or documentation may be
|
||||||
|
# reproduced, stored in a retrieval system, or transmitted in any
|
||||||
|
# form or by any means without the express written consent of
|
||||||
|
# Intel Corporation.
|
||||||
|
#
|
||||||
|
##
|
||||||
|
|
||||||
|
|
||||||
|
[Defines]
|
||||||
|
INF_VERSION = 0x00010005
|
||||||
|
BASE_NAME = GetNetByName
|
||||||
|
FILE_GUID = DAF7B0E6-32DE-4619-B63A-2B9173A75B14
|
||||||
|
MODULE_TYPE = UEFI_APPLICATION
|
||||||
|
VERSION_STRING = 1.0
|
||||||
|
ENTRY_POINT = ShellCEntryLib
|
||||||
|
|
||||||
|
#
|
||||||
|
# The following information is for reference only and not required by the build tools.
|
||||||
|
#
|
||||||
|
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||||
|
#
|
||||||
|
|
||||||
|
[Sources]
|
||||||
|
GetNetByName.c
|
||||||
|
|
||||||
|
|
||||||
|
[Packages]
|
||||||
|
MdePkg/MdePkg.dec
|
||||||
|
ShellPkg/ShellPkg.dec
|
||||||
|
StdLib/StdLib.dec
|
||||||
|
|
||||||
|
|
||||||
|
[LibraryClasses]
|
||||||
|
BaseMemoryLib
|
||||||
|
BsdSocketLib
|
||||||
|
DebugLib
|
||||||
|
DevShell
|
||||||
|
EfiSocketLib
|
||||||
|
LibC
|
||||||
|
LibMath
|
||||||
|
LibNetUtil
|
||||||
|
ShellCEntryLib
|
||||||
|
UefiBootServicesTableLib
|
||||||
|
UefiLib
|
||||||
|
# UseSocketDxe
|
||||||
|
|
||||||
|
[BuildOptions]
|
||||||
|
INTEL:*_*_*_CC_FLAGS = /Qdiag-disable:181,186
|
||||||
|
MSFT:*_*_*_CC_FLAGS = /Od
|
||||||
|
GCC:*_*_*_CC_FLAGS = -O0 -Wno-unused-variable
|
||||||
|
|
|
@ -0,0 +1,76 @@
|
||||||
|
/** @file
|
||||||
|
Translate the service name into a port number
|
||||||
|
|
||||||
|
Copyright (c) 2011, Intel Corporation
|
||||||
|
All rights reserved. This program and the accompanying materials
|
||||||
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <Uefi.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <Library/DebugLib.h>
|
||||||
|
#include <Library/UefiLib.h>
|
||||||
|
|
||||||
|
#include <sys/socket.h>
|
||||||
|
|
||||||
|
char mBuffer [65536];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Translate the service name into a port number
|
||||||
|
|
||||||
|
@param [in] Argc The number of arguments
|
||||||
|
@param [in] Argv The argument value array
|
||||||
|
|
||||||
|
@retval 0 The application exited normally.
|
||||||
|
@retval Other An error occurred.
|
||||||
|
**/
|
||||||
|
int
|
||||||
|
main (
|
||||||
|
IN int Argc,
|
||||||
|
IN char **Argv
|
||||||
|
)
|
||||||
|
{
|
||||||
|
int AppStatus;
|
||||||
|
int PortNumber;
|
||||||
|
struct servent * pService;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Determine if the service name is specified
|
||||||
|
//
|
||||||
|
AppStatus = 0;
|
||||||
|
if ( 1 == Argc ) {
|
||||||
|
Print ( L"%a <service name>\r\n", Argv[0]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//
|
||||||
|
// Translate the service name
|
||||||
|
//
|
||||||
|
pService = getservbyname ( Argv[1], NULL );
|
||||||
|
if ( NULL == pService ) {
|
||||||
|
Print ( L"ERROR - service not found, errno: %d\r\n", errno );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
PortNumber = htons ( pService->s_port );
|
||||||
|
Print ( L"%a: %d, %a\r\n",
|
||||||
|
pService->s_name,
|
||||||
|
PortNumber,
|
||||||
|
pService->s_proto );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// All done
|
||||||
|
//
|
||||||
|
return errno;
|
||||||
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
#/** @file
|
||||||
|
# GetServByName Application
|
||||||
|
#
|
||||||
|
# This file contains an 'Intel Peripheral Driver' and is
|
||||||
|
# licensed for Intel CPUs and chipsets under the terms of your
|
||||||
|
# license agreement with Intel or your vendor. This file may
|
||||||
|
# be modified by the user, subject to additional terms of the
|
||||||
|
# license agreement
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Copyright (c) 20011 Intel Corporation. All rights reserved
|
||||||
|
# This software and associated documentation (if any) is furnished
|
||||||
|
# under a license and may only be used or copied in accordance
|
||||||
|
# with the terms of the license. Except as permitted by such
|
||||||
|
# license, no part of this software or documentation may be
|
||||||
|
# reproduced, stored in a retrieval system, or transmitted in any
|
||||||
|
# form or by any means without the express written consent of
|
||||||
|
# Intel Corporation.
|
||||||
|
#
|
||||||
|
##
|
||||||
|
|
||||||
|
|
||||||
|
[Defines]
|
||||||
|
INF_VERSION = 0x00010005
|
||||||
|
BASE_NAME = GetServByName
|
||||||
|
FILE_GUID = 5D1F3F9E-8CEE-4299-93C2-4C64EBB58977
|
||||||
|
MODULE_TYPE = UEFI_APPLICATION
|
||||||
|
VERSION_STRING = 1.0
|
||||||
|
ENTRY_POINT = ShellCEntryLib
|
||||||
|
|
||||||
|
#
|
||||||
|
# The following information is for reference only and not required by the build tools.
|
||||||
|
#
|
||||||
|
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||||
|
#
|
||||||
|
|
||||||
|
[Sources]
|
||||||
|
GetServByName.c
|
||||||
|
|
||||||
|
|
||||||
|
[Packages]
|
||||||
|
MdePkg/MdePkg.dec
|
||||||
|
ShellPkg/ShellPkg.dec
|
||||||
|
StdLib/StdLib.dec
|
||||||
|
|
||||||
|
|
||||||
|
[LibraryClasses]
|
||||||
|
BaseMemoryLib
|
||||||
|
BsdSocketLib
|
||||||
|
DebugLib
|
||||||
|
DevShell
|
||||||
|
EfiSocketLib
|
||||||
|
LibC
|
||||||
|
LibMath
|
||||||
|
LibNetUtil
|
||||||
|
ShellCEntryLib
|
||||||
|
UefiBootServicesTableLib
|
||||||
|
UefiLib
|
||||||
|
# UseSocketDxe
|
||||||
|
|
||||||
|
[BuildOptions]
|
||||||
|
INTEL:*_*_*_CC_FLAGS = /Qdiag-disable:181,186
|
||||||
|
MSFT:*_*_*_CC_FLAGS = /Od
|
||||||
|
GCC:*_*_*_CC_FLAGS = -O0 -Wno-unused-variable
|
||||||
|
|
|
@ -0,0 +1,77 @@
|
||||||
|
/** @file
|
||||||
|
Translate the port number into a service name
|
||||||
|
|
||||||
|
Copyright (c) 2011, Intel Corporation
|
||||||
|
All rights reserved. This program and the accompanying materials
|
||||||
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <Uefi.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <Library/DebugLib.h>
|
||||||
|
#include <Library/UefiLib.h>
|
||||||
|
|
||||||
|
#include <sys/socket.h>
|
||||||
|
|
||||||
|
char mBuffer [65536];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Translate the port number into a service name
|
||||||
|
|
||||||
|
@param [in] Argc The number of arguments
|
||||||
|
@param [in] Argv The argument value array
|
||||||
|
|
||||||
|
@retval 0 The application exited normally.
|
||||||
|
@retval Other An error occurred.
|
||||||
|
**/
|
||||||
|
int
|
||||||
|
main (
|
||||||
|
IN int Argc,
|
||||||
|
IN char **Argv
|
||||||
|
)
|
||||||
|
{
|
||||||
|
int AppStatus;
|
||||||
|
int PortNumber;
|
||||||
|
struct servent * pService;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Determine if the service name is specified
|
||||||
|
//
|
||||||
|
AppStatus = 0;
|
||||||
|
if (( 2 != Argc )
|
||||||
|
|| ( 1 != sscanf ( Argv[1], "%d", &PortNumber ))) {
|
||||||
|
Print ( L"%a <port number>\r\n", Argv[0]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//
|
||||||
|
// Translate the port number
|
||||||
|
//
|
||||||
|
pService = getservbyport ( htons ( PortNumber ), NULL );
|
||||||
|
if ( NULL == pService ) {
|
||||||
|
Print ( L"ERROR - service not found, errno: %d\r\n", errno );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Print ( L"%a: %d, %a\r\n",
|
||||||
|
pService->s_name,
|
||||||
|
PortNumber,
|
||||||
|
pService->s_proto );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// All done
|
||||||
|
//
|
||||||
|
return errno;
|
||||||
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
#/** @file
|
||||||
|
# GetServByPort Application
|
||||||
|
#
|
||||||
|
# This file contains an 'Intel Peripheral Driver' and is
|
||||||
|
# licensed for Intel CPUs and chipsets under the terms of your
|
||||||
|
# license agreement with Intel or your vendor. This file may
|
||||||
|
# be modified by the user, subject to additional terms of the
|
||||||
|
# license agreement
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Copyright (c) 20011 Intel Corporation. All rights reserved
|
||||||
|
# This software and associated documentation (if any) is furnished
|
||||||
|
# under a license and may only be used or copied in accordance
|
||||||
|
# with the terms of the license. Except as permitted by such
|
||||||
|
# license, no part of this software or documentation may be
|
||||||
|
# reproduced, stored in a retrieval system, or transmitted in any
|
||||||
|
# form or by any means without the express written consent of
|
||||||
|
# Intel Corporation.
|
||||||
|
#
|
||||||
|
##
|
||||||
|
|
||||||
|
|
||||||
|
[Defines]
|
||||||
|
INF_VERSION = 0x00010005
|
||||||
|
BASE_NAME = GetServByPort
|
||||||
|
FILE_GUID = 83381B06-2EEA-4cf3-9B5F-D75B9B5C93DE
|
||||||
|
MODULE_TYPE = UEFI_APPLICATION
|
||||||
|
VERSION_STRING = 1.0
|
||||||
|
ENTRY_POINT = ShellCEntryLib
|
||||||
|
|
||||||
|
#
|
||||||
|
# The following information is for reference only and not required by the build tools.
|
||||||
|
#
|
||||||
|
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||||
|
#
|
||||||
|
|
||||||
|
[Sources]
|
||||||
|
GetServByPort.c
|
||||||
|
|
||||||
|
|
||||||
|
[Packages]
|
||||||
|
MdePkg/MdePkg.dec
|
||||||
|
ShellPkg/ShellPkg.dec
|
||||||
|
StdLib/StdLib.dec
|
||||||
|
|
||||||
|
|
||||||
|
[LibraryClasses]
|
||||||
|
BaseMemoryLib
|
||||||
|
BsdSocketLib
|
||||||
|
DebugLib
|
||||||
|
DevShell
|
||||||
|
EfiSocketLib
|
||||||
|
LibC
|
||||||
|
LibMath
|
||||||
|
LibNetUtil
|
||||||
|
ShellCEntryLib
|
||||||
|
UefiBootServicesTableLib
|
||||||
|
UefiLib
|
||||||
|
# UseSocketDxe
|
||||||
|
|
||||||
|
[BuildOptions]
|
||||||
|
INTEL:*_*_*_CC_FLAGS = /Qdiag-disable:181,186
|
||||||
|
MSFT:*_*_*_CC_FLAGS = /Od
|
||||||
|
GCC:*_*_*_CC_FLAGS = -O0 -Wno-unused-variable
|
||||||
|
|
|
@ -0,0 +1,116 @@
|
||||||
|
/** @file
|
||||||
|
Receive a datagram
|
||||||
|
|
||||||
|
Copyright (c) 2011, Intel Corporation
|
||||||
|
All rights reserved. This program and the accompanying materials
|
||||||
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <Uefi.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <Library/DebugLib.h>
|
||||||
|
#include <Library/UefiLib.h>
|
||||||
|
|
||||||
|
#include <netinet/in.h>
|
||||||
|
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
UINT8 mBuffer [ 65536 ];
|
||||||
|
|
||||||
|
/**
|
||||||
|
Receive a datagram
|
||||||
|
|
||||||
|
@param [in] Argc The number of arguments
|
||||||
|
@param [in] Argv The argument value array
|
||||||
|
|
||||||
|
@retval 0 The application exited normally.
|
||||||
|
@retval Other An error occurred.
|
||||||
|
**/
|
||||||
|
int
|
||||||
|
main (
|
||||||
|
IN int Argc,
|
||||||
|
IN char **Argv
|
||||||
|
)
|
||||||
|
{
|
||||||
|
struct sockaddr_in Address;
|
||||||
|
socklen_t AddressLength;
|
||||||
|
ssize_t LengthInBytes;
|
||||||
|
int s;
|
||||||
|
int Status;
|
||||||
|
struct timeval Timeout;
|
||||||
|
|
||||||
|
|
||||||
|
DEBUG (( DEBUG_INFO,
|
||||||
|
"%a starting\r\n",
|
||||||
|
Argv[0]));
|
||||||
|
|
||||||
|
//
|
||||||
|
// Get the socket
|
||||||
|
//
|
||||||
|
s = socket ( AF_INET, SOCK_DGRAM, 0 );
|
||||||
|
if ( -1 == s ) {
|
||||||
|
Print ( L"ERROR - Unable to open the socket, errno: %d\r\n", errno );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Timeout.tv_sec = 5;
|
||||||
|
Timeout.tv_usec = 0;
|
||||||
|
Status = setsockopt ( s,
|
||||||
|
SOL_SOCKET,
|
||||||
|
SO_RCVTIMEO,
|
||||||
|
&Timeout,
|
||||||
|
sizeof ( Timeout ));
|
||||||
|
if ( -1 == Status ) {
|
||||||
|
Print ( L"ERROR - Unable to set the receive timeout, errno: %d\r\n", errno );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
AddressLength = sizeof ( Address );
|
||||||
|
LengthInBytes = recvfrom ( s,
|
||||||
|
&mBuffer[0],
|
||||||
|
sizeof ( mBuffer[0]),
|
||||||
|
0,
|
||||||
|
(struct sockaddr *)&Address,
|
||||||
|
&AddressLength );
|
||||||
|
if ( -1 == LengthInBytes ) {
|
||||||
|
if ( ETIMEDOUT == errno ) {
|
||||||
|
Print ( L"No datagram received\r\n" );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Print ( L"ERROR - No datagram received, errno: %d\r\n", errno );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Print ( L"Received %d bytes from %d.%d.%d.%d:%d\r\n",
|
||||||
|
LengthInBytes,
|
||||||
|
(UINT8)Address.sin_addr.s_addr,
|
||||||
|
(UINT8)( Address.sin_addr.s_addr >> 8 ),
|
||||||
|
(UINT8)( Address.sin_addr.s_addr >> 16 ),
|
||||||
|
(UINT8)( Address.sin_addr.s_addr >> 24 ),
|
||||||
|
htons ( Address.sin_port ));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Done with the socket
|
||||||
|
//
|
||||||
|
close ( s );
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// All done
|
||||||
|
//
|
||||||
|
DEBUG (( DEBUG_INFO,
|
||||||
|
"%a exiting, errno: %d\r\n",
|
||||||
|
Argv[0],
|
||||||
|
errno ));
|
||||||
|
return errno;
|
||||||
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
#/** @file
|
||||||
|
# Receive Datagram Application
|
||||||
|
#
|
||||||
|
# This file contains an 'Intel Peripheral Driver' and is
|
||||||
|
# licensed for Intel CPUs and chipsets under the terms of your
|
||||||
|
# license agreement with Intel or your vendor. This file may
|
||||||
|
# be modified by the user, subject to additional terms of the
|
||||||
|
# license agreement
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Copyright (c) 20011 Intel Corporation. All rights reserved
|
||||||
|
# This software and associated documentation (if any) is furnished
|
||||||
|
# under a license and may only be used or copied in accordance
|
||||||
|
# with the terms of the license. Except as permitted by such
|
||||||
|
# license, no part of this software or documentation may be
|
||||||
|
# reproduced, stored in a retrieval system, or transmitted in any
|
||||||
|
# form or by any means without the express written consent of
|
||||||
|
# Intel Corporation.
|
||||||
|
#
|
||||||
|
##
|
||||||
|
|
||||||
|
|
||||||
|
[Defines]
|
||||||
|
INF_VERSION = 0x00010005
|
||||||
|
BASE_NAME = RecvDgram
|
||||||
|
FILE_GUID = 929189C9-0670-4c0b-AF7D-135D1550C8C0
|
||||||
|
MODULE_TYPE = UEFI_APPLICATION
|
||||||
|
VERSION_STRING = 1.0
|
||||||
|
ENTRY_POINT = ShellCEntryLib
|
||||||
|
|
||||||
|
#
|
||||||
|
# The following information is for reference only and not required by the build tools.
|
||||||
|
#
|
||||||
|
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||||
|
#
|
||||||
|
|
||||||
|
[Sources]
|
||||||
|
RecvDgram.c
|
||||||
|
|
||||||
|
|
||||||
|
[Packages]
|
||||||
|
MdePkg/MdePkg.dec
|
||||||
|
ShellPkg/ShellPkg.dec
|
||||||
|
StdLib/StdLib.dec
|
||||||
|
|
||||||
|
|
||||||
|
[LibraryClasses]
|
||||||
|
BaseMemoryLib
|
||||||
|
BsdSocketLib
|
||||||
|
DebugLib
|
||||||
|
DevShell
|
||||||
|
EfiSocketLib
|
||||||
|
LibC
|
||||||
|
LibMath
|
||||||
|
ShellCEntryLib
|
||||||
|
UefiBootServicesTableLib
|
||||||
|
UefiLib
|
||||||
|
# UseSocketDxe
|
||||||
|
|
||||||
|
[BuildOptions]
|
||||||
|
INTEL:*_*_*_CC_FLAGS = /Qdiag-disable:181,186
|
||||||
|
MSFT:*_*_*_CC_FLAGS = /Od
|
||||||
|
GCC:*_*_*_CC_FLAGS = -O0 -Wno-unused-variable
|
||||||
|
|
|
@ -0,0 +1,100 @@
|
||||||
|
/** @file
|
||||||
|
Set the host name
|
||||||
|
|
||||||
|
Copyright (c) 2011, Intel Corporation
|
||||||
|
All rights reserved. This program and the accompanying materials
|
||||||
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <Uefi.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <Library/DebugLib.h>
|
||||||
|
#include <Library/UefiLib.h>
|
||||||
|
|
||||||
|
#include <sys/socket.h>
|
||||||
|
|
||||||
|
char mBuffer [65536];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Set the host name
|
||||||
|
|
||||||
|
@param [in] Argc The number of arguments
|
||||||
|
@param [in] Argv The argument value array
|
||||||
|
|
||||||
|
@retval 0 The application exited normally.
|
||||||
|
@retval Other An error occurred.
|
||||||
|
**/
|
||||||
|
int
|
||||||
|
main (
|
||||||
|
IN int Argc,
|
||||||
|
IN char **Argv
|
||||||
|
)
|
||||||
|
{
|
||||||
|
int AppStatus;
|
||||||
|
|
||||||
|
DEBUG (( DEBUG_INFO,
|
||||||
|
"%a starting\r\n",
|
||||||
|
Argv[0]));
|
||||||
|
|
||||||
|
//
|
||||||
|
// Determine if the host name is specified
|
||||||
|
//
|
||||||
|
AppStatus = 0;
|
||||||
|
if ( 1 < Argc ) {
|
||||||
|
//
|
||||||
|
// Set the host name
|
||||||
|
//
|
||||||
|
AppStatus = sethostname ( Argv[1], strlen ( Argv[1]));
|
||||||
|
if ( -1 == AppStatus ) {
|
||||||
|
switch ( errno ) {
|
||||||
|
default:
|
||||||
|
Print ( L"ERROR - errno: %d\r\n", errno );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ENODEV:
|
||||||
|
Print ( L"WARNING - Plarform does not support permanent storage!\r\n" );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ENOMEM:
|
||||||
|
Print ( L"ERROR - Insufficient storage to save host name!\r\n" );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ENOTSUP:
|
||||||
|
Print ( L"ERROR - Platform does not support environment variable storage!\r\n" );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//
|
||||||
|
// Display the current host name
|
||||||
|
//
|
||||||
|
AppStatus = gethostname ( &mBuffer[0], sizeof ( mBuffer ));
|
||||||
|
if ( -1 == AppStatus ) {
|
||||||
|
Print ( L"ERROR - Unable to get host name, errno: %d\r\n", errno );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ( 0 == mBuffer[0]) {
|
||||||
|
Print ( L"Host name is not set!\r\n" );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Print ( L"Host name: %a", &mBuffer[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// All done
|
||||||
|
//
|
||||||
|
return errno;
|
||||||
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
#/** @file
|
||||||
|
# SetHostName Application
|
||||||
|
#
|
||||||
|
# This file contains an 'Intel Peripheral Driver' and is
|
||||||
|
# licensed for Intel CPUs and chipsets under the terms of your
|
||||||
|
# license agreement with Intel or your vendor. This file may
|
||||||
|
# be modified by the user, subject to additional terms of the
|
||||||
|
# license agreement
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Copyright (c) 20011 Intel Corporation. All rights reserved
|
||||||
|
# This software and associated documentation (if any) is furnished
|
||||||
|
# under a license and may only be used or copied in accordance
|
||||||
|
# with the terms of the license. Except as permitted by such
|
||||||
|
# license, no part of this software or documentation may be
|
||||||
|
# reproduced, stored in a retrieval system, or transmitted in any
|
||||||
|
# form or by any means without the express written consent of
|
||||||
|
# Intel Corporation.
|
||||||
|
#
|
||||||
|
##
|
||||||
|
|
||||||
|
|
||||||
|
[Defines]
|
||||||
|
INF_VERSION = 0x00010005
|
||||||
|
BASE_NAME = SetHostName
|
||||||
|
FILE_GUID = 4BC80B15-255D-4858-8072-51D6D98CF90E
|
||||||
|
MODULE_TYPE = UEFI_APPLICATION
|
||||||
|
VERSION_STRING = 1.0
|
||||||
|
ENTRY_POINT = ShellCEntryLib
|
||||||
|
|
||||||
|
#
|
||||||
|
# The following information is for reference only and not required by the build tools.
|
||||||
|
#
|
||||||
|
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||||
|
#
|
||||||
|
|
||||||
|
[Sources]
|
||||||
|
SetHostName.c
|
||||||
|
|
||||||
|
|
||||||
|
[Packages]
|
||||||
|
MdePkg/MdePkg.dec
|
||||||
|
ShellPkg/ShellPkg.dec
|
||||||
|
StdLib/StdLib.dec
|
||||||
|
|
||||||
|
|
||||||
|
[LibraryClasses]
|
||||||
|
BaseMemoryLib
|
||||||
|
BsdSocketLib
|
||||||
|
DebugLib
|
||||||
|
DevShell
|
||||||
|
EfiSocketLib
|
||||||
|
LibC
|
||||||
|
LibMath
|
||||||
|
ShellCEntryLib
|
||||||
|
UefiBootServicesTableLib
|
||||||
|
UefiLib
|
||||||
|
# UseSocketDxe
|
||||||
|
|
||||||
|
[BuildOptions]
|
||||||
|
INTEL:*_*_*_CC_FLAGS = /Qdiag-disable:181,186
|
||||||
|
MSFT:*_*_*_CC_FLAGS = /Od
|
||||||
|
GCC:*_*_*_CC_FLAGS = -O0 -Wno-unused-variable
|
||||||
|
|
|
@ -0,0 +1,379 @@
|
||||||
|
/** @file
|
||||||
|
Set the socket options
|
||||||
|
|
||||||
|
Copyright (c) 2011, Intel Corporation
|
||||||
|
All rights reserved. This program and the accompanying materials
|
||||||
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <Uefi.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <Library/DebugLib.h>
|
||||||
|
#include <Library/UefiLib.h>
|
||||||
|
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
typedef enum _DATA_TYPE {
|
||||||
|
DATA_TYPE_UNKNOWN = 0,
|
||||||
|
DATA_TYPE_INT32_DECIMAL,
|
||||||
|
DATA_TYPE_SOCKET_TYPE,
|
||||||
|
DATA_TYPE_TIMEVAL
|
||||||
|
} DATA_TYPE;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char * pOptionName;
|
||||||
|
int OptionValue;
|
||||||
|
int OptionLevel;
|
||||||
|
BOOLEAN bSetAllowed;
|
||||||
|
DATA_TYPE DataType;
|
||||||
|
} OPTIONS;
|
||||||
|
|
||||||
|
CONST OPTIONS mOptions [] = {
|
||||||
|
{ "SO_ACCEPTCONN", SO_ACCEPTCONN, SOL_SOCKET, FALSE, DATA_TYPE_UNKNOWN },
|
||||||
|
{ "SO_BROADCAST", SO_BROADCAST, SOL_SOCKET, TRUE, DATA_TYPE_UNKNOWN },
|
||||||
|
{ "SO_DEBUG", SO_DEBUG, SOL_SOCKET, TRUE, DATA_TYPE_UNKNOWN },
|
||||||
|
{ "SO_DONTROUTE", SO_DONTROUTE, SOL_SOCKET, TRUE, DATA_TYPE_UNKNOWN },
|
||||||
|
{ "SO_ERROR", SO_ERROR, SOL_SOCKET, FALSE, DATA_TYPE_UNKNOWN },
|
||||||
|
{ "SO_KEEPALIVE", SO_KEEPALIVE, SOL_SOCKET, TRUE, DATA_TYPE_UNKNOWN },
|
||||||
|
{ "SO_OOBINLINE", SO_OOBINLINE, SOL_SOCKET, TRUE, DATA_TYPE_UNKNOWN },
|
||||||
|
{ "SO_OVERFLOWED", SO_OVERFLOWED, SOL_SOCKET, TRUE, DATA_TYPE_UNKNOWN },
|
||||||
|
{ "SO_RCVBUF", SO_RCVBUF, SOL_SOCKET, TRUE, DATA_TYPE_INT32_DECIMAL },
|
||||||
|
{ "SO_RCVLOWAT", SO_RCVLOWAT, SOL_SOCKET, TRUE, DATA_TYPE_UNKNOWN },
|
||||||
|
{ "SO_RCVTIMEO", SO_RCVTIMEO, SOL_SOCKET, TRUE, DATA_TYPE_TIMEVAL },
|
||||||
|
{ "SO_REUSEADDR", SO_REUSEADDR, SOL_SOCKET, TRUE, DATA_TYPE_UNKNOWN },
|
||||||
|
{ "SO_REUSEPORT", SO_REUSEPORT, SOL_SOCKET, TRUE, DATA_TYPE_UNKNOWN },
|
||||||
|
{ "SO_SNDBUF", SO_SNDBUF, SOL_SOCKET, TRUE, DATA_TYPE_INT32_DECIMAL },
|
||||||
|
{ "SO_SNDLOWAT", SO_SNDLOWAT, SOL_SOCKET, TRUE, DATA_TYPE_UNKNOWN },
|
||||||
|
{ "SO_SNDTIMEO", SO_SNDTIMEO, SOL_SOCKET, TRUE, DATA_TYPE_UNKNOWN },
|
||||||
|
{ "SO_TIMESTAMP", SO_TIMESTAMP, SOL_SOCKET, TRUE, DATA_TYPE_UNKNOWN },
|
||||||
|
{ "SO_TYPE", SO_TYPE, SOL_SOCKET, FALSE, DATA_TYPE_SOCKET_TYPE },
|
||||||
|
{ "SO_USELOOPBACK", SO_USELOOPBACK, SOL_SOCKET, TRUE, DATA_TYPE_UNKNOWN }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
UINT8 mBuffer [ 65536 ];
|
||||||
|
UINT8 mValue [ 65536 ];
|
||||||
|
char * mSocketType [] = {
|
||||||
|
"SOCK_STREAM",
|
||||||
|
"SOCK_DGRAM",
|
||||||
|
"SOCK_RAW",
|
||||||
|
"SOCK_RDM",
|
||||||
|
"SOCK_SEQPACKET"
|
||||||
|
};
|
||||||
|
|
||||||
|
void
|
||||||
|
DisplayOption (
|
||||||
|
CONST OPTIONS * pOption,
|
||||||
|
socklen_t LengthInBytes,
|
||||||
|
BOOLEAN bDisplayUpdate,
|
||||||
|
BOOLEAN bDisplayCrLf
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UINT8 * pEnd;
|
||||||
|
char * pString;
|
||||||
|
union {
|
||||||
|
UINT8 * u8;
|
||||||
|
INT32 * i32;
|
||||||
|
struct timeval * TimeVal;
|
||||||
|
} Value;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Display the value length
|
||||||
|
//
|
||||||
|
if ( !bDisplayUpdate ) {
|
||||||
|
Print ( L"LengthInBytes: %d\r\n", LengthInBytes );
|
||||||
|
Print ( L"%a: ", pOption->pOptionName );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Print ( L" --> " );
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Display the value
|
||||||
|
//
|
||||||
|
Value.u8 = &mBuffer[0];
|
||||||
|
switch ( pOption->DataType )
|
||||||
|
{
|
||||||
|
case DATA_TYPE_UNKNOWN:
|
||||||
|
Print ( L"%a:", pOption->pOptionName );
|
||||||
|
pEnd = &Value.u8 [ LengthInBytes ];
|
||||||
|
while ( pEnd > Value.u8 ) {
|
||||||
|
Print ( L" %02x", *Value.u8 );
|
||||||
|
Value.u8 += 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DATA_TYPE_INT32_DECIMAL:
|
||||||
|
if ( 4 == LengthInBytes ) {
|
||||||
|
Print ( L"%d", *Value.i32 );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
errno = ( 4 > LengthInBytes ) ? EBUFSIZE : ERANGE;
|
||||||
|
Print ( L"\r\nERROR - Invalid length, errno: %d\r\n", errno );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DATA_TYPE_SOCKET_TYPE:
|
||||||
|
if ( 4 == LengthInBytes ) {
|
||||||
|
if (( SOCK_STREAM <= *Value.i32 ) && ( SOCK_SEQPACKET >= *Value.i32 )) {
|
||||||
|
pString = mSocketType [ *Value.i32 - SOCK_STREAM ];
|
||||||
|
Print ( L"%a", pString );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Print ( L"%08x (unknown type)", *Value.i32 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
errno = ( 4 > LengthInBytes ) ? EBUFSIZE : ERANGE;
|
||||||
|
Print ( L"\r\nERROR - Invalid length, errno: %d\r\n", errno );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DATA_TYPE_TIMEVAL:
|
||||||
|
if ( sizeof ( *Value.TimeVal ) == LengthInBytes ) {
|
||||||
|
if (( 0 == Value.TimeVal->tv_sec )
|
||||||
|
&& ( 0 == Value.TimeVal->tv_usec )) {
|
||||||
|
Print ( L"Infinite" );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Print ( L"%d.%06d sec",
|
||||||
|
Value.TimeVal->tv_sec,
|
||||||
|
Value.TimeVal->tv_usec );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
errno = ( 4 > LengthInBytes ) ? EBUFSIZE : ERANGE;
|
||||||
|
Print ( L"\r\nERROR - Invalid length, errno: %d\r\n", errno );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Terminate the line
|
||||||
|
//
|
||||||
|
if ( bDisplayCrLf ) {
|
||||||
|
Print ( L"\r\n" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
socklen_t
|
||||||
|
GetOptionValue (
|
||||||
|
CONST OPTIONS * pOption,
|
||||||
|
char * pValue
|
||||||
|
)
|
||||||
|
{
|
||||||
|
socklen_t BytesToWrite;
|
||||||
|
union {
|
||||||
|
UINT8 * u8;
|
||||||
|
INT32 * i32;
|
||||||
|
struct timeval * TimeVal;
|
||||||
|
} Value;
|
||||||
|
int Values;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Assume failure
|
||||||
|
//
|
||||||
|
errno = EINVAL;
|
||||||
|
BytesToWrite = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Determine the type of parameter
|
||||||
|
//
|
||||||
|
if ( pOption->bSetAllowed ) {
|
||||||
|
Value.u8 = &mValue[0];
|
||||||
|
switch ( pOption->DataType ) {
|
||||||
|
case DATA_TYPE_INT32_DECIMAL:
|
||||||
|
Values = sscanf ( pValue, "%d", Value.i32 );
|
||||||
|
if ( 1 == Values ) {
|
||||||
|
BytesToWrite = sizeof ( *Value.i32);
|
||||||
|
errno = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DATA_TYPE_TIMEVAL:
|
||||||
|
Values = sscanf ( pValue, "%d.%0d",
|
||||||
|
&Value.TimeVal->tv_sec,
|
||||||
|
&Value.TimeVal->tv_usec );
|
||||||
|
if (( 2 == Values )
|
||||||
|
&& ( 0 <= Value.TimeVal->tv_sec )
|
||||||
|
&& ( 0 <= Value.TimeVal->tv_usec )
|
||||||
|
&& ( 1000000 > Value.TimeVal->tv_usec )){
|
||||||
|
BytesToWrite = sizeof ( *Value.TimeVal );
|
||||||
|
errno = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Display the error
|
||||||
|
//
|
||||||
|
if ( 0 == BytesToWrite ) {
|
||||||
|
Print ( L"ERROR - Invalid value!\r\n" );
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Return the number of bytes to be written
|
||||||
|
//
|
||||||
|
return BytesToWrite;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Set the socket options
|
||||||
|
|
||||||
|
@param [in] Argc The number of arguments
|
||||||
|
@param [in] Argv The argument value array
|
||||||
|
|
||||||
|
@retval 0 The application exited normally.
|
||||||
|
@retval Other An error occurred.
|
||||||
|
**/
|
||||||
|
int
|
||||||
|
main (
|
||||||
|
IN int Argc,
|
||||||
|
IN char **Argv
|
||||||
|
)
|
||||||
|
{
|
||||||
|
socklen_t BytesToWrite;
|
||||||
|
socklen_t LengthInBytes;
|
||||||
|
CONST OPTIONS * pEnd;
|
||||||
|
CONST OPTIONS * pOption;
|
||||||
|
int s;
|
||||||
|
int Status;
|
||||||
|
|
||||||
|
DEBUG (( DEBUG_INFO,
|
||||||
|
"%a starting\r\n",
|
||||||
|
Argv[0]));
|
||||||
|
|
||||||
|
//
|
||||||
|
// Parse the socket option
|
||||||
|
//
|
||||||
|
pOption = &mOptions[0];
|
||||||
|
pEnd = &pOption[sizeof ( mOptions ) / sizeof ( mOptions[0])];
|
||||||
|
if ( 2 <= Argc ) {
|
||||||
|
while ( pEnd > pOption ) {
|
||||||
|
if ( 0 == strcmp ( Argv[1], pOption->pOptionName )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
pOption += 1;
|
||||||
|
}
|
||||||
|
if ( pEnd <= pOption ) {
|
||||||
|
Print ( L"ERROR: Invalid option: %a\r\n", Argv[1]);
|
||||||
|
Argc = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Display the help if necessary
|
||||||
|
//
|
||||||
|
if (( 2 > Argc ) || ( 3 < Argc )) {
|
||||||
|
Print ( L"%a <option>\r\n", Argv[0]);
|
||||||
|
Print ( L"\r\n" );
|
||||||
|
Print ( L"Option one of:\r\n" );
|
||||||
|
pOption = &mOptions[0];
|
||||||
|
while ( pEnd > pOption ) {
|
||||||
|
Print ( L" %a: %a\r\n",
|
||||||
|
pOption->pOptionName,
|
||||||
|
pOption->bSetAllowed ? "get/set" : "get" );
|
||||||
|
pOption += 1;
|
||||||
|
}
|
||||||
|
errno = EINVAL;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//
|
||||||
|
// Determine if the value is to be set
|
||||||
|
//
|
||||||
|
BytesToWrite = 0;
|
||||||
|
if (( 3 > Argc )
|
||||||
|
|| ( 0 < ( BytesToWrite = GetOptionValue ( pOption, Argv [2])))) {
|
||||||
|
//
|
||||||
|
// Get the socket
|
||||||
|
//
|
||||||
|
s = socket ( AF_INET, 0, 0 );
|
||||||
|
if ( -1 == s ) {
|
||||||
|
Print ( L"ERROR - Unable to open the socket, errno: %d\r\n", errno );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//
|
||||||
|
// Display the option value
|
||||||
|
//
|
||||||
|
LengthInBytes = sizeof ( mBuffer );
|
||||||
|
Status = getsockopt ( s,
|
||||||
|
pOption->OptionLevel,
|
||||||
|
pOption->OptionValue,
|
||||||
|
&mBuffer,
|
||||||
|
&LengthInBytes );
|
||||||
|
if ( -1 == Status ) {
|
||||||
|
Print ( L"ERROR - getsockopt failed, errno: %d\r\n", errno );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
DisplayOption ( pOption,
|
||||||
|
LengthInBytes,
|
||||||
|
FALSE,
|
||||||
|
(BOOLEAN)( 0 == BytesToWrite ));
|
||||||
|
|
||||||
|
//
|
||||||
|
// Determine if the value is to be set
|
||||||
|
//
|
||||||
|
if (( 0 < BytesToWrite )
|
||||||
|
&& ( BytesToWrite == LengthInBytes )) {
|
||||||
|
//
|
||||||
|
// Set the option value
|
||||||
|
//
|
||||||
|
Status = setsockopt ( s,
|
||||||
|
pOption->OptionLevel,
|
||||||
|
pOption->OptionValue,
|
||||||
|
&mValue,
|
||||||
|
BytesToWrite );
|
||||||
|
if ( -1 == Status ) {
|
||||||
|
Print ( L"ERROR - setsockopt failed, errno: %d\r\n", errno );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//
|
||||||
|
// Display the updated option value
|
||||||
|
//
|
||||||
|
Status = getsockopt ( s,
|
||||||
|
pOption->OptionLevel,
|
||||||
|
pOption->OptionValue,
|
||||||
|
&mBuffer,
|
||||||
|
&LengthInBytes );
|
||||||
|
if ( -1 == Status ) {
|
||||||
|
Print ( L"ERROR - getsockopt failed, errno: %d\r\n", errno );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
DisplayOption ( pOption,
|
||||||
|
LengthInBytes,
|
||||||
|
TRUE,
|
||||||
|
TRUE );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Done with the socket
|
||||||
|
//
|
||||||
|
close ( s );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// All done
|
||||||
|
//
|
||||||
|
DEBUG (( DEBUG_INFO,
|
||||||
|
"%a exiting, errno: %d\r\n",
|
||||||
|
Argv[0],
|
||||||
|
errno ));
|
||||||
|
return errno;
|
||||||
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
#/** @file
|
||||||
|
# SetHostName Application
|
||||||
|
#
|
||||||
|
# This file contains an 'Intel Peripheral Driver' and is
|
||||||
|
# licensed for Intel CPUs and chipsets under the terms of your
|
||||||
|
# license agreement with Intel or your vendor. This file may
|
||||||
|
# be modified by the user, subject to additional terms of the
|
||||||
|
# license agreement
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Copyright (c) 20011 Intel Corporation. All rights reserved
|
||||||
|
# This software and associated documentation (if any) is furnished
|
||||||
|
# under a license and may only be used or copied in accordance
|
||||||
|
# with the terms of the license. Except as permitted by such
|
||||||
|
# license, no part of this software or documentation may be
|
||||||
|
# reproduced, stored in a retrieval system, or transmitted in any
|
||||||
|
# form or by any means without the express written consent of
|
||||||
|
# Intel Corporation.
|
||||||
|
#
|
||||||
|
##
|
||||||
|
|
||||||
|
|
||||||
|
[Defines]
|
||||||
|
INF_VERSION = 0x00010005
|
||||||
|
BASE_NAME = SetSockOpt
|
||||||
|
FILE_GUID = 6E851687-A7A9-4aa2-8DD0-673E03E51433
|
||||||
|
MODULE_TYPE = UEFI_APPLICATION
|
||||||
|
VERSION_STRING = 1.0
|
||||||
|
ENTRY_POINT = ShellCEntryLib
|
||||||
|
|
||||||
|
#
|
||||||
|
# The following information is for reference only and not required by the build tools.
|
||||||
|
#
|
||||||
|
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||||
|
#
|
||||||
|
|
||||||
|
[Sources]
|
||||||
|
SetSockOpt.c
|
||||||
|
|
||||||
|
|
||||||
|
[Packages]
|
||||||
|
MdePkg/MdePkg.dec
|
||||||
|
ShellPkg/ShellPkg.dec
|
||||||
|
StdLib/StdLib.dec
|
||||||
|
|
||||||
|
|
||||||
|
[LibraryClasses]
|
||||||
|
BaseMemoryLib
|
||||||
|
BsdSocketLib
|
||||||
|
DebugLib
|
||||||
|
DevShell
|
||||||
|
EfiSocketLib
|
||||||
|
LibC
|
||||||
|
LibMath
|
||||||
|
ShellCEntryLib
|
||||||
|
UefiBootServicesTableLib
|
||||||
|
UefiLib
|
||||||
|
# UseSocketDxe
|
||||||
|
|
||||||
|
[BuildOptions]
|
||||||
|
INTEL:*_*_*_CC_FLAGS = /Qdiag-disable:181,186
|
||||||
|
MSFT:*_*_*_CC_FLAGS = /Od
|
||||||
|
GCC:*_*_*_CC_FLAGS = -O0 -Wno-unused-variable
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,331 @@
|
||||||
|
/** @file
|
||||||
|
Definitions for the TFTP server.
|
||||||
|
|
||||||
|
Copyright (c) 2011, Intel Corporation
|
||||||
|
All rights reserved. This program and the accompanying materials
|
||||||
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#ifndef _TFTP_SERVER_H_
|
||||||
|
#define _TFTP_SERVER_H_
|
||||||
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <Uefi.h>
|
||||||
|
|
||||||
|
#include <Guid/EventGroup.h>
|
||||||
|
|
||||||
|
#include <Library/BaseMemoryLib.h>
|
||||||
|
#include <Library/DebugLib.h>
|
||||||
|
#include <Library/PcdLib.h>
|
||||||
|
#include <Library/UefiApplicationEntryPoint.h>
|
||||||
|
#include <Library/UefiBootServicesTableLib.h>
|
||||||
|
#include <Library/UefiLib.h>
|
||||||
|
#include <Protocol/BlockIo.h>
|
||||||
|
|
||||||
|
#include <netinet/in.h>
|
||||||
|
|
||||||
|
#include <sys/EfiSysCall.h>
|
||||||
|
#include <sys/poll.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// Macros
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#if defined(_MSC_VER) /* Handle Microsoft VC++ compiler specifics. */
|
||||||
|
#define DBG_ENTER() DEBUG (( DEBUG_INFO, "Entering " __FUNCTION__ "\n" )) ///< Display routine entry
|
||||||
|
#define DBG_EXIT() DEBUG (( DEBUG_INFO, "Exiting " __FUNCTION__ "\n" )) ///< Display routine exit
|
||||||
|
#define DBG_EXIT_DEC(Status) DEBUG (( DEBUG_INFO, "Exiting " __FUNCTION__ ", Status: %d\n", Status )) ///< Display routine exit with decimal value
|
||||||
|
#define DBG_EXIT_HEX(Status) DEBUG (( DEBUG_INFO, "Exiting " __FUNCTION__ ", Status: 0x%08x\n", Status )) ///< Display routine exit with hex value
|
||||||
|
#define DBG_EXIT_STATUS(Status) DEBUG (( DEBUG_INFO, "Exiting " __FUNCTION__ ", Status: %r\n", Status )) ///< Display routine exit with status value
|
||||||
|
#define DBG_EXIT_TF(Status) DEBUG (( DEBUG_INFO, "Exiting " __FUNCTION__ ", returning %s\n", (FALSE == Status) ? L"FALSE" : L"TRUE" )) ///< Display routine with TRUE/FALSE value
|
||||||
|
#else // _MSC_VER
|
||||||
|
#define DBG_ENTER()
|
||||||
|
#define DBG_EXIT()
|
||||||
|
#define DBG_EXIT_DEC(Status)
|
||||||
|
#define DBG_EXIT_HEX(Status)
|
||||||
|
#define DBG_EXIT_STATUS(Status)
|
||||||
|
#define DBG_EXIT_TF(Status)
|
||||||
|
#endif // _MSC_VER
|
||||||
|
|
||||||
|
#define DIM(x) ( sizeof ( x ) / sizeof ( x[0] )) ///< Compute the number of entries in an array
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// Constants
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#define DEBUG_SOCKET_POLL 0x40000000 ///< Display the socket poll messages
|
||||||
|
#define DEBUG_PORT_WORK 0x20000000 ///< Display the port work messages
|
||||||
|
#define DEBUG_SERVER_TIMER 0x10000000 ///< Display the socket poll messages
|
||||||
|
#define DEBUG_TFTP_PORT 0x08000000 ///< Display the TFTP port messages
|
||||||
|
#define DEBUG_TFTP_REQUEST 0x04000000 ///< Display the TFTP request messages
|
||||||
|
#define DEBUG_TX 0x02000000 ///< Display transmit messages
|
||||||
|
#define DEBUG_RX 0x01000000 ///< Display receive messages
|
||||||
|
#define DEBUG_TFTP_ACK 0x00800000 ///< Display the TFTP ACK messages
|
||||||
|
|
||||||
|
#define TFTP_PORT_POLL_DELAY ( 2 * 1000 ) ///< Delay in milliseconds for attempts to open the TFTP port
|
||||||
|
#define CLIENT_POLL_DELAY 50 ///< Delay in milliseconds between client polls
|
||||||
|
|
||||||
|
#define TPL_TFTP_SERVER TPL_CALLBACK ///< TPL for routine synchronization
|
||||||
|
|
||||||
|
/**
|
||||||
|
Verify new TPL value
|
||||||
|
|
||||||
|
This macro which is enabled when debug is enabled verifies that
|
||||||
|
the new TPL value is >= the current TPL value.
|
||||||
|
**/
|
||||||
|
#ifdef VERIFY_TPL
|
||||||
|
#undef VERIFY_TPL
|
||||||
|
#endif // VERIFY_TPL
|
||||||
|
|
||||||
|
#if !defined(MDEPKG_NDEBUG)
|
||||||
|
|
||||||
|
#define VERIFY_TPL(tpl) \
|
||||||
|
{ \
|
||||||
|
EFI_TPL PreviousTpl; \
|
||||||
|
\
|
||||||
|
PreviousTpl = gBS->RaiseTPL ( TPL_HIGH_LEVEL ); \
|
||||||
|
gBS->RestoreTPL ( PreviousTpl ); \
|
||||||
|
if ( PreviousTpl > tpl ) { \
|
||||||
|
DEBUG (( DEBUG_ERROR, "Current TPL: %d, New TPL: %d\r\n", PreviousTpl, tpl )); \
|
||||||
|
ASSERT ( PreviousTpl <= tpl ); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
|
#else // MDEPKG_NDEBUG
|
||||||
|
|
||||||
|
#define VERIFY_TPL(tpl)
|
||||||
|
|
||||||
|
#endif // MDEPKG_NDEBUG
|
||||||
|
|
||||||
|
#define TFTP_SERVER_SIGNATURE SIGNATURE_32('T','F','T','P') ///< TSDT_TFTP_SERVER memory signature
|
||||||
|
|
||||||
|
//
|
||||||
|
// See: http://www.rfc-editor.org/rfc/pdfrfc/rfc1350.txt.pdf
|
||||||
|
//
|
||||||
|
// TFTP Operations
|
||||||
|
//
|
||||||
|
|
||||||
|
#define TFTP_OP_READ_REQUEST 1 ///< Read request, zero terminated file name, zero terminated mode
|
||||||
|
#define TFTP_OP_WRITE_REQUEST 2 ///< Write request, zero terminated file name, zero terminated mode
|
||||||
|
#define TFTP_OP_DATA 3 ///< Data block, end-of-file indicated by short block
|
||||||
|
#define TFTP_OP_ACK 4 ///< ACK block number
|
||||||
|
#define TFTP_OP_ERROR 5 ///< Error number and explaination
|
||||||
|
#define TFTP_OP_OACK 6 ///< ACK the options
|
||||||
|
|
||||||
|
#define TFTP_MAX_BLOCK_SIZE 4096 ///< Maximum block size
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// Data Types
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
Port control structure
|
||||||
|
**/
|
||||||
|
typedef struct _TSDT_CONNECTION_CONTEXT TSDT_CONNECTION_CONTEXT;
|
||||||
|
typedef struct _TSDT_CONNECTION_CONTEXT {
|
||||||
|
//
|
||||||
|
// Remote connection management
|
||||||
|
//
|
||||||
|
TSDT_CONNECTION_CONTEXT * pNext; ///< Next context in the connection list
|
||||||
|
struct sockaddr_in RemoteAddress; ///< Remote address
|
||||||
|
|
||||||
|
//
|
||||||
|
// TFTP management parameters
|
||||||
|
//
|
||||||
|
UINT16 AckNext; ///< Next block to be received
|
||||||
|
BOOLEAN bExpectAck; ///< TRUE for read, FALSE for write
|
||||||
|
UINT32 BlockSize; ///< Negotiated block size
|
||||||
|
UINT32 Timeout; ///< Number of seconds to wait before retransmission
|
||||||
|
|
||||||
|
//
|
||||||
|
// File management parameters
|
||||||
|
//
|
||||||
|
EFI_HANDLE File; ///< NULL while file is closed
|
||||||
|
UINT64 LengthInBytes; ///< Size of the file
|
||||||
|
UINT64 MaxTransferSize; ///< Maximum transfer size
|
||||||
|
BOOLEAN bEofSent; ///< End of file sent
|
||||||
|
UINT8 * pBuffer; ///< Pointer into the file data
|
||||||
|
UINT8 * pEnd; ///< End of the file data
|
||||||
|
UINT8 FileData [ 64 * TFTP_MAX_BLOCK_SIZE ]; ///< File data to send
|
||||||
|
|
||||||
|
//
|
||||||
|
// Buffer management
|
||||||
|
//
|
||||||
|
ssize_t TxBytes; ///< Bytes in the TX buffer
|
||||||
|
UINT8 TxBuffer [ 2 + 2 + TFTP_MAX_BLOCK_SIZE ]; ///< Transmit buffer
|
||||||
|
}GCC_TSDT_CONNECTION_CONTEXT;
|
||||||
|
|
||||||
|
/**
|
||||||
|
TFTP server control structure
|
||||||
|
**/
|
||||||
|
typedef struct {
|
||||||
|
UINTN Signature; ///< Structure identification
|
||||||
|
|
||||||
|
//
|
||||||
|
// Image attributes
|
||||||
|
//
|
||||||
|
EFI_HANDLE ImageHandle; ///< Image handle
|
||||||
|
|
||||||
|
//
|
||||||
|
// TFTP port management
|
||||||
|
//
|
||||||
|
BOOLEAN bTimerRunning; ///< Port creation timer status
|
||||||
|
EFI_EVENT TimerEvent; ///< Timer to open TFTP port
|
||||||
|
struct pollfd TftpPort; ///< Poll descriptor for the TFTP port
|
||||||
|
struct sockaddr_in TftpServerAddress; ///< Address of the local TFTP server
|
||||||
|
|
||||||
|
//
|
||||||
|
// Request management
|
||||||
|
//
|
||||||
|
struct sockaddr_in RemoteAddress; ///< Remote address
|
||||||
|
ssize_t RxBytes; ///< Receive data length in bytes
|
||||||
|
UINT8 RxBuffer [ 2 + 2 + TFTP_MAX_BLOCK_SIZE ]; ///< Receive buffer
|
||||||
|
|
||||||
|
//
|
||||||
|
// Client port management
|
||||||
|
//
|
||||||
|
TSDT_CONNECTION_CONTEXT * pContextList; ///< List of connection context structures
|
||||||
|
} TSDT_TFTP_SERVER;
|
||||||
|
|
||||||
|
//#define SERVER_FROM_SERVICE(a) CR(a, TSDT_TFTP_SERVER, ServiceBinding, TFTP_SERVER_SIGNATURE) ///< Locate DT_LAYER from service binding
|
||||||
|
|
||||||
|
extern TSDT_TFTP_SERVER mTftpServer;
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// Support routines
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
Process the TFTP request
|
||||||
|
|
||||||
|
@param [in] pOption Address of the first zero terminated option string
|
||||||
|
@param [in] pValue Address to receive the value
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Option translated into a value
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
TftpOptionValue (
|
||||||
|
IN UINT8 * pOption,
|
||||||
|
IN INT32 * pValue
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Process the TFTP request
|
||||||
|
|
||||||
|
@param [in] pTftpServer The TFTP server control structure address.
|
||||||
|
@param [in] pContext Connection context structure address
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
TftpProcessRequest (
|
||||||
|
IN TSDT_TFTP_SERVER * pTftpServer,
|
||||||
|
IN TSDT_CONNECTION_CONTEXT * pContext
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Build and send an error packet
|
||||||
|
|
||||||
|
@param [in] pTftpServer The TFTP server control structure address.
|
||||||
|
@param [in] pContext The context structure address.
|
||||||
|
@param [in] Error Error number for the packet
|
||||||
|
@param [in] pError Zero terminated error string address
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Message processed successfully
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
TftpSendError (
|
||||||
|
IN TSDT_TFTP_SERVER * pTftpServer,
|
||||||
|
IN TSDT_CONNECTION_CONTEXT * pContext,
|
||||||
|
IN UINT16 Error,
|
||||||
|
IN UINT8 * pError
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Send the next block of file system data
|
||||||
|
|
||||||
|
@param [in] pTftpServer The TFTP server control structure address.
|
||||||
|
@param [in] pContext The context structure address.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Message processed successfully
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
TftpSendNextBlock (
|
||||||
|
IN TSDT_TFTP_SERVER * pTftpServer,
|
||||||
|
IN TSDT_CONNECTION_CONTEXT * pContext
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
TFTP port creation timer routine
|
||||||
|
|
||||||
|
This routine polls the socket layer waiting for the initial network connection
|
||||||
|
which will enable the creation of the TFTP port. The socket layer will manage
|
||||||
|
the coming and going of the network connections after that until the last network
|
||||||
|
connection is broken.
|
||||||
|
|
||||||
|
@param [in] pTftpServer The TFTP server control structure address.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
TftpServerTimer (
|
||||||
|
IN TSDT_TFTP_SERVER * pTftpServer
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Start the TFTP server port creation timer
|
||||||
|
|
||||||
|
@param [in] pTftpServer The TFTP server control structure address.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The timer was successfully started.
|
||||||
|
@retval EFI_ALREADY_STARTED The timer is already running.
|
||||||
|
@retval Other The timer failed to start.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
TftpServerTimerStart (
|
||||||
|
IN TSDT_TFTP_SERVER * pTftpServer
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Stop the TFTP server port creation timer
|
||||||
|
|
||||||
|
@param [in] pTftpServer The TFTP server control structure address.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The TFTP port timer is stopped
|
||||||
|
@retval Other Failed to stop the TFTP port timer
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
TftpServerTimerStop (
|
||||||
|
IN TSDT_TFTP_SERVER * pTftpServer
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Send the next TFTP packet
|
||||||
|
|
||||||
|
@param [in] pTftpServer The TFTP server control structure address.
|
||||||
|
@param [in] pContext The context structure address.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS Message processed successfully
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
TftpTxPacket (
|
||||||
|
IN TSDT_TFTP_SERVER * pTftpServer,
|
||||||
|
IN TSDT_CONNECTION_CONTEXT * pContext
|
||||||
|
);
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#endif // _TFTP_SERVER_H_
|
|
@ -0,0 +1,66 @@
|
||||||
|
#/** @file
|
||||||
|
# TFTP Server Application
|
||||||
|
#
|
||||||
|
# This file contains an 'Intel Peripheral Driver' and is
|
||||||
|
# licensed for Intel CPUs and chipsets under the terms of your
|
||||||
|
# license agreement with Intel or your vendor. This file may
|
||||||
|
# be modified by the user, subject to additional terms of the
|
||||||
|
# license agreement
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Copyright (c) 20011 Intel Corporation. All rights reserved
|
||||||
|
# This software and associated documentation (if any) is furnished
|
||||||
|
# under a license and may only be used or copied in accordance
|
||||||
|
# with the terms of the license. Except as permitted by such
|
||||||
|
# license, no part of this software or documentation may be
|
||||||
|
# reproduced, stored in a retrieval system, or transmitted in any
|
||||||
|
# form or by any means without the express written consent of
|
||||||
|
# Intel Corporation.
|
||||||
|
#
|
||||||
|
##
|
||||||
|
|
||||||
|
|
||||||
|
[Defines]
|
||||||
|
INF_VERSION = 0x00010005
|
||||||
|
BASE_NAME = TftpServer
|
||||||
|
FILE_GUID = 94621F9E-B5CA-4cfd-82BE-0C542EB0D9BE
|
||||||
|
MODULE_TYPE = UEFI_APPLICATION
|
||||||
|
VERSION_STRING = 1.0
|
||||||
|
ENTRY_POINT = ShellCEntryLib
|
||||||
|
|
||||||
|
#
|
||||||
|
# The following information is for reference only and not required by the build tools.
|
||||||
|
#
|
||||||
|
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||||
|
#
|
||||||
|
|
||||||
|
[Sources]
|
||||||
|
TftpServer.h
|
||||||
|
TftpServer.c
|
||||||
|
|
||||||
|
|
||||||
|
[Packages]
|
||||||
|
MdePkg/MdePkg.dec
|
||||||
|
ShellPkg/ShellPkg.dec
|
||||||
|
StdLib/StdLib.dec
|
||||||
|
|
||||||
|
|
||||||
|
[LibraryClasses]
|
||||||
|
BaseMemoryLib
|
||||||
|
BsdSocketLib
|
||||||
|
DebugLib
|
||||||
|
DevShell
|
||||||
|
EfiSocketLib
|
||||||
|
LibC
|
||||||
|
ShellLib
|
||||||
|
ShellCEntryLib
|
||||||
|
UefiBootServicesTableLib
|
||||||
|
UefiLib
|
||||||
|
UefiRuntimeServicesTableLib
|
||||||
|
# UseSocketDxe
|
||||||
|
|
||||||
|
[BuildOptions]
|
||||||
|
INTEL:*_*_*_CC_FLAGS = /Qdiag-disable:181,186
|
||||||
|
MSFT:*_*_*_CC_FLAGS = /Od
|
||||||
|
GCC:*_*_*_CC_FLAGS = -O0 -Wno-unused-variable
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,481 @@
|
||||||
|
/*++
|
||||||
|
This file contains an 'Intel UEFI Application' and is
|
||||||
|
licensed for Intel CPUs and chipsets under the terms of your
|
||||||
|
license agreement with Intel or your vendor. This file may
|
||||||
|
be modified by the user, subject to additional terms of the
|
||||||
|
license agreement
|
||||||
|
--*/
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Copyright (c) 2011 Intel Corporation. All rights reserved
|
||||||
|
This software and associated documentation (if any) is furnished
|
||||||
|
under a license and may only be used or copied in accordance
|
||||||
|
with the terms of the license. Except as permitted by such
|
||||||
|
license, no part of this software or documentation may be
|
||||||
|
reproduced, stored in a retrieval system, or transmitted in any
|
||||||
|
form or by any means without the express written consent of
|
||||||
|
Intel Corporation.
|
||||||
|
|
||||||
|
--*/
|
||||||
|
|
||||||
|
/** @file
|
||||||
|
Display the boot services table
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include <WebServer.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
Respond with the boot services table
|
||||||
|
|
||||||
|
@param [in] SocketFD The socket's file descriptor to add to the list.
|
||||||
|
@param [in] pPort The WSDT_PORT structure address
|
||||||
|
@param [out] pbDone Address to receive the request completion status
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The request was successfully processed
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
BootServicesTablePage (
|
||||||
|
IN int SocketFD,
|
||||||
|
IN WSDT_PORT * pPort,
|
||||||
|
OUT BOOLEAN * pbDone
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
DBG_ENTER ( );
|
||||||
|
|
||||||
|
//
|
||||||
|
// Send the boot services page
|
||||||
|
//
|
||||||
|
for ( ; ; ) {
|
||||||
|
//
|
||||||
|
// Send the page and table header
|
||||||
|
//
|
||||||
|
Status = TableHeader ( SocketFD, pPort, L"Boot Services Table", gBS );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The table header for the EFI Boot Services Table.
|
||||||
|
///
|
||||||
|
Status = EfiTableHeader ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
&gBS->Hdr );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Task Priority Services
|
||||||
|
//
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"RaiseTPL",
|
||||||
|
(CONST VOID *)gBS->RaiseTPL,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"RestoreTPL",
|
||||||
|
(CONST VOID *)gBS->RestoreTPL,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Memory Services
|
||||||
|
//
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"AllocatePages",
|
||||||
|
(CONST VOID *)gBS->AllocatePages,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"FreePages",
|
||||||
|
(CONST VOID *)gBS->FreePages,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"GetMemoryMap",
|
||||||
|
(CONST VOID *)gBS->GetMemoryMap,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"AllocatePool",
|
||||||
|
(CONST VOID *)gBS->AllocatePool,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"FreePool",
|
||||||
|
(CONST VOID *)gBS->FreePool,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Event & Timer Services
|
||||||
|
//
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"CreateEvent",
|
||||||
|
(CONST VOID *)gBS->CreateEvent,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"SetTimer",
|
||||||
|
(CONST VOID *)gBS->SetTimer,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"WaitForEvent",
|
||||||
|
(CONST VOID *)gBS->WaitForEvent,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"SignalEvent",
|
||||||
|
(CONST VOID *)gBS->SignalEvent,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"CloseEvent",
|
||||||
|
(CONST VOID *)gBS->CloseEvent,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"CheckEvent",
|
||||||
|
(CONST VOID *)gBS->CheckEvent,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Protocol Handler Services
|
||||||
|
//
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"InstallProtocolInterface",
|
||||||
|
(CONST VOID *)gBS->InstallProtocolInterface,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"ReinstallProtocolInterface",
|
||||||
|
(CONST VOID *)gBS->ReinstallProtocolInterface,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"UninstallProtocolInterface",
|
||||||
|
(CONST VOID *)gBS->UninstallProtocolInterface,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"HandleProtocol",
|
||||||
|
(CONST VOID *)gBS->HandleProtocol,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"Reserved",
|
||||||
|
(CONST VOID *)gBS->Reserved,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"RegisterProtocolNotify",
|
||||||
|
(CONST VOID *)gBS->RegisterProtocolNotify,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"LocateHandle",
|
||||||
|
(CONST VOID *)gBS->LocateHandle,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"LocateDevicePath",
|
||||||
|
(CONST VOID *)gBS->LocateDevicePath,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"InstallConfigurationTable",
|
||||||
|
(CONST VOID *)gBS->InstallConfigurationTable,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Image Services
|
||||||
|
//
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"LoadImage",
|
||||||
|
(CONST VOID *)gBS->LoadImage,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"StartImage",
|
||||||
|
(CONST VOID *)gBS->StartImage,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"Exit",
|
||||||
|
(CONST VOID *)gBS->Exit,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"UnloadImage",
|
||||||
|
(CONST VOID *)gBS->UnloadImage,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"ExitBootServices",
|
||||||
|
(CONST VOID *)gBS->ExitBootServices,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Miscellaneous Services
|
||||||
|
//
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"GetNextMonotonicCount",
|
||||||
|
(CONST VOID *)gBS->GetNextMonotonicCount,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"Stall",
|
||||||
|
(CONST VOID *)gBS->Stall,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"SetWatchdogTimer",
|
||||||
|
(CONST VOID *)gBS->SetWatchdogTimer,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// DriverSupport Services
|
||||||
|
//
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"ConnectController",
|
||||||
|
(CONST VOID *)gBS->ConnectController,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"DisconnectController",
|
||||||
|
(CONST VOID *)gBS->DisconnectController,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Open and Close Protocol Services
|
||||||
|
//
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"OpenProtocol",
|
||||||
|
(CONST VOID *)gBS->OpenProtocol,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"CloseProtocol",
|
||||||
|
(CONST VOID *)gBS->CloseProtocol,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"OpenProtocolInformation",
|
||||||
|
(CONST VOID *)gBS->OpenProtocolInformation,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Library Services
|
||||||
|
//
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"ProtocolsPerHandle",
|
||||||
|
(CONST VOID *)gBS->ProtocolsPerHandle,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"LocateHandleBuffer",
|
||||||
|
(CONST VOID *)gBS->LocateHandleBuffer,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"LocateProtocol",
|
||||||
|
(CONST VOID *)gBS->LocateProtocol,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"InstallMultipleProtocolInterfaces",
|
||||||
|
(CONST VOID *)gBS->InstallMultipleProtocolInterfaces,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"UninstallMultipleProtocolInterfaces",
|
||||||
|
(CONST VOID *)gBS->UninstallMultipleProtocolInterfaces,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// 32-bit CRC Services
|
||||||
|
//
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"CalculateCrc32",
|
||||||
|
(CONST VOID *)gBS->CalculateCrc32,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Miscellaneous Services
|
||||||
|
//
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"CopyMem",
|
||||||
|
(CONST VOID *)gBS->CopyMem,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"SetMem",
|
||||||
|
(CONST VOID *)gBS->SetMem,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"CreateEventEx",
|
||||||
|
(CONST VOID *)gBS->CreateEventEx,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Build the table trailer
|
||||||
|
//
|
||||||
|
Status = TableTrailer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
pbDone );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Return the operation status
|
||||||
|
//
|
||||||
|
DBG_EXIT_STATUS ( Status );
|
||||||
|
return Status;
|
||||||
|
}
|
|
@ -0,0 +1,380 @@
|
||||||
|
/*++
|
||||||
|
This file contains an 'Intel UEFI Application' and is
|
||||||
|
licensed for Intel CPUs and chipsets under the terms of your
|
||||||
|
license agreement with Intel or your vendor. This file may
|
||||||
|
be modified by the user, subject to additional terms of the
|
||||||
|
license agreement
|
||||||
|
--*/
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Copyright (c) 2011 Intel Corporation. All rights reserved
|
||||||
|
This software and associated documentation (if any) is furnished
|
||||||
|
under a license and may only be used or copied in accordance
|
||||||
|
with the terms of the license. Except as permitted by such
|
||||||
|
license, no part of this software or documentation may be
|
||||||
|
reproduced, stored in a retrieval system, or transmitted in any
|
||||||
|
form or by any means without the express written consent of
|
||||||
|
Intel Corporation.
|
||||||
|
|
||||||
|
--*/
|
||||||
|
|
||||||
|
/** @file
|
||||||
|
Display the configuration table
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include <WebServer.h>
|
||||||
|
#include <Guid\Acpi.h>
|
||||||
|
#include <Guid\DebugImageInfoTable.h>
|
||||||
|
#include <Guid\DxeServices.h>
|
||||||
|
#include <Guid\HobList.h>
|
||||||
|
#include <Guid\MemoryTypeInformation.h>
|
||||||
|
#include <Guid\LoadModuleAtFixedAddress.h>
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
CHAR16 * GuidName;
|
||||||
|
EFI_GUID * pGuid;
|
||||||
|
CHAR16 * pWebPage;
|
||||||
|
} GUID_NAME;
|
||||||
|
|
||||||
|
CONST GUID_NAME mGuidName [] = {
|
||||||
|
{ L"gEfiAcpi10TableGuid", &gEfiAcpi10TableGuid, PAGE_ACPI_RSDP_10B },
|
||||||
|
{ L"gEfiAcpiTableGuid", &gEfiAcpiTableGuid, PAGE_ACPI_RSDP_30 },
|
||||||
|
{ L"gEfiDebugImageInfoTableGuid", &gEfiDebugImageInfoTableGuid, NULL },
|
||||||
|
{ L"gEfiDxeServicesTableGuid", &gEfiDxeServicesTableGuid, PAGE_DXE_SERVICES_TABLE },
|
||||||
|
{ L"gEfiHobListGuid", &gEfiHobListGuid, NULL },
|
||||||
|
{ L"gEfiMemoryTypeInformationGuid", &gEfiMemoryTypeInformationGuid, NULL },
|
||||||
|
{ L"gLoadFixedAddressConfigurationTableGuid", &gLoadFixedAddressConfigurationTableGuid, NULL }
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
Display a row containing a GUID value
|
||||||
|
|
||||||
|
@param [in] SocketFD The socket's file descriptor to add to the list.
|
||||||
|
@param [in] pPort The WSDT_PORT structure address
|
||||||
|
@param [in] pName Address of a zero terminated name string
|
||||||
|
@param [in] pGuid Address of the GUID to display
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The request was successfully processed
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
RowGuid (
|
||||||
|
IN int SocketFD,
|
||||||
|
IN WSDT_PORT * pPort,
|
||||||
|
IN CONST CHAR8 * pName,
|
||||||
|
IN CONST EFI_GUID * pGuid
|
||||||
|
)
|
||||||
|
{
|
||||||
|
CONST GUID_NAME * pGuidName;
|
||||||
|
CONST GUID_NAME * pGuidNameEnd;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
UINTN Value;
|
||||||
|
|
||||||
|
DBG_ENTER ( );
|
||||||
|
|
||||||
|
//
|
||||||
|
// Use for/break instead of goto
|
||||||
|
//
|
||||||
|
for ( ; ; ) {
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"<tr><td>" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
pName );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"</td><td><code>" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Determine if this is a known GUID
|
||||||
|
//
|
||||||
|
pGuidName = &mGuidName[0];
|
||||||
|
pGuidNameEnd = &pGuidName [ sizeof ( mGuidName ) / sizeof ( mGuidName[0])];
|
||||||
|
while ( pGuidNameEnd > pGuidName ) {
|
||||||
|
if ( CompareGuid ( pGuidName->pGuid, pGuid )) {
|
||||||
|
//
|
||||||
|
// Display the web link if available
|
||||||
|
//
|
||||||
|
if ( NULL != pGuidName->pWebPage ) {
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"<a target=\"_blank\" href=\"" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = HttpSendUnicodeString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
pGuidName->pWebPage );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"\">" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Display the GUID name
|
||||||
|
//
|
||||||
|
Status = HttpSendUnicodeString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
pGuidName->GuidName );
|
||||||
|
|
||||||
|
//
|
||||||
|
// Complete the web link if available
|
||||||
|
//
|
||||||
|
if ( NULL != pGuidName->pWebPage ) {
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"</a>" );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Set the next GUID name
|
||||||
|
//
|
||||||
|
pGuidName += 1;
|
||||||
|
}
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Only if the entry is not known, display the GUID and type
|
||||||
|
//
|
||||||
|
if ( pGuidNameEnd <= pGuidName ) {
|
||||||
|
//
|
||||||
|
// Display the GUID
|
||||||
|
//
|
||||||
|
Status = HttpSendGuid ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
pGuid );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Display the GUID type
|
||||||
|
//
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"<br/><a target=\"_blank\" href=\"http://www.ietf.org/rfc/rfc4122.txt\">Guid Type</a>: " );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Value = pGuid->Data4[1];
|
||||||
|
Value >>= 5;
|
||||||
|
if ( 3 >= Value ) {
|
||||||
|
//
|
||||||
|
// Network type
|
||||||
|
//
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"Network " );
|
||||||
|
}
|
||||||
|
else if ( 5 >= Value ) {
|
||||||
|
//
|
||||||
|
// Standard type
|
||||||
|
//
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"Standard " );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Decode the standard type using RFC 4122
|
||||||
|
//
|
||||||
|
Value = pGuid->Data3;
|
||||||
|
Value >>= 12;
|
||||||
|
switch ( Value ) {
|
||||||
|
default:
|
||||||
|
//
|
||||||
|
// Display the MAC address
|
||||||
|
//
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"Version " );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = HttpSendValue ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
pGuid->Data3 >> 12 );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"MAC address" );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"DCE Security" );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"MD5 hash" );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"Random" );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 5:
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"SHA-1 hash" );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( 6 == Value ) {
|
||||||
|
//
|
||||||
|
// Microsoft's Component Object Model (COM) type
|
||||||
|
//
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"Microsoft COM" );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//
|
||||||
|
// Reserved type
|
||||||
|
//
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"Reserved" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Done with this entry
|
||||||
|
//
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"</code></td></tr>\r\n" );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Return the operation status
|
||||||
|
//
|
||||||
|
DBG_EXIT_STATUS ( Status );
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Respond with the configuration tables
|
||||||
|
|
||||||
|
@param [in] SocketFD The socket's file descriptor to add to the list.
|
||||||
|
@param [in] pPort The WSDT_PORT structure address
|
||||||
|
@param [out] pbDone Address to receive the request completion status
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The request was successfully processed
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
ConfigurationTablePage (
|
||||||
|
IN int SocketFD,
|
||||||
|
IN WSDT_PORT * pPort,
|
||||||
|
OUT BOOLEAN * pbDone
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_CONFIGURATION_TABLE * pEnd;
|
||||||
|
EFI_CONFIGURATION_TABLE * pTable;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
DBG_ENTER ( );
|
||||||
|
|
||||||
|
//
|
||||||
|
// Send the system table page
|
||||||
|
//
|
||||||
|
for ( ; ; ) {
|
||||||
|
//
|
||||||
|
// Send the page and table header
|
||||||
|
//
|
||||||
|
Status = TableHeader ( SocketFD, pPort, L"Configuration Tables", gST );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Display the table size
|
||||||
|
//
|
||||||
|
Status = RowDecimalValue ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"Entries",
|
||||||
|
gST->NumberOfTableEntries );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Determine the location of the configuration tables
|
||||||
|
//
|
||||||
|
pTable = gST->ConfigurationTable;
|
||||||
|
pEnd = &pTable [ gST->NumberOfTableEntries ];
|
||||||
|
while ( pEnd > pTable ) {
|
||||||
|
Status = RowGuid ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"VendorGuid",
|
||||||
|
&pTable->VendorGuid );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"VendorTable",
|
||||||
|
(VOID *)pTable->VendorTable,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Set the next row
|
||||||
|
//
|
||||||
|
pTable += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Build the table trailer
|
||||||
|
//
|
||||||
|
Status = TableTrailer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
pbDone );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Return the operation status
|
||||||
|
//
|
||||||
|
DBG_EXIT_STATUS ( Status );
|
||||||
|
return Status;
|
||||||
|
}
|
|
@ -0,0 +1,235 @@
|
||||||
|
/*++
|
||||||
|
This file contains an 'Intel UEFI Application' and is
|
||||||
|
licensed for Intel CPUs and chipsets under the terms of your
|
||||||
|
license agreement with Intel or your vendor. This file may
|
||||||
|
be modified by the user, subject to additional terms of the
|
||||||
|
license agreement
|
||||||
|
--*/
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Copyright (c) 2011 Intel Corporation. All rights reserved
|
||||||
|
This software and associated documentation (if any) is furnished
|
||||||
|
under a license and may only be used or copied in accordance
|
||||||
|
with the terms of the license. Except as permitted by such
|
||||||
|
license, no part of this software or documentation may be
|
||||||
|
reproduced, stored in a retrieval system, or transmitted in any
|
||||||
|
form or by any means without the express written consent of
|
||||||
|
Intel Corporation.
|
||||||
|
|
||||||
|
--*/
|
||||||
|
|
||||||
|
/** @file
|
||||||
|
Display the DHCP options
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include <WebServer.h>
|
||||||
|
#include <Guid/DxeServices.h>
|
||||||
|
#include <pi/PiDxeCis.h>
|
||||||
|
|
||||||
|
#include <protocol/Dhcp4.h>
|
||||||
|
#include <protocol/ServiceBinding.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
Respond with the DHCP options
|
||||||
|
|
||||||
|
@param [in] SocketFD The socket's file descriptor to add to the list.
|
||||||
|
@param [in] pPort The WSDT_PORT structure address
|
||||||
|
@param [out] pbDone Address to receive the request completion status
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The request was successfully processed
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
DhcpOptionsPage (
|
||||||
|
IN int SocketFD,
|
||||||
|
IN WSDT_PORT * pPort,
|
||||||
|
OUT BOOLEAN * pbDone
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// EFI_HANDLE Dhcp4Handle;
|
||||||
|
EFI_DHCP4_MODE_DATA Dhcp4Mode;
|
||||||
|
UINTN HandleCount;
|
||||||
|
EFI_DHCP4_PROTOCOL * pDhcp4;
|
||||||
|
EFI_DHCP4_PACKET * pDhcp4Packet;
|
||||||
|
EFI_HANDLE * pEnd;
|
||||||
|
EFI_HANDLE * pHandle;
|
||||||
|
// EFI_SERVICE_BINDING_PROTOCOL * pService;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
DBG_ENTER ( );
|
||||||
|
|
||||||
|
//
|
||||||
|
// Send the DHCP options
|
||||||
|
//
|
||||||
|
for ( ; ; ) {
|
||||||
|
//
|
||||||
|
// Send the page header
|
||||||
|
//
|
||||||
|
Status = HttpPageHeader ( SocketFD, pPort, L"DHCP Options" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Build the header
|
||||||
|
//
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"<h1>" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = HttpSendUnicodeString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
L"DHCP Options" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"</h1>\r\n" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Attempt to locate DHCP clients
|
||||||
|
//
|
||||||
|
Status = gBS->LocateHandleBuffer ( ByProtocol,
|
||||||
|
// &gEfiDhcp4ServiceBindingProtocolGuid,
|
||||||
|
&gEfiDhcp4ProtocolGuid,
|
||||||
|
NULL,
|
||||||
|
&HandleCount,
|
||||||
|
&pHandle );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"DHCP not in use" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//
|
||||||
|
// Walk the list of handles
|
||||||
|
//
|
||||||
|
pEnd = &pHandle [ HandleCount ];
|
||||||
|
while ( pEnd > pHandle ) {
|
||||||
|
/*
|
||||||
|
//
|
||||||
|
// Get the DHCP service binding
|
||||||
|
//
|
||||||
|
Status = gBS->OpenProtocol ( *pHandle,
|
||||||
|
&gEfiDhcp4ServiceBindingProtocolGuid,
|
||||||
|
&pService,
|
||||||
|
NULL,
|
||||||
|
gImageHandle,
|
||||||
|
EFI_OPEN_PROTOCOL_GET_PROTOCOL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"Failed to open gEfiDhcp4ServiceBindingProtocolGuid" );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Get the DHCP handle
|
||||||
|
//
|
||||||
|
Status = pService->CreateChild ( pService,
|
||||||
|
&Dhcp4Handle );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"Failed to create DHCP4 child" );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
*/
|
||||||
|
//
|
||||||
|
// Get the DHCP protocol
|
||||||
|
//
|
||||||
|
Status = gBS->OpenProtocol ( *pHandle,
|
||||||
|
// Dhcp4Handle,
|
||||||
|
&gEfiDhcp4ProtocolGuid,
|
||||||
|
&pDhcp4,
|
||||||
|
NULL,
|
||||||
|
gImageHandle,
|
||||||
|
EFI_OPEN_PROTOCOL_GET_PROTOCOL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"Failed to open gEfiDhcp4ProtocolGuid" );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//
|
||||||
|
// Get the DHCP packet
|
||||||
|
//
|
||||||
|
Status = pDhcp4->GetModeData ( pDhcp4,
|
||||||
|
&Dhcp4Mode );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"Failed to get DHCP4 mode" );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//
|
||||||
|
// Get the last packet
|
||||||
|
//
|
||||||
|
pDhcp4Packet = Dhcp4Mode.ReplyPacket;
|
||||||
|
if ( NULL == pDhcp4Packet ) {
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"No DHCP reply received!<br/>DHCP Mode:<br/>" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Display the DHCP mode data
|
||||||
|
//
|
||||||
|
Status = HttpSendDump ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
sizeof ( Dhcp4Mode ),
|
||||||
|
(UINT8 *)&Dhcp4Mode );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//
|
||||||
|
// Display the DHCP packet
|
||||||
|
//
|
||||||
|
Status = HttpSendDump ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
pDhcp4Packet->Length,
|
||||||
|
(UINT8 *)&pDhcp4Packet->Dhcp4 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Done with the DHCP protocol
|
||||||
|
//
|
||||||
|
pService->DestroyChild ( pService,
|
||||||
|
Dhcp4Handle );
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Set the next service binding
|
||||||
|
//
|
||||||
|
pHandle += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Send the page trailer
|
||||||
|
//
|
||||||
|
Status = HttpPageTrailer ( SocketFD, pPort, pbDone );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Return the operation status
|
||||||
|
//
|
||||||
|
DBG_EXIT_STATUS ( Status );
|
||||||
|
return Status;
|
||||||
|
}
|
|
@ -0,0 +1,245 @@
|
||||||
|
/*++
|
||||||
|
This file contains an 'Intel UEFI Application' and is
|
||||||
|
licensed for Intel CPUs and chipsets under the terms of your
|
||||||
|
license agreement with Intel or your vendor. This file may
|
||||||
|
be modified by the user, subject to additional terms of the
|
||||||
|
license agreement
|
||||||
|
--*/
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Copyright (c) 2011 Intel Corporation. All rights reserved
|
||||||
|
This software and associated documentation (if any) is furnished
|
||||||
|
under a license and may only be used or copied in accordance
|
||||||
|
with the terms of the license. Except as permitted by such
|
||||||
|
license, no part of this software or documentation may be
|
||||||
|
reproduced, stored in a retrieval system, or transmitted in any
|
||||||
|
form or by any means without the express written consent of
|
||||||
|
Intel Corporation.
|
||||||
|
|
||||||
|
--*/
|
||||||
|
|
||||||
|
/** @file
|
||||||
|
Display the DXE services table
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include <WebServer.h>
|
||||||
|
#include <Guid/DxeServices.h>
|
||||||
|
#include <pi/PiDxeCis.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
Respond with the DXE services table
|
||||||
|
|
||||||
|
@param [in] SocketFD The socket's file descriptor to add to the list.
|
||||||
|
@param [in] pPort The WSDT_PORT structure address
|
||||||
|
@param [out] pbDone Address to receive the request completion status
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The request was successfully processed
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
DxeServicesTablePage (
|
||||||
|
IN int SocketFD,
|
||||||
|
IN WSDT_PORT * pPort,
|
||||||
|
OUT BOOLEAN * pbDone
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_DXE_SERVICES * pDS;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
DBG_ENTER ( );
|
||||||
|
|
||||||
|
//
|
||||||
|
// Send the DXE services page
|
||||||
|
//
|
||||||
|
for ( ; ; ) {
|
||||||
|
//
|
||||||
|
// Get the DXE services table
|
||||||
|
//
|
||||||
|
Status = EfiGetSystemConfigurationTable (&gEfiDxeServicesTableGuid, (VOID **) &pDS);
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Send the page and table header
|
||||||
|
//
|
||||||
|
Status = TableHeader ( SocketFD, pPort, L"DXE Services Table", pDS );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The table header for the DXE Services Table.
|
||||||
|
/// This header contains the DXE_SERVICES_SIGNATURE and DXE_SERVICES_REVISION values.
|
||||||
|
///
|
||||||
|
Status = EfiTableHeader ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
&pDS->Hdr );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Global Coherency Domain Services
|
||||||
|
//
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"AddMemorySpace",
|
||||||
|
(VOID *)pDS->AddMemorySpace,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"AllocateMemorySpace",
|
||||||
|
(VOID *)pDS->AllocateMemorySpace,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"FreeMemorySpace",
|
||||||
|
(VOID *)pDS->FreeMemorySpace,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"RemoveMemorySpace",
|
||||||
|
(VOID *)pDS->RemoveMemorySpace,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"GetMemorySpaceDescriptor",
|
||||||
|
(VOID *)pDS->GetMemorySpaceDescriptor,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"SetMemorySpaceAttributes",
|
||||||
|
(VOID *)pDS->SetMemorySpaceAttributes,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"GetMemorySpaceMap",
|
||||||
|
(VOID *)pDS->GetMemorySpaceMap,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"AddIoSpace",
|
||||||
|
(VOID *)pDS->AddIoSpace,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"AllocateIoSpace",
|
||||||
|
(VOID *)pDS->AllocateIoSpace,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"FreeIoSpace",
|
||||||
|
(VOID *)pDS->FreeIoSpace,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"RemoveIoSpace",
|
||||||
|
(VOID *)pDS->RemoveIoSpace,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"GetIoSpaceDescriptor",
|
||||||
|
(VOID *)pDS->GetIoSpaceDescriptor,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"GetIoSpaceMap",
|
||||||
|
(VOID *)pDS->GetIoSpaceMap,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Dispatcher Services
|
||||||
|
//
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"Dispatch",
|
||||||
|
(VOID *)pDS->Dispatch,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"Schedule",
|
||||||
|
(VOID *)pDS->Schedule,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"Trust",
|
||||||
|
(VOID *)pDS->Trust,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Service to process a single firmware volume found in a capsule
|
||||||
|
//
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"ProcessFirmwareVolume",
|
||||||
|
(VOID *)pDS->ProcessFirmwareVolume,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Build the table trailer
|
||||||
|
//
|
||||||
|
Status = TableTrailer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
pbDone );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Return the operation status
|
||||||
|
//
|
||||||
|
DBG_EXIT_STATUS ( Status );
|
||||||
|
return Status;
|
||||||
|
}
|
|
@ -0,0 +1,106 @@
|
||||||
|
/*++
|
||||||
|
This file contains an 'Intel UEFI Application' and is
|
||||||
|
licensed for Intel CPUs and chipsets under the terms of your
|
||||||
|
license agreement with Intel or your vendor. This file may
|
||||||
|
be modified by the user, subject to additional terms of the
|
||||||
|
license agreement
|
||||||
|
--*/
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Copyright (c) 2011 Intel Corporation. All rights reserved
|
||||||
|
This software and associated documentation (if any) is furnished
|
||||||
|
under a license and may only be used or copied in accordance
|
||||||
|
with the terms of the license. Except as permitted by such
|
||||||
|
license, no part of this software or documentation may be
|
||||||
|
reproduced, stored in a retrieval system, or transmitted in any
|
||||||
|
form or by any means without the express written consent of
|
||||||
|
Intel Corporation.
|
||||||
|
|
||||||
|
--*/
|
||||||
|
|
||||||
|
/** @file
|
||||||
|
Display the firmware
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include <WebServer.h>
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Respond with the firmware status
|
||||||
|
|
||||||
|
@param [in] SocketFD The socket's file descriptor to add to the list.
|
||||||
|
@param [in] pPort The WSDT_PORT structure address
|
||||||
|
@param [out] pbDone Address to receive the request completion status
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The request was successfully processed
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
FirmwarePage (
|
||||||
|
IN int SocketFD,
|
||||||
|
IN WSDT_PORT * pPort,
|
||||||
|
OUT BOOLEAN * pbDone
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
DBG_ENTER ( );
|
||||||
|
|
||||||
|
//
|
||||||
|
// Send the system table page
|
||||||
|
//
|
||||||
|
for ( ; ; ) {
|
||||||
|
//
|
||||||
|
// Send the page and table header
|
||||||
|
//
|
||||||
|
Status = TableHeader ( SocketFD, pPort, L"Firmware", NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Display the firmware vendor and revision
|
||||||
|
//
|
||||||
|
Status = RowUnicodeString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"Vendor",
|
||||||
|
gST->FirmwareVendor );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = RowRevision ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"Revision",
|
||||||
|
gST->FirmwareRevision );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Display the UEFI version
|
||||||
|
//
|
||||||
|
Status = RowRevision ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"UEFI",
|
||||||
|
gST->Hdr.Revision );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Build the table trailer
|
||||||
|
//
|
||||||
|
Status = TableTrailer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
pbDone );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Return the operation status
|
||||||
|
//
|
||||||
|
DBG_EXIT_STATUS ( Status );
|
||||||
|
return Status;
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,294 @@
|
||||||
|
/*++
|
||||||
|
This file contains an 'Intel UEFI Application' and is
|
||||||
|
licensed for Intel CPUs and chipsets under the terms of your
|
||||||
|
license agreement with Intel or your vendor. This file may
|
||||||
|
be modified by the user, subject to additional terms of the
|
||||||
|
license agreement
|
||||||
|
--*/
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Copyright (c) 2011 Intel Corporation. All rights reserved
|
||||||
|
This software and associated documentation (if any) is furnished
|
||||||
|
under a license and may only be used or copied in accordance
|
||||||
|
with the terms of the license. Except as permitted by such
|
||||||
|
license, no part of this software or documentation may be
|
||||||
|
reproduced, stored in a retrieval system, or transmitted in any
|
||||||
|
form or by any means without the express written consent of
|
||||||
|
Intel Corporation.
|
||||||
|
|
||||||
|
--*/
|
||||||
|
|
||||||
|
/** @file
|
||||||
|
Display the handles in the system
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include <WebServer.h>
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Respond with the handles in the system
|
||||||
|
|
||||||
|
@param [in] SocketFD The socket's file descriptor to add to the list.
|
||||||
|
@param [in] pPort The WSDT_PORT structure address
|
||||||
|
@param [out] pbDone Address to receive the request completion status
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The request was successfully processed
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
HandlePage (
|
||||||
|
IN int SocketFD,
|
||||||
|
IN WSDT_PORT * pPort,
|
||||||
|
OUT BOOLEAN * pbDone
|
||||||
|
)
|
||||||
|
{
|
||||||
|
INTN Digit;
|
||||||
|
INTN Entries;
|
||||||
|
INTN Index;
|
||||||
|
UINTN GuidCount;
|
||||||
|
UINTN LengthInBytes;
|
||||||
|
UINT8 * pDigit;
|
||||||
|
EFI_HANDLE * pHandleArray;
|
||||||
|
EFI_HANDLE * pHandle;
|
||||||
|
EFI_HANDLE * pHandleEnd;
|
||||||
|
EFI_GUID ** ppGuidArray;
|
||||||
|
EFI_GUID ** ppGuid;
|
||||||
|
EFI_GUID ** ppGuidEnd;
|
||||||
|
INTN Shift;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
UINTN Value;
|
||||||
|
CONST UINTN cDigit [] = {
|
||||||
|
3, 2, 1, 0, 5, 4, 7, 6, 8, 9, 10, 11, 12, 13, 14, 15 };
|
||||||
|
|
||||||
|
DBG_ENTER ( );
|
||||||
|
|
||||||
|
//
|
||||||
|
// Send the handles page
|
||||||
|
//
|
||||||
|
for ( ; ; ) {
|
||||||
|
//
|
||||||
|
// Send the page header
|
||||||
|
//
|
||||||
|
Status = HttpPageHeader ( SocketFD, pPort, L"Handle Database" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Build the table header
|
||||||
|
//
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"<h1>Handle Database</h1>\r\n"
|
||||||
|
"<table border=\"1\">\r\n"
|
||||||
|
" <tr bgcolor=\"c0c0ff\"><th>Handle</th><th>Protocol Guids</th></tr>\r\n" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Determine the number of handles in the database
|
||||||
|
//
|
||||||
|
LengthInBytes = 0;
|
||||||
|
Status = gBS->LocateHandle ( AllHandles,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
&LengthInBytes,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_BUFFER_TOO_SMALL == Status ) {
|
||||||
|
//
|
||||||
|
// Allocate space for the handles
|
||||||
|
//
|
||||||
|
Status = gBS->AllocatePool ( EfiRuntimeServicesData,
|
||||||
|
LengthInBytes,
|
||||||
|
(VOID **) &pHandleArray );
|
||||||
|
if ( !EFI_ERROR ( Status )) {
|
||||||
|
//
|
||||||
|
// Get the list of handles
|
||||||
|
//
|
||||||
|
Status = gBS->LocateHandle ( AllHandles,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
&LengthInBytes,
|
||||||
|
pHandleArray );
|
||||||
|
if ( !EFI_ERROR ( Status )) {
|
||||||
|
Entries = LengthInBytes / sizeof ( *pHandleArray );
|
||||||
|
pHandle = pHandleArray;
|
||||||
|
pHandleEnd = &pHandle [ Entries ];
|
||||||
|
while ( pHandleEnd > pHandle ) {
|
||||||
|
//
|
||||||
|
// Build the table entry for this page
|
||||||
|
//
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"<tr><td><code>0x" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Value = (UINTN) *pHandle;
|
||||||
|
for ( Shift = ( sizeof ( Shift ) << 3 ) - 4; 0 <= Shift; Shift -= 4 ) {
|
||||||
|
//
|
||||||
|
// Convert the next address nibble to ANSI hex
|
||||||
|
//
|
||||||
|
Digit = (( Value >> Shift ) & 0xf ) | '0';
|
||||||
|
if ( '9' < Digit ) {
|
||||||
|
Digit += 'a' - '0' - 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Display the address digit
|
||||||
|
//
|
||||||
|
Status = HttpSendByte ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
(UINT8) Digit );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Start the second column
|
||||||
|
//
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"</code></td><td><code>\r\n" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Determine the number of protocols connected to this handle
|
||||||
|
//
|
||||||
|
Status = gBS->ProtocolsPerHandle ( *pHandle,
|
||||||
|
&ppGuidArray,
|
||||||
|
&GuidCount );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ppGuid = ppGuidArray;
|
||||||
|
ppGuidEnd = &ppGuid [ GuidCount ];
|
||||||
|
while ( ppGuidEnd > ppGuid ) {
|
||||||
|
//
|
||||||
|
// Display the guid
|
||||||
|
//
|
||||||
|
pDigit = (UINT8 *) *ppGuid;
|
||||||
|
for ( Index = 0; 16 > Index; Index++ ) {
|
||||||
|
//
|
||||||
|
// Separate the portions of the GUID
|
||||||
|
// 99E87DCF-6162-40c5-9FA1-32111F5197F7
|
||||||
|
//
|
||||||
|
if (( 4 == Index )
|
||||||
|
|| ( 6 == Index )
|
||||||
|
|| ( 8 == Index )
|
||||||
|
|| ( 10 == Index )) {
|
||||||
|
Status = HttpSendByte ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
'-' );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Display the GUID digits
|
||||||
|
//
|
||||||
|
Value = pDigit [ cDigit [ Index ]];
|
||||||
|
for ( Shift = 4; 0 <= Shift; Shift -= 4 ) {
|
||||||
|
//
|
||||||
|
// Convert the next address nibble to ANSI hex
|
||||||
|
//
|
||||||
|
Digit = (( Value >> Shift ) & 0xf ) | '0';
|
||||||
|
if ( '9' < Digit ) {
|
||||||
|
Digit += 'a' - '0' - 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Display the address digit
|
||||||
|
//
|
||||||
|
Status = HttpSendByte ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
(UINT8) Digit );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Separate each GUID
|
||||||
|
//
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"<br/>\r\n" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Set the next protocol
|
||||||
|
//
|
||||||
|
ppGuid+= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Free the GUID array
|
||||||
|
//
|
||||||
|
gBS->FreePool ( ppGuidArray );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// End the row
|
||||||
|
//
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"</code></td></tr>\r\n" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Set the next handle
|
||||||
|
//
|
||||||
|
pHandle += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Done with the handle array
|
||||||
|
//
|
||||||
|
gBS->FreePool ( pHandleArray );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Build the table trailer
|
||||||
|
//
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"</table>\r\n" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Send the page trailer
|
||||||
|
//
|
||||||
|
Status = HttpPageTrailer ( SocketFD, pPort, pbDone );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Return the operation status
|
||||||
|
//
|
||||||
|
DBG_EXIT_STATUS ( Status );
|
||||||
|
return Status;
|
||||||
|
}
|
|
@ -0,0 +1,87 @@
|
||||||
|
/*++
|
||||||
|
This file contains an 'Intel UEFI Application' and is
|
||||||
|
licensed for Intel CPUs and chipsets under the terms of your
|
||||||
|
license agreement with Intel or your vendor. This file may
|
||||||
|
be modified by the user, subject to additional terms of the
|
||||||
|
license agreement
|
||||||
|
--*/
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Copyright (c) 2011 Intel Corporation. All rights reserved
|
||||||
|
This software and associated documentation (if any) is furnished
|
||||||
|
under a license and may only be used or copied in accordance
|
||||||
|
with the terms of the license. Except as permitted by such
|
||||||
|
license, no part of this software or documentation may be
|
||||||
|
reproduced, stored in a retrieval system, or transmitted in any
|
||||||
|
form or by any means without the express written consent of
|
||||||
|
Intel Corporation.
|
||||||
|
|
||||||
|
--*/
|
||||||
|
|
||||||
|
/** @file
|
||||||
|
Hello World response page
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include <WebServer.h>
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Respond with the Hello World page
|
||||||
|
|
||||||
|
@param [in] SocketFD The socket's file descriptor to add to the list.
|
||||||
|
@param [in] pPort The WSDT_PORT structure address
|
||||||
|
@param [out] pbDone Address to receive the request completion status
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The request was successfully processed
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
HelloPage (
|
||||||
|
IN int SocketFD,
|
||||||
|
IN WSDT_PORT * pPort,
|
||||||
|
OUT BOOLEAN * pbDone
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
DBG_ENTER ( );
|
||||||
|
|
||||||
|
//
|
||||||
|
// Send the Hello World page
|
||||||
|
//
|
||||||
|
for ( ; ; ) {
|
||||||
|
//
|
||||||
|
// Send the page header
|
||||||
|
//
|
||||||
|
Status = HttpPageHeader ( SocketFD, pPort, L"Hello World" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Send the page body
|
||||||
|
//
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"<h1>Hello World</h1>\r\n"
|
||||||
|
"<p>\r\n"
|
||||||
|
" This response was generated by the UEFI web server application.\r\n"
|
||||||
|
"</p>\r\n" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Send the page trailer
|
||||||
|
//
|
||||||
|
Status = HttpPageTrailer ( SocketFD, pPort, pbDone );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Return the operation status
|
||||||
|
//
|
||||||
|
DBG_EXIT_STATUS ( Status );
|
||||||
|
return Status;
|
||||||
|
}
|
|
@ -0,0 +1,161 @@
|
||||||
|
/*++
|
||||||
|
This file contains an 'Intel UEFI Application' and is
|
||||||
|
licensed for Intel CPUs and chipsets under the terms of your
|
||||||
|
license agreement with Intel or your vendor. This file may
|
||||||
|
be modified by the user, subject to additional terms of the
|
||||||
|
license agreement
|
||||||
|
--*/
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Copyright (c) 2011 Intel Corporation. All rights reserved
|
||||||
|
This software and associated documentation (if any) is furnished
|
||||||
|
under a license and may only be used or copied in accordance
|
||||||
|
with the terms of the license. Except as permitted by such
|
||||||
|
license, no part of this software or documentation may be
|
||||||
|
reproduced, stored in a retrieval system, or transmitted in any
|
||||||
|
form or by any means without the express written consent of
|
||||||
|
Intel Corporation.
|
||||||
|
|
||||||
|
--*/
|
||||||
|
|
||||||
|
/** @file
|
||||||
|
Generate the list of known pages.
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include <WebServer.h>
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Respond with the list of known pages
|
||||||
|
|
||||||
|
@param [in] SocketFD The socket's file descriptor to add to the list.
|
||||||
|
@param [in] pPort The WSDT_PORT structure address
|
||||||
|
@param [out] pbDone Address to receive the request completion status
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The request was successfully processed
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
IndexPage (
|
||||||
|
IN int SocketFD,
|
||||||
|
IN WSDT_PORT * pPort,
|
||||||
|
OUT BOOLEAN * pbDone
|
||||||
|
)
|
||||||
|
{
|
||||||
|
CONST DT_PAGE * pPage;
|
||||||
|
CONST DT_PAGE * pPageEnd;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
DBG_ENTER ( );
|
||||||
|
|
||||||
|
//
|
||||||
|
// Send the index page
|
||||||
|
//
|
||||||
|
for ( ; ; ) {
|
||||||
|
//
|
||||||
|
// Send the page header
|
||||||
|
//
|
||||||
|
Status = HttpPageHeader ( SocketFD, pPort, L"Index" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Build the table header
|
||||||
|
//
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"<h1>UEFI Web Server</h1>\r\n"
|
||||||
|
"<table border=\"1\">\r\n"
|
||||||
|
" <tr bgcolor=\"c0c0ff\"><th>Page</th><th>Description</th></tr>\r\n" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Walk the list of pages
|
||||||
|
// Skip the first page
|
||||||
|
//
|
||||||
|
pPage = &mPageList[0];
|
||||||
|
pPageEnd = &pPage[mPageCount];
|
||||||
|
pPage += 1;
|
||||||
|
while ( pPageEnd > pPage ) {
|
||||||
|
//
|
||||||
|
// Build the table entry for this page
|
||||||
|
//
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"<tr><td><a target=\"_blank\" href=\"" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = HttpSendUnicodeString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
&pPage->pPageName[1]);
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"\">" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = HttpSendUnicodeString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
&pPage->pPageName[1]);
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"</a></td><td>" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = HttpSendUnicodeString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
pPage->pDescription );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"</td></tr>\r\n" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Set the next page
|
||||||
|
//
|
||||||
|
pPage += 1;
|
||||||
|
}
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Build the table trailer
|
||||||
|
//
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"</table>\r\n" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Send the page trailer
|
||||||
|
//
|
||||||
|
Status = HttpPageTrailer ( SocketFD, pPort, pbDone );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Return the operation status
|
||||||
|
//
|
||||||
|
DBG_EXIT_STATUS ( Status );
|
||||||
|
return Status;
|
||||||
|
}
|
|
@ -0,0 +1,59 @@
|
||||||
|
/*++
|
||||||
|
This file contains an 'Intel UEFI Application' and is
|
||||||
|
licensed for Intel CPUs and chipsets under the terms of your
|
||||||
|
license agreement with Intel or your vendor. This file may
|
||||||
|
be modified by the user, subject to additional terms of the
|
||||||
|
license agreement
|
||||||
|
--*/
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Copyright (c) 2011 Intel Corporation. All rights reserved
|
||||||
|
This software and associated documentation (if any) is furnished
|
||||||
|
under a license and may only be used or copied in accordance
|
||||||
|
with the terms of the license. Except as permitted by such
|
||||||
|
license, no part of this software or documentation may be
|
||||||
|
reproduced, stored in a retrieval system, or transmitted in any
|
||||||
|
form or by any means without the express written consent of
|
||||||
|
Intel Corporation.
|
||||||
|
|
||||||
|
--*/
|
||||||
|
|
||||||
|
/** @file
|
||||||
|
List of pages to display
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include <WebServer.h>
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
List of pages in the system
|
||||||
|
**/
|
||||||
|
CONST DT_PAGE mPageList [] = {
|
||||||
|
|
||||||
|
//
|
||||||
|
// The index page must be first
|
||||||
|
//
|
||||||
|
{ L"/", IndexPage, L"Index of pages" }, ///< List the pages
|
||||||
|
|
||||||
|
//
|
||||||
|
// All other pages follow in alphabetical order
|
||||||
|
//
|
||||||
|
{ PAGE_BOOT_SERVICES_TABLE, BootServicesTablePage, L"Boot Services Table" }, ///< Format boot services table
|
||||||
|
{ PAGE_CONFIGURATION_TABLE, ConfigurationTablePage, L"Configuration Table" }, ///< Format configuration table
|
||||||
|
{ L"/DhcpOptions", DhcpOptionsPage, L"DHCP Options" }, ///< Display the DHCP options
|
||||||
|
{ PAGE_ACPI_DSDT, AcpiDsdtPage, L"DSDT - Differentiated System Description Table" }, ///< Format DSDT
|
||||||
|
{ PAGE_DXE_SERVICES_TABLE, DxeServicesTablePage, L"DXE Services Table" }, ///< Format DXE services table
|
||||||
|
{ PAGE_ACPI_FADT, AcpiFadtPage, L"FADT - Fixed ACPI Description Table" }, ///< Format FADT
|
||||||
|
{ L"/Firmware", FirmwarePage, L"Firmware" }, ///< Firmware status
|
||||||
|
{ L"/Handles", HandlePage, L"Display handles and associated protocol GUIDs" }, ///< Handle database page
|
||||||
|
{ L"/Hello", HelloPage, L"Hello World" }, ///< Hello world page
|
||||||
|
{ L"/Reboot", RebootPage, L"Reboot the sytem" }, ///< Reboot page
|
||||||
|
{ PAGE_ACPI_RSDP_10B, AcpiRsdp10Page, L"RSDP 1.0b - ACPI Root System Description Pointer" }, ///< Format RSDP 1.0b table
|
||||||
|
{ PAGE_ACPI_RSDP_30, AcpiRsdp30Page, L"RSDP 3.0 - ACPI Root System Description Pointer" }, ///< Format RSDP 3.0 table
|
||||||
|
{ PAGE_ACPI_RSDT, AcpiRsdtPage, L"RSDT - ACPI Root System Description Table" }, ///< Format RSDT
|
||||||
|
{ PAGE_RUNTIME_SERVICES_TABLE, RuntimeSservicesTablePage, L"Runtime Services Table" },///< Format runtime services table
|
||||||
|
{ L"/SystemTable", SystemTablePage, L"System Table" } ///< Format system table
|
||||||
|
};
|
||||||
|
|
||||||
|
CONST UINTN mPageCount = DIM ( mPageList );
|
|
@ -0,0 +1,105 @@
|
||||||
|
/*++
|
||||||
|
This file contains an 'Intel UEFI Application' and is
|
||||||
|
licensed for Intel CPUs and chipsets under the terms of your
|
||||||
|
license agreement with Intel or your vendor. This file may
|
||||||
|
be modified by the user, subject to additional terms of the
|
||||||
|
license agreement
|
||||||
|
--*/
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Copyright (c) 2011 Intel Corporation. All rights reserved
|
||||||
|
This software and associated documentation (if any) is furnished
|
||||||
|
under a license and may only be used or copied in accordance
|
||||||
|
with the terms of the license. Except as permitted by such
|
||||||
|
license, no part of this software or documentation may be
|
||||||
|
reproduced, stored in a retrieval system, or transmitted in any
|
||||||
|
form or by any means without the express written consent of
|
||||||
|
Intel Corporation.
|
||||||
|
|
||||||
|
--*/
|
||||||
|
|
||||||
|
/** @file
|
||||||
|
Reboot the system
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include <WebServer.h>
|
||||||
|
#include <Library/UefiRuntimeServicesTableLib.h>
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Page to reboot the system
|
||||||
|
|
||||||
|
@param [in] SocketFD The socket's file descriptor to add to the list.
|
||||||
|
@param [in] pPort The WSDT_PORT structure address
|
||||||
|
@param [out] pbDone Address to receive the request completion status
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The request was successfully processed
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
RebootPage (
|
||||||
|
IN int SocketFD,
|
||||||
|
IN WSDT_PORT * pPort,
|
||||||
|
OUT BOOLEAN * pbDone
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
DBG_ENTER ( );
|
||||||
|
|
||||||
|
//
|
||||||
|
// Send the Hello World page
|
||||||
|
//
|
||||||
|
for ( ; ; ) {
|
||||||
|
//
|
||||||
|
// Send the page header
|
||||||
|
//
|
||||||
|
Status = HttpPageHeader ( SocketFD, pPort, L"Reboot" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Send the page body
|
||||||
|
//
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"<h1>Reboot</h1>\r\n"
|
||||||
|
"<p>\r\n"
|
||||||
|
" Ouch! The system is rebooting!\r\n" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Send the page trailer
|
||||||
|
//
|
||||||
|
Status = HttpPageTrailer ( SocketFD, pPort, pbDone );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Deliver the data to the remote system by
|
||||||
|
// closing the socket
|
||||||
|
//
|
||||||
|
close ( SocketFD );
|
||||||
|
|
||||||
|
//
|
||||||
|
// Attempt to reboot the system
|
||||||
|
//
|
||||||
|
DEBUG (( DEBUG_REQUEST, "Reseting System\r\n" ));
|
||||||
|
gRT->ResetSystem ( EfiResetCold,
|
||||||
|
EFI_SUCCESS,
|
||||||
|
0,
|
||||||
|
NULL );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Return the operation status
|
||||||
|
//
|
||||||
|
DBG_EXIT_STATUS ( Status );
|
||||||
|
return Status;
|
||||||
|
}
|
|
@ -0,0 +1,227 @@
|
||||||
|
/*++
|
||||||
|
This file contains an 'Intel UEFI Application' and is
|
||||||
|
licensed for Intel CPUs and chipsets under the terms of your
|
||||||
|
license agreement with Intel or your vendor. This file may
|
||||||
|
be modified by the user, subject to additional terms of the
|
||||||
|
license agreement
|
||||||
|
--*/
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Copyright (c) 2011 Intel Corporation. All rights reserved
|
||||||
|
This software and associated documentation (if any) is furnished
|
||||||
|
under a license and may only be used or copied in accordance
|
||||||
|
with the terms of the license. Except as permitted by such
|
||||||
|
license, no part of this software or documentation may be
|
||||||
|
reproduced, stored in a retrieval system, or transmitted in any
|
||||||
|
form or by any means without the express written consent of
|
||||||
|
Intel Corporation.
|
||||||
|
|
||||||
|
--*/
|
||||||
|
|
||||||
|
/** @file
|
||||||
|
Display the runtime services table
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include <WebServer.h>
|
||||||
|
#include <Library/UefiRuntimeServicesTableLib.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
Respond with the runtime services table
|
||||||
|
|
||||||
|
@param [in] SocketFD The socket's file descriptor to add to the list.
|
||||||
|
@param [in] pPort The WSDT_PORT structure address
|
||||||
|
@param [out] pbDone Address to receive the request completion status
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The request was successfully processed
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
RuntimeSservicesTablePage (
|
||||||
|
IN int SocketFD,
|
||||||
|
IN WSDT_PORT * pPort,
|
||||||
|
OUT BOOLEAN * pbDone
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
DBG_ENTER ( );
|
||||||
|
|
||||||
|
//
|
||||||
|
// Send the runtime services page
|
||||||
|
//
|
||||||
|
for ( ; ; ) {
|
||||||
|
//
|
||||||
|
// Send the page and table header
|
||||||
|
//
|
||||||
|
Status = TableHeader ( SocketFD, pPort, L"Runtime Services Table", gRT );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The table header for the EFI Runtime Services Table.
|
||||||
|
///
|
||||||
|
Status = EfiTableHeader ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
&gRT->Hdr );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Time Services
|
||||||
|
//
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"GetTime",
|
||||||
|
(VOID *)gRT->GetTime,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"SetTime",
|
||||||
|
(VOID *)gRT->SetTime,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"GetWakeupTime",
|
||||||
|
(VOID *)gRT->GetWakeupTime,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"SetWakeupTime",
|
||||||
|
(VOID *)gRT->SetWakeupTime,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Virtual Memory Services
|
||||||
|
//
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"SetVirtualAddressMap",
|
||||||
|
(VOID *)gRT->SetVirtualAddressMap,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"ConvertPointer",
|
||||||
|
(VOID *)gRT->ConvertPointer,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Variable Services
|
||||||
|
//
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"GetVariable",
|
||||||
|
(VOID *)gRT->GetVariable,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"GetNextVariableName",
|
||||||
|
(VOID *)gRT->GetNextVariableName,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"SetVariable",
|
||||||
|
(VOID *)gRT->SetVariable,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Miscellaneous Services
|
||||||
|
//
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"GetNextHighNonotonicCount",
|
||||||
|
(VOID *)gRT->GetNextHighMonotonicCount,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"ResetSystem",
|
||||||
|
(VOID *)gRT->ResetSystem,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Determine if the structures supports 2.0 services
|
||||||
|
//
|
||||||
|
if ( 2 <= ( gRT->Hdr.Revision >> 16 )) {
|
||||||
|
//
|
||||||
|
// UEFI 2.0 Capsule Services
|
||||||
|
//
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"UpdateCapsule",
|
||||||
|
(VOID *)gRT->UpdateCapsule,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"QueryCapsuleCapabilities",
|
||||||
|
(VOID *)gRT->QueryCapsuleCapabilities,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Miscellaneous UEFI 2.0 Service
|
||||||
|
//
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"QueryVariableInfo",
|
||||||
|
(VOID *)gRT->QueryVariableInfo,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Build the table trailer
|
||||||
|
//
|
||||||
|
Status = TableTrailer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
pbDone );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Return the operation status
|
||||||
|
//
|
||||||
|
DBG_EXIT_STATUS ( Status );
|
||||||
|
return Status;
|
||||||
|
}
|
|
@ -0,0 +1,863 @@
|
||||||
|
/*++
|
||||||
|
This file contains an 'Intel UEFI Application' and is
|
||||||
|
licensed for Intel CPUs and chipsets under the terms of your
|
||||||
|
license agreement with Intel or your vendor. This file may
|
||||||
|
be modified by the user, subject to additional terms of the
|
||||||
|
license agreement
|
||||||
|
--*/
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Copyright (c) 2011 Intel Corporation. All rights reserved
|
||||||
|
This software and associated documentation (if any) is furnished
|
||||||
|
under a license and may only be used or copied in accordance
|
||||||
|
with the terms of the license. Except as permitted by such
|
||||||
|
license, no part of this software or documentation may be
|
||||||
|
reproduced, stored in a retrieval system, or transmitted in any
|
||||||
|
form or by any means without the express written consent of
|
||||||
|
Intel Corporation.
|
||||||
|
|
||||||
|
--*/
|
||||||
|
|
||||||
|
/** @file
|
||||||
|
Display the system table
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include <WebServer.h>
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Display the EFI Table Header
|
||||||
|
|
||||||
|
@param [in] SocketFD The socket's file descriptor to add to the list.
|
||||||
|
@param [in] pPort The WSDT_PORT structure address
|
||||||
|
@param [in] pHeader Address of the EFI_TABLE_HEADER structure
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The request was successfully processed
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EfiTableHeader (
|
||||||
|
IN int SocketFD,
|
||||||
|
IN WSDT_PORT * pPort,
|
||||||
|
IN EFI_TABLE_HEADER * pHeader
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
DBG_ENTER ( );
|
||||||
|
|
||||||
|
//
|
||||||
|
// Send the handles page
|
||||||
|
//
|
||||||
|
for ( ; ; ) {
|
||||||
|
///
|
||||||
|
/// A 64-bit signature that identifies the type of table that follows.
|
||||||
|
/// Unique signatures have been generated for the EFI System Table,
|
||||||
|
/// the EFI Boot Services Table, and the EFI Runtime Services Table.
|
||||||
|
///
|
||||||
|
Status = RowHexValue ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"Hdr.Signature",
|
||||||
|
pHeader->Signature,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The revision of the EFI Specification to which this table
|
||||||
|
/// conforms. The upper 16 bits of this field contain the major
|
||||||
|
/// revision value, and the lower 16 bits contain the minor revision
|
||||||
|
/// value. The minor revision values are limited to the range of 00..99.
|
||||||
|
///
|
||||||
|
Status = RowRevision ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"Hdr.Revision",
|
||||||
|
pHeader->Revision );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The size, in bytes, of the entire table including the EFI_TABLE_HEADER.
|
||||||
|
///
|
||||||
|
Status = RowDecimalValue ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"Hdr.HeaderSize",
|
||||||
|
pHeader->HeaderSize );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The 32-bit CRC for the entire table. This value is computed by
|
||||||
|
/// setting this field to 0, and computing the 32-bit CRC for HeaderSize bytes.
|
||||||
|
///
|
||||||
|
Status = RowHexValue ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"Hdr.CRC",
|
||||||
|
pHeader->CRC32,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Reserved field that must be set to 0.
|
||||||
|
///
|
||||||
|
Status = RowHexValue ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"Hdr.Reserved",
|
||||||
|
pHeader->Reserved,
|
||||||
|
NULL );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Return the operation status
|
||||||
|
//
|
||||||
|
DBG_EXIT_STATUS ( Status );
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Display a row containing a decimal value
|
||||||
|
|
||||||
|
@param [in] SocketFD The socket's file descriptor to add to the list.
|
||||||
|
@param [in] pPort The WSDT_PORT structure address
|
||||||
|
@param [in] pName Address of a zero terminated name string
|
||||||
|
@param [in] Value The value to display
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The request was successfully processed
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
RowDecimalValue (
|
||||||
|
IN int SocketFD,
|
||||||
|
IN WSDT_PORT * pPort,
|
||||||
|
IN CONST CHAR8 * pName,
|
||||||
|
IN UINT64 Value
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
DBG_ENTER ( );
|
||||||
|
|
||||||
|
//
|
||||||
|
// Use for/break instead of goto
|
||||||
|
//
|
||||||
|
for ( ; ; ) {
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"<tr><td>" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
pName );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"</td><td><code>" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = HttpSendValue ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
Value );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"</code></td></tr>\r\n" );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Return the operation status
|
||||||
|
//
|
||||||
|
DBG_EXIT_STATUS ( Status );
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Display a row containing a hex value
|
||||||
|
|
||||||
|
@param [in] SocketFD The socket's file descriptor to add to the list.
|
||||||
|
@param [in] pPort The WSDT_PORT structure address
|
||||||
|
@param [in] pName Address of a zero terminated name string
|
||||||
|
@param [in] Value The value to display
|
||||||
|
@param [in] pWebPage Address of a zero terminated web page name
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The request was successfully processed
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
RowHexValue (
|
||||||
|
IN int SocketFD,
|
||||||
|
IN WSDT_PORT * pPort,
|
||||||
|
IN CONST CHAR8 * pName,
|
||||||
|
IN UINT64 Value,
|
||||||
|
IN CONST CHAR16 * pWebPage
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
DBG_ENTER ( );
|
||||||
|
|
||||||
|
//
|
||||||
|
// Use for/break instead of goto
|
||||||
|
//
|
||||||
|
for ( ; ; ) {
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"<tr><td>" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
pName );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"</td><td><code>0x" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if ( NULL != pWebPage ) {
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"<a target=\"_blank\" href=\"" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = HttpSendUnicodeString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
pWebPage );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"\">" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Status = HttpSendHexValue ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
Value );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if ( NULL != pWebPage ) {
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"</a>" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"</code></td></tr>\r\n" );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Return the operation status
|
||||||
|
//
|
||||||
|
DBG_EXIT_STATUS ( Status );
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Display a row containing a pointer
|
||||||
|
|
||||||
|
@param [in] SocketFD The socket's file descriptor to add to the list.
|
||||||
|
@param [in] pPort The WSDT_PORT structure address
|
||||||
|
@param [in] pName Address of a zero terminated name string
|
||||||
|
@param [in] pAddress The address to display
|
||||||
|
@param [in] pWebPage Address of a zero terminated web page name
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The request was successfully processed
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
RowPointer (
|
||||||
|
IN int SocketFD,
|
||||||
|
IN WSDT_PORT * pPort,
|
||||||
|
IN CONST CHAR8 * pName,
|
||||||
|
IN CONST VOID * pAddress,
|
||||||
|
IN CONST CHAR16 * pWebPage
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
DBG_ENTER ( );
|
||||||
|
|
||||||
|
//
|
||||||
|
// Use for/break instead of goto
|
||||||
|
//
|
||||||
|
for ( ; ; ) {
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"<tr><td>" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
pName );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"</td><td><code>" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if ( NULL != pWebPage ) {
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"<a target=\"_blank\" href=\"" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = HttpSendUnicodeString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
pWebPage );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"\">" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"0x" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = HttpSendHexBits ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
sizeof ( pAddress ) * 8,
|
||||||
|
(UINT64) pAddress );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if ( NULL != pWebPage ) {
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"</a>" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"</code></td></tr>\r\n" );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Return the operation status
|
||||||
|
//
|
||||||
|
DBG_EXIT_STATUS ( Status );
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Display a row containing a revision
|
||||||
|
|
||||||
|
@param [in] SocketFD The socket's file descriptor to add to the list.
|
||||||
|
@param [in] pPort The WSDT_PORT structure address
|
||||||
|
@param [in] pName Address of a zero terminated name string
|
||||||
|
@param [in] Revision The revision to display
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The request was successfully processed
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
RowRevision (
|
||||||
|
IN int SocketFD,
|
||||||
|
IN WSDT_PORT * pPort,
|
||||||
|
IN CONST CHAR8 * pName,
|
||||||
|
IN UINT32 Revision
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
DBG_ENTER ( );
|
||||||
|
|
||||||
|
//
|
||||||
|
// Use for/break instead of goto
|
||||||
|
//
|
||||||
|
for ( ; ; ) {
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"<tr><td>" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
pName );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"</td><td><code>" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = HttpSendValue ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
Revision >> 16 );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = HttpSendByte ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
'.' );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = HttpSendValue ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
Revision & 0xFFFF );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"</code></td></tr>\r\n" );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Return the operation status
|
||||||
|
//
|
||||||
|
DBG_EXIT_STATUS ( Status );
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Display a row containing a unicode string
|
||||||
|
|
||||||
|
@param [in] SocketFD The socket's file descriptor to add to the list.
|
||||||
|
@param [in] pPort The WSDT_PORT structure address
|
||||||
|
@param [in] pName Address of a zero terminated name string
|
||||||
|
@param [in] pString Address of a zero terminated unicode string
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The request was successfully processed
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
RowUnicodeString (
|
||||||
|
IN int SocketFD,
|
||||||
|
IN WSDT_PORT * pPort,
|
||||||
|
IN CONST CHAR8 * pName,
|
||||||
|
IN CONST CHAR16 * pString
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
DBG_ENTER ( );
|
||||||
|
|
||||||
|
//
|
||||||
|
// Use for/break instead of goto
|
||||||
|
//
|
||||||
|
for ( ; ; ) {
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"<tr><td>" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
pName );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"</td><td>" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = HttpSendUnicodeString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
pString );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"</td></tr>\r\n" );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Return the operation status
|
||||||
|
//
|
||||||
|
DBG_EXIT_STATUS ( Status );
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Start the table page
|
||||||
|
|
||||||
|
@param [in] SocketFD The socket's file descriptor to add to the list.
|
||||||
|
@param [in] pPort The WSDT_PORT structure address
|
||||||
|
@param [in] pName Address of a zero terminated name string
|
||||||
|
@param [in] pTable Address of the table
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The request was successfully processed
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
TableHeader (
|
||||||
|
IN int SocketFD,
|
||||||
|
IN WSDT_PORT * pPort,
|
||||||
|
IN CONST CHAR16 * pName,
|
||||||
|
IN CONST VOID * pTable
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
DBG_ENTER ( );
|
||||||
|
|
||||||
|
//
|
||||||
|
// Use for/break instead of goto
|
||||||
|
//
|
||||||
|
for ( ; ; ) {
|
||||||
|
//
|
||||||
|
// Send the page header
|
||||||
|
//
|
||||||
|
Status = HttpPageHeader ( SocketFD, pPort, pName );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Build the table header
|
||||||
|
//
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"<h1>" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = HttpSendUnicodeString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
pName );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if ( NULL != pTable ) {
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
": 0x" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Status = HttpSendHexBits ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
sizeof ( pTable ) * 8,
|
||||||
|
(UINT64)pTable );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"</h1>\r\n"
|
||||||
|
"<table border=\"1\">\r\n"
|
||||||
|
" <tr bgcolor=\"c0c0ff\"><th>Field Name</th><th>Value</th></tr>\r\n" );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Return the operation status
|
||||||
|
//
|
||||||
|
DBG_EXIT_STATUS ( Status );
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
End the table page
|
||||||
|
|
||||||
|
@param [in] SocketFD The socket's file descriptor to add to the list.
|
||||||
|
@param [in] pPort The WSDT_PORT structure address
|
||||||
|
@param [out] pbDone Address to receive the request completion status
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The request was successfully processed
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
TableTrailer (
|
||||||
|
IN int SocketFD,
|
||||||
|
IN WSDT_PORT * pPort,
|
||||||
|
OUT BOOLEAN *pbDone
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
DBG_ENTER ( );
|
||||||
|
|
||||||
|
//
|
||||||
|
// Use for/break instead of goto
|
||||||
|
//
|
||||||
|
for ( ; ; ) {
|
||||||
|
//
|
||||||
|
// Build the table trailer
|
||||||
|
//
|
||||||
|
Status = HttpSendAnsiString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"</table>\r\n" );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Send the page trailer
|
||||||
|
//
|
||||||
|
Status = HttpPageTrailer ( SocketFD, pPort, pbDone );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Return the operation status
|
||||||
|
//
|
||||||
|
DBG_EXIT_STATUS ( Status );
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Respond with the system table
|
||||||
|
|
||||||
|
@param [in] SocketFD The socket's file descriptor to add to the list.
|
||||||
|
@param [in] pPort The WSDT_PORT structure address
|
||||||
|
@param [out] pbDone Address to receive the request completion status
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The request was successfully processed
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
SystemTablePage (
|
||||||
|
IN int SocketFD,
|
||||||
|
IN WSDT_PORT * pPort,
|
||||||
|
OUT BOOLEAN * pbDone
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
DBG_ENTER ( );
|
||||||
|
|
||||||
|
//
|
||||||
|
// Send the system table page
|
||||||
|
//
|
||||||
|
for ( ; ; ) {
|
||||||
|
//
|
||||||
|
// Send the page and table header
|
||||||
|
//
|
||||||
|
Status = TableHeader ( SocketFD, pPort, L"System Table", gST );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The table header for the EFI System Table.
|
||||||
|
///
|
||||||
|
Status = EfiTableHeader ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
&gST->Hdr );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// A pointer to a null terminated string that identifies the vendor
|
||||||
|
/// that produces the system firmware for the platform.
|
||||||
|
///
|
||||||
|
Status = RowUnicodeString ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"FirmwareVendor",
|
||||||
|
gST->FirmwareVendor );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// A firmware vendor specific value that identifies the revision
|
||||||
|
/// of the system firmware for the platform.
|
||||||
|
///
|
||||||
|
Status = RowRevision ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"FirmwareRevision",
|
||||||
|
gST->FirmwareRevision );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The handle for the active console input device. This handle must support
|
||||||
|
/// EFI_SIMPLE_TEXT_INPUT_PROTOCOL and EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL.
|
||||||
|
///
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"ConsoleInHandle",
|
||||||
|
(VOID *)gST->ConsoleInHandle,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// A pointer to the EFI_SIMPLE_TEXT_INPUT_PROTOCOL interface that is
|
||||||
|
/// associated with ConsoleInHandle.
|
||||||
|
///
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"ConIn",
|
||||||
|
(VOID *)gST->ConIn,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The handle for the active console output device.
|
||||||
|
///
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"ConsoleOutHandle",
|
||||||
|
(VOID *)gST->ConsoleOutHandle,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// A pointer to the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL interface
|
||||||
|
/// that is associated with ConsoleOutHandle.
|
||||||
|
///
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"ConOut",
|
||||||
|
(VOID *)gST->ConOut,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The handle for the active standard error console device.
|
||||||
|
/// This handle must support the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.
|
||||||
|
///
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"StandardErrorHandle",
|
||||||
|
(VOID *)gST->StandardErrorHandle,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// A pointer to the EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL interface
|
||||||
|
/// that is associated with StandardErrorHandle.
|
||||||
|
///
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"StdErr",
|
||||||
|
(VOID *)gST->StdErr,
|
||||||
|
NULL );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// A pointer to the EFI Runtime Services Table.
|
||||||
|
///
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"RuntimeServices",
|
||||||
|
(VOID *)gST->RuntimeServices,
|
||||||
|
PAGE_RUNTIME_SERVICES_TABLE );
|
||||||
|
|
||||||
|
///
|
||||||
|
/// A pointer to the EFI Boot Services Table.
|
||||||
|
///
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"BootServices",
|
||||||
|
(VOID *)gST->BootServices,
|
||||||
|
PAGE_BOOT_SERVICES_TABLE );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// The number of system configuration tables in the buffer ConfigurationTable.
|
||||||
|
///
|
||||||
|
Status = RowDecimalValue ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"NumberOfTableEntries",
|
||||||
|
gST->NumberOfTableEntries );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// A pointer to the system configuration tables.
|
||||||
|
/// The number of entries in the table is NumberOfTableEntries.
|
||||||
|
///
|
||||||
|
Status = RowPointer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
"ConfigurationTable",
|
||||||
|
(VOID *)gST->ConfigurationTable,
|
||||||
|
PAGE_CONFIGURATION_TABLE );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Build the table trailer
|
||||||
|
//
|
||||||
|
Status = TableTrailer ( SocketFD,
|
||||||
|
pPort,
|
||||||
|
pbDone );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Return the operation status
|
||||||
|
//
|
||||||
|
DBG_EXIT_STATUS ( Status );
|
||||||
|
return Status;
|
||||||
|
}
|
|
@ -0,0 +1,853 @@
|
||||||
|
/*++
|
||||||
|
This file contains an 'Intel UEFI Application' and is
|
||||||
|
licensed for Intel CPUs and chipsets under the terms of your
|
||||||
|
license agreement with Intel or your vendor. This file may
|
||||||
|
be modified by the user, subject to additional terms of the
|
||||||
|
license agreement
|
||||||
|
--*/
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Copyright (c) 2011 Intel Corporation. All rights reserved
|
||||||
|
This software and associated documentation (if any) is furnished
|
||||||
|
under a license and may only be used or copied in accordance
|
||||||
|
with the terms of the license. Except as permitted by such
|
||||||
|
license, no part of this software or documentation may be
|
||||||
|
reproduced, stored in a retrieval system, or transmitted in any
|
||||||
|
form or by any means without the express written consent of
|
||||||
|
Intel Corporation.
|
||||||
|
|
||||||
|
--*/
|
||||||
|
|
||||||
|
/** @file
|
||||||
|
This is a simple shell application
|
||||||
|
|
||||||
|
This should be executed with "/Param2 Val1" and "/Param1" as the 2 command line options!
|
||||||
|
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include <WebServer.h>
|
||||||
|
|
||||||
|
DT_WEB_SERVER mWebServer; ///< Web server's control structure
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Add a port to the list of ports to be polled.
|
||||||
|
|
||||||
|
@param [in] pWebServer The web server control structure address.
|
||||||
|
|
||||||
|
@param [in] SocketFD The socket's file descriptor to add to the list.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The port was successfully added
|
||||||
|
@retval EFI_NO_RESOURCES Insufficient memory to add the port
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
PortAdd (
|
||||||
|
IN DT_WEB_SERVER * pWebServer,
|
||||||
|
IN int SocketFD
|
||||||
|
)
|
||||||
|
{
|
||||||
|
nfds_t Index;
|
||||||
|
size_t LengthInBytes;
|
||||||
|
nfds_t MaxEntries;
|
||||||
|
nfds_t MaxEntriesNew;
|
||||||
|
struct pollfd * pFdList;
|
||||||
|
struct pollfd * pFdListNew;
|
||||||
|
WSDT_PORT ** ppPortListNew;
|
||||||
|
WSDT_PORT * pPort;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
DBG_ENTER ( );
|
||||||
|
|
||||||
|
//
|
||||||
|
// Use for/break instead of goto
|
||||||
|
//
|
||||||
|
for ( ; ; ) {
|
||||||
|
//
|
||||||
|
// Assume success
|
||||||
|
//
|
||||||
|
Status = EFI_SUCCESS;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Create a new list if necessary
|
||||||
|
//
|
||||||
|
pFdList = pWebServer->pFdList;
|
||||||
|
MaxEntries = pWebServer->MaxEntries;
|
||||||
|
if ( pWebServer->Entries >= MaxEntries ) {
|
||||||
|
MaxEntriesNew = 16 + MaxEntries;
|
||||||
|
|
||||||
|
//
|
||||||
|
// The current FD list is full
|
||||||
|
// Allocate a new FD list
|
||||||
|
//
|
||||||
|
LengthInBytes = sizeof ( *pFdList ) * MaxEntriesNew;
|
||||||
|
Status = gBS->AllocatePool ( EfiRuntimeServicesData,
|
||||||
|
LengthInBytes,
|
||||||
|
(VOID **)&pFdListNew );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
DEBUG (( DEBUG_ERROR | DEBUG_POOL,
|
||||||
|
"ERROR - Failed to allocate the FD list, Status: %r\r\n",
|
||||||
|
Status ));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Allocate a new port list
|
||||||
|
//
|
||||||
|
LengthInBytes = sizeof ( *ppPortListNew ) * MaxEntriesNew;
|
||||||
|
Status = gBS->AllocatePool ( EfiRuntimeServicesData,
|
||||||
|
LengthInBytes,
|
||||||
|
(VOID **) &ppPortListNew );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
DEBUG (( DEBUG_ERROR | DEBUG_POOL,
|
||||||
|
"ERROR - Failed to allocate the port list, Status: %r\r\n",
|
||||||
|
Status ));
|
||||||
|
|
||||||
|
//
|
||||||
|
// Free the new FD list
|
||||||
|
//
|
||||||
|
gBS->FreePool ( pFdListNew );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Duplicate the FD list
|
||||||
|
//
|
||||||
|
Index = MaxEntries;
|
||||||
|
if ( NULL != pFdList ) {
|
||||||
|
CopyMem ( pFdListNew,
|
||||||
|
pFdList,
|
||||||
|
Index * sizeof ( *pFdList ));
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Initialize the new entries in the FD list
|
||||||
|
//
|
||||||
|
for ( ; MaxEntriesNew > Index; Index++ ) {
|
||||||
|
pFdListNew [ Index ].fd = -1;
|
||||||
|
pFdListNew [ Index ].events = 0;
|
||||||
|
pFdListNew [ Index ].revents = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Free the old FD list
|
||||||
|
//
|
||||||
|
if ( NULL != pFdList ) {
|
||||||
|
gBS->FreePool ( pFdList );
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Switch to the new FD list
|
||||||
|
//
|
||||||
|
pWebServer->pFdList = pFdListNew;
|
||||||
|
pFdList = pWebServer->pFdList;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Duplicate the port list
|
||||||
|
//
|
||||||
|
Index = MaxEntries;
|
||||||
|
if ( NULL != pWebServer->ppPortList ) {
|
||||||
|
CopyMem ( ppPortListNew,
|
||||||
|
pWebServer->ppPortList,
|
||||||
|
Index * sizeof ( *ppPortListNew ));
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Initialize the new entries in the port list
|
||||||
|
//
|
||||||
|
for ( ; MaxEntriesNew > Index; Index++ ) {
|
||||||
|
ppPortListNew [ Index ] = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Free the old port list
|
||||||
|
//
|
||||||
|
if ( NULL != pWebServer->ppPortList ) {
|
||||||
|
gBS->FreePool ( pWebServer->ppPortList );
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Switch to the new port list
|
||||||
|
//
|
||||||
|
pWebServer->ppPortList = ppPortListNew;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Update the list size
|
||||||
|
//
|
||||||
|
pWebServer->MaxEntries = MaxEntriesNew;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Allocate a new port
|
||||||
|
//
|
||||||
|
LengthInBytes = sizeof ( *pPort );
|
||||||
|
Status = gBS->AllocatePool ( EfiRuntimeServicesData,
|
||||||
|
LengthInBytes,
|
||||||
|
(VOID **)&pPort );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
DEBUG (( DEBUG_ERROR | DEBUG_POOL,
|
||||||
|
"ERROR - Failed to allocate the port, Status: %r\r\n",
|
||||||
|
Status ));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Initialize the port
|
||||||
|
//
|
||||||
|
pPort->RequestLength = 0;
|
||||||
|
pPort->TxBytes = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Add the socket to the FD list
|
||||||
|
//
|
||||||
|
pFdList [ pWebServer->Entries ].fd = SocketFD;
|
||||||
|
pFdList [ pWebServer->Entries ].events = POLLRDNORM
|
||||||
|
| POLLHUP;
|
||||||
|
pFdList [ pWebServer->Entries ].revents = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Add the port to the port list
|
||||||
|
//
|
||||||
|
pWebServer->ppPortList [ pWebServer->Entries ] = pPort;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Account for the new entry
|
||||||
|
//
|
||||||
|
pWebServer->Entries += 1;
|
||||||
|
DEBUG (( DEBUG_PORT_WORK | DEBUG_INFO,
|
||||||
|
"WebServer handling %d ports\r\n",
|
||||||
|
pWebServer->Entries ));
|
||||||
|
|
||||||
|
//
|
||||||
|
// All done
|
||||||
|
//
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Return the operation status
|
||||||
|
//
|
||||||
|
DBG_EXIT_STATUS ( Status );
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Remove a port from the list of ports to be polled.
|
||||||
|
|
||||||
|
@param [in] pWebServer The web server control structure address.
|
||||||
|
|
||||||
|
@param [in] SocketFD The socket's file descriptor to add to the list.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
PortRemove (
|
||||||
|
IN DT_WEB_SERVER * pWebServer,
|
||||||
|
IN int SocketFD
|
||||||
|
)
|
||||||
|
{
|
||||||
|
nfds_t Entries;
|
||||||
|
nfds_t Index;
|
||||||
|
struct pollfd * pFdList;
|
||||||
|
WSDT_PORT ** ppPortList;
|
||||||
|
|
||||||
|
DBG_ENTER ( );
|
||||||
|
|
||||||
|
//
|
||||||
|
// Attempt to remove the entry from the list
|
||||||
|
//
|
||||||
|
Entries = pWebServer->Entries;
|
||||||
|
pFdList = pWebServer->pFdList;
|
||||||
|
ppPortList = pWebServer->ppPortList;
|
||||||
|
for ( Index = 0; Entries > Index; Index++ ) {
|
||||||
|
//
|
||||||
|
// Locate the specified socket file descriptor
|
||||||
|
//
|
||||||
|
if ( SocketFD == pFdList [ Index ].fd ) {
|
||||||
|
//
|
||||||
|
// Determine if this is the listen port
|
||||||
|
//
|
||||||
|
if ( SocketFD == pWebServer->HttpListenPort ) {
|
||||||
|
pWebServer->HttpListenPort = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Close the socket
|
||||||
|
//
|
||||||
|
close ( SocketFD );
|
||||||
|
|
||||||
|
//
|
||||||
|
// Free the port structure
|
||||||
|
//
|
||||||
|
gBS->FreePool ( ppPortList [ Index ]);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Remove this port from the list by copying
|
||||||
|
// the rest of the list down one entry
|
||||||
|
//
|
||||||
|
Entries -= 1;
|
||||||
|
for ( ; Entries > Index; Index++ ) {
|
||||||
|
pFdList [ Index ] = pFdList [ Index + 1 ];
|
||||||
|
ppPortList [ Index ] = ppPortList [ Index + 1 ];
|
||||||
|
}
|
||||||
|
pFdList [ Index ].fd = -1;
|
||||||
|
pFdList [ Index ].events = 0;
|
||||||
|
pFdList [ Index ].revents = 0;
|
||||||
|
ppPortList [ Index ] = NULL;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Update the number of entries in the list
|
||||||
|
//
|
||||||
|
pWebServer->Entries = Entries;
|
||||||
|
DEBUG (( DEBUG_PORT_WORK | DEBUG_INFO,
|
||||||
|
"WebServer handling %d ports\r\n",
|
||||||
|
pWebServer->Entries ));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DBG_EXIT ( );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Process the work for the sockets.
|
||||||
|
|
||||||
|
@param [in] pWebServer The web server control structure address.
|
||||||
|
|
||||||
|
@param [in] SocketFD The socket's file descriptor to add to the list.
|
||||||
|
|
||||||
|
@param [in] events everts is a bitmask of the work to be done
|
||||||
|
|
||||||
|
@param [in] pPort The address of a WSDT_PORT structure
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The operation was successful
|
||||||
|
@retval EFI_DEVICE_ERROR Error, close the port
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
PortWork (
|
||||||
|
IN DT_WEB_SERVER * pWebServer,
|
||||||
|
IN int SocketFD,
|
||||||
|
IN INTN events,
|
||||||
|
IN WSDT_PORT * pPort
|
||||||
|
)
|
||||||
|
{
|
||||||
|
BOOLEAN bDone;
|
||||||
|
size_t LengthInBytes;
|
||||||
|
int NewSocket;
|
||||||
|
EFI_STATUS OpStatus;
|
||||||
|
struct sockaddr RemoteAddress;
|
||||||
|
socklen_t RemoteAddressLength;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
DEBUG (( DEBUG_PORT_WORK, "Entering PortWork\r\n" ));
|
||||||
|
|
||||||
|
//
|
||||||
|
// Assume success
|
||||||
|
//
|
||||||
|
OpStatus = EFI_SUCCESS;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Handle input events
|
||||||
|
//
|
||||||
|
if ( 0 != ( events & POLLRDNORM )) {
|
||||||
|
//
|
||||||
|
// Determine if this is a connection attempt
|
||||||
|
//
|
||||||
|
if ( SocketFD == pWebServer->HttpListenPort ) {
|
||||||
|
//
|
||||||
|
// Handle connection attempts
|
||||||
|
// Accepts arrive as read events
|
||||||
|
//
|
||||||
|
RemoteAddressLength = sizeof ( RemoteAddress );
|
||||||
|
NewSocket = accept ( SocketFD,
|
||||||
|
&RemoteAddress,
|
||||||
|
&RemoteAddressLength );
|
||||||
|
if ( -1 != NewSocket ) {
|
||||||
|
if ( 0 != NewSocket ) {
|
||||||
|
//
|
||||||
|
// Add this port to the list monitored by the web server
|
||||||
|
//
|
||||||
|
Status = PortAdd ( pWebServer, NewSocket );
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
DEBUG (( DEBUG_ERROR,
|
||||||
|
"ERROR - Failed to add the port 0x%08x, Status: %r\r\n",
|
||||||
|
NewSocket,
|
||||||
|
Status ));
|
||||||
|
|
||||||
|
//
|
||||||
|
// Done with the new socket
|
||||||
|
//
|
||||||
|
close ( NewSocket );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
DEBUG (( DEBUG_ERROR,
|
||||||
|
"ERROR - Socket not available!\r\n" ));
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Leave the listen port open
|
||||||
|
//
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//
|
||||||
|
// Listen port error
|
||||||
|
// Close the listen port by returning error status
|
||||||
|
//
|
||||||
|
OpStatus = EFI_DEVICE_ERROR;
|
||||||
|
DEBUG (( DEBUG_ERROR,
|
||||||
|
"ERROR - Failed to accept new connection, errno: 0x%08x\r\n",
|
||||||
|
errno ));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//
|
||||||
|
// Handle the data received event
|
||||||
|
//
|
||||||
|
if ( 0 == pPort->RequestLength ) {
|
||||||
|
//
|
||||||
|
// Receive the page request
|
||||||
|
//
|
||||||
|
pPort->RequestLength = recv ( SocketFD,
|
||||||
|
&pPort->Request[0],
|
||||||
|
DIM ( pPort->Request ),
|
||||||
|
0 );
|
||||||
|
if ( -1 == pPort->RequestLength ) {
|
||||||
|
//
|
||||||
|
// Receive error detected
|
||||||
|
// Close the port
|
||||||
|
//
|
||||||
|
OpStatus = EFI_DEVICE_ERROR;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
DEBUG (( DEBUG_REQUEST,
|
||||||
|
"0x%08x: Socket - Received %d bytes of HTTP request\r\n",
|
||||||
|
SocketFD,
|
||||||
|
pPort->RequestLength ));
|
||||||
|
|
||||||
|
//
|
||||||
|
// Process the request
|
||||||
|
//
|
||||||
|
OpStatus = HttpRequest ( SocketFD, pPort, &bDone );
|
||||||
|
if ( bDone ) {
|
||||||
|
//
|
||||||
|
// Notify the upper layer to close the socket
|
||||||
|
//
|
||||||
|
OpStatus = EFI_DEVICE_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Receive the file data
|
||||||
|
//
|
||||||
|
LengthInBytes = recv ( SocketFD,
|
||||||
|
&pPort->RxBuffer[0],
|
||||||
|
DIM ( pPort->RxBuffer ),
|
||||||
|
0 );
|
||||||
|
if ( -1 == LengthInBytes ) {
|
||||||
|
//
|
||||||
|
// Receive error detected
|
||||||
|
// Close the port
|
||||||
|
//
|
||||||
|
OpStatus = EFI_DEVICE_ERROR;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
DEBUG (( DEBUG_REQUEST,
|
||||||
|
"0x%08x: Socket - Received %d bytes of file data\r\n",
|
||||||
|
SocketFD,
|
||||||
|
LengthInBytes ));
|
||||||
|
|
||||||
|
//
|
||||||
|
// TODO: Process the file data
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Handle the close event
|
||||||
|
//
|
||||||
|
if ( 0 != ( events & POLLHUP )) {
|
||||||
|
//
|
||||||
|
// Close the port
|
||||||
|
//
|
||||||
|
OpStatus = EFI_DEVICE_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Return the operation status
|
||||||
|
//
|
||||||
|
DEBUG (( DEBUG_PORT_WORK,
|
||||||
|
"Exiting PortWork, Status: %r\r\n",
|
||||||
|
OpStatus ));
|
||||||
|
return OpStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Scan the list of sockets and process any pending work
|
||||||
|
|
||||||
|
@param [in] pWebServer The web server control structure address.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
SocketPoll (
|
||||||
|
IN DT_WEB_SERVER * pWebServer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
int FDCount;
|
||||||
|
struct pollfd * pPoll;
|
||||||
|
WSDT_PORT ** ppPort;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
DEBUG (( DEBUG_SOCKET_POLL, "Entering SocketPoll\r\n" ));
|
||||||
|
|
||||||
|
//
|
||||||
|
// Determine if any ports are active
|
||||||
|
//
|
||||||
|
FDCount = poll ( pWebServer->pFdList,
|
||||||
|
pWebServer->Entries,
|
||||||
|
CLIENT_POLL_DELAY );
|
||||||
|
if ( -1 == FDCount ) {
|
||||||
|
DEBUG (( DEBUG_ERROR | DEBUG_SOCKET_POLL,
|
||||||
|
"ERROR - errno: %d\r\n",
|
||||||
|
errno ));
|
||||||
|
}
|
||||||
|
|
||||||
|
pPoll = pWebServer->pFdList;
|
||||||
|
ppPort = pWebServer->ppPortList;
|
||||||
|
while ( 0 < FDCount ) {
|
||||||
|
//
|
||||||
|
// Walk the list of ports to determine what work needs to be done
|
||||||
|
//
|
||||||
|
if ( 0 != pPoll->revents ) {
|
||||||
|
//
|
||||||
|
// Process this port
|
||||||
|
//
|
||||||
|
Status = PortWork ( pWebServer,
|
||||||
|
pPoll->fd,
|
||||||
|
pPoll->revents,
|
||||||
|
*ppPort );
|
||||||
|
pPoll->revents = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Close the port if necessary
|
||||||
|
//
|
||||||
|
if ( EFI_ERROR ( Status )) {
|
||||||
|
PortRemove ( pWebServer, pPoll->fd );
|
||||||
|
pPoll -= 1;
|
||||||
|
ppPort -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Account for this file descriptor
|
||||||
|
//
|
||||||
|
FDCount -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Set the next port
|
||||||
|
//
|
||||||
|
pPoll += 1;
|
||||||
|
ppPort += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
DEBUG (( DEBUG_SOCKET_POLL, "Exiting SocketPoll\r\n" ));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Create the HTTP port for the web server
|
||||||
|
|
||||||
|
This routine polls the network layer to create the HTTP port for the
|
||||||
|
web server. More than one attempt may be necessary since it may take
|
||||||
|
some time to get the IP address and initialize the upper layers of
|
||||||
|
the network stack.
|
||||||
|
|
||||||
|
After the HTTP port is created, the socket layer will manage the
|
||||||
|
coming and going of the network connections until the last network
|
||||||
|
connection is broken.
|
||||||
|
|
||||||
|
@param [in] pWebServer The web server control structure address.
|
||||||
|
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
WebServerTimer (
|
||||||
|
IN DT_WEB_SERVER * pWebServer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
UINT16 HttpPort;
|
||||||
|
struct sockaddr_in WebServerAddress;
|
||||||
|
int SocketStatus;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
DEBUG (( DEBUG_SERVER_TIMER, "Entering WebServerTimer\r\n" ));
|
||||||
|
|
||||||
|
//
|
||||||
|
// Open the HTTP port on the server
|
||||||
|
//
|
||||||
|
do {
|
||||||
|
do {
|
||||||
|
//
|
||||||
|
// Complete the client operations
|
||||||
|
//
|
||||||
|
SocketPoll ( pWebServer );
|
||||||
|
|
||||||
|
//
|
||||||
|
// Wait for a while
|
||||||
|
//
|
||||||
|
Status = gBS->CheckEvent ( pWebServer->TimerEvent );
|
||||||
|
} while ( EFI_SUCCESS != Status );
|
||||||
|
|
||||||
|
//
|
||||||
|
// Attempt to create the socket for the web server
|
||||||
|
//
|
||||||
|
pWebServer->HttpListenPort = socket ( AF_INET,
|
||||||
|
SOCK_STREAM,
|
||||||
|
IPPROTO_TCP );
|
||||||
|
if ( -1 != pWebServer->HttpListenPort )
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Set the socket address
|
||||||
|
//
|
||||||
|
ZeroMem ( &WebServerAddress, sizeof ( WebServerAddress ));
|
||||||
|
HttpPort = PcdGet16 ( WebServer_HttpPort );
|
||||||
|
DEBUG (( DEBUG_HTTP_PORT,
|
||||||
|
"HTTP Port: %d\r\n",
|
||||||
|
HttpPort ));
|
||||||
|
WebServerAddress.sin_len = sizeof ( WebServerAddress );
|
||||||
|
WebServerAddress.sin_family = AF_INET;
|
||||||
|
WebServerAddress.sin_addr.s_addr = INADDR_ANY;
|
||||||
|
WebServerAddress.sin_port = htons ( HttpPort );
|
||||||
|
|
||||||
|
//
|
||||||
|
// Bind the socket to the HTTP port
|
||||||
|
//
|
||||||
|
SocketStatus = bind ( pWebServer->HttpListenPort,
|
||||||
|
(struct sockaddr *) &WebServerAddress,
|
||||||
|
WebServerAddress.sin_len );
|
||||||
|
if ( -1 != SocketStatus ) {
|
||||||
|
//
|
||||||
|
// Enable connections to the HTTP port
|
||||||
|
//
|
||||||
|
SocketStatus = listen ( pWebServer->HttpListenPort,
|
||||||
|
SOMAXCONN );
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Release the socket if necessary
|
||||||
|
//
|
||||||
|
if ( -1 == SocketStatus ) {
|
||||||
|
close ( pWebServer->HttpListenPort );
|
||||||
|
pWebServer->HttpListenPort = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Wait until the socket is open
|
||||||
|
//
|
||||||
|
}while ( -1 == pWebServer->HttpListenPort );
|
||||||
|
|
||||||
|
DEBUG (( DEBUG_SERVER_TIMER, "Exiting WebServerTimer\r\n" ));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Start the web server port creation timer
|
||||||
|
|
||||||
|
@param [in] pWebServer The web server control structure address.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The timer was successfully started.
|
||||||
|
@retval EFI_ALREADY_STARTED The timer is already running.
|
||||||
|
@retval Other The timer failed to start.
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
WebServerTimerStart (
|
||||||
|
IN DT_WEB_SERVER * pWebServer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
UINT64 TriggerTime;
|
||||||
|
|
||||||
|
DBG_ENTER ( );
|
||||||
|
|
||||||
|
//
|
||||||
|
// Assume the timer is already running
|
||||||
|
//
|
||||||
|
Status = EFI_ALREADY_STARTED;
|
||||||
|
if ( !pWebServer->bTimerRunning ) {
|
||||||
|
//
|
||||||
|
// Compute the poll interval
|
||||||
|
//
|
||||||
|
TriggerTime = HTTP_PORT_POLL_DELAY * ( 1000 * 10 );
|
||||||
|
Status = gBS->SetTimer ( pWebServer->TimerEvent,
|
||||||
|
TimerPeriodic,
|
||||||
|
TriggerTime );
|
||||||
|
if ( !EFI_ERROR ( Status )) {
|
||||||
|
DEBUG (( DEBUG_HTTP_PORT, "HTTP port timer started\r\n" ));
|
||||||
|
|
||||||
|
//
|
||||||
|
// Mark the timer running
|
||||||
|
//
|
||||||
|
pWebServer->bTimerRunning = TRUE;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
DEBUG (( DEBUG_ERROR | DEBUG_HTTP_PORT,
|
||||||
|
"ERROR - Failed to start HTTP port timer, Status: %r\r\n",
|
||||||
|
Status ));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Return the operation status
|
||||||
|
//
|
||||||
|
DBG_EXIT_STATUS ( Status );
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Stop the web server port creation timer
|
||||||
|
|
||||||
|
@param [in] pWebServer The web server control structure address.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The HTTP port timer is stopped
|
||||||
|
@retval Other Failed to stop the HTTP port timer
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
WebServerTimerStop (
|
||||||
|
IN DT_WEB_SERVER * pWebServer
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
DBG_ENTER ( );
|
||||||
|
|
||||||
|
//
|
||||||
|
// Assume the timer is stopped
|
||||||
|
//
|
||||||
|
Status = EFI_SUCCESS;
|
||||||
|
if ( pWebServer->bTimerRunning ) {
|
||||||
|
//
|
||||||
|
// Stop the port creation polling
|
||||||
|
//
|
||||||
|
Status = gBS->SetTimer ( pWebServer->TimerEvent,
|
||||||
|
TimerCancel,
|
||||||
|
0 );
|
||||||
|
if ( !EFI_ERROR ( Status )) {
|
||||||
|
DEBUG (( DEBUG_HTTP_PORT, "HTTP port timer stopped\r\n" ));
|
||||||
|
|
||||||
|
//
|
||||||
|
// Mark the timer stopped
|
||||||
|
//
|
||||||
|
pWebServer->bTimerRunning = FALSE;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
DEBUG (( DEBUG_ERROR | DEBUG_HTTP_PORT,
|
||||||
|
"ERROR - Failed to stop HTTP port timer, Status: %r\r\n",
|
||||||
|
Status ));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Return the operation status
|
||||||
|
//
|
||||||
|
DBG_EXIT_STATUS ( Status );
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Entry point for the web server application.
|
||||||
|
|
||||||
|
@param [in] Argc The number of arguments
|
||||||
|
@param [in] Argv The argument value array
|
||||||
|
|
||||||
|
@retval 0 The application exited normally.
|
||||||
|
@retval Other An error occurred.
|
||||||
|
**/
|
||||||
|
int
|
||||||
|
main (
|
||||||
|
IN int Argc,
|
||||||
|
IN char **Argv
|
||||||
|
)
|
||||||
|
{
|
||||||
|
DT_WEB_SERVER * pWebServer;
|
||||||
|
EFI_STATUS Status;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Create a timer event to start HTTP port
|
||||||
|
//
|
||||||
|
pWebServer = &mWebServer;
|
||||||
|
Status = gBS->CreateEvent ( EVT_TIMER,
|
||||||
|
TPL_WEB_SERVER,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
&pWebServer->TimerEvent );
|
||||||
|
if ( !EFI_ERROR ( Status )) {
|
||||||
|
Status = WebServerTimerStart ( pWebServer );
|
||||||
|
if ( !EFI_ERROR ( Status )) {
|
||||||
|
//
|
||||||
|
// Run the web server forever
|
||||||
|
//
|
||||||
|
for ( ; ; ) {
|
||||||
|
//
|
||||||
|
// Poll the network layer to create the HTTP port
|
||||||
|
// for the web server. More than one attempt may
|
||||||
|
// be necessary since it may take some time to get
|
||||||
|
// the IP address and initialize the upper layers
|
||||||
|
// of the network stack.
|
||||||
|
//
|
||||||
|
WebServerTimer ( pWebServer );
|
||||||
|
|
||||||
|
//
|
||||||
|
// Add the HTTP port to the list of ports
|
||||||
|
//
|
||||||
|
Status = PortAdd ( pWebServer, pWebServer->HttpListenPort );
|
||||||
|
if ( !EFI_ERROR ( Status )) {
|
||||||
|
//
|
||||||
|
// Poll the sockets for activity
|
||||||
|
//
|
||||||
|
do {
|
||||||
|
SocketPoll ( pWebServer );
|
||||||
|
} while ( -1 != pWebServer->HttpListenPort );
|
||||||
|
|
||||||
|
//
|
||||||
|
// The HTTP port failed the accept and was closed
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Close the HTTP port if necessary
|
||||||
|
//
|
||||||
|
if ( -1 != pWebServer->HttpListenPort ) {
|
||||||
|
close ( pWebServer->HttpListenPort );
|
||||||
|
pWebServer->HttpListenPort = -1;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// TODO: Remove the following test code
|
||||||
|
// Exit when the network connection is broken
|
||||||
|
//
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Done with the timer event
|
||||||
|
//
|
||||||
|
WebServerTimerStop ( pWebServer );
|
||||||
|
Status = gBS->CloseEvent ( pWebServer->TimerEvent );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Return the final status
|
||||||
|
//
|
||||||
|
DBG_EXIT_STATUS ( Status );
|
||||||
|
return Status;
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,97 @@
|
||||||
|
#/** @file
|
||||||
|
# Web Server Application
|
||||||
|
#
|
||||||
|
# This file contains an 'Intel Peripheral Driver' and is
|
||||||
|
# licensed for Intel CPUs and chipsets under the terms of your
|
||||||
|
# license agreement with Intel or your vendor. This file may
|
||||||
|
# be modified by the user, subject to additional terms of the
|
||||||
|
# license agreement
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Copyright (c) 20011 Intel Corporation. All rights reserved
|
||||||
|
# This software and associated documentation (if any) is furnished
|
||||||
|
# under a license and may only be used or copied in accordance
|
||||||
|
# with the terms of the license. Except as permitted by such
|
||||||
|
# license, no part of this software or documentation may be
|
||||||
|
# reproduced, stored in a retrieval system, or transmitted in any
|
||||||
|
# form or by any means without the express written consent of
|
||||||
|
# Intel Corporation.
|
||||||
|
#
|
||||||
|
##
|
||||||
|
|
||||||
|
|
||||||
|
[Defines]
|
||||||
|
INF_VERSION = 0x00010005
|
||||||
|
BASE_NAME = WebServer
|
||||||
|
FILE_GUID = 99E87DCF-6162-40c5-9FA1-32111F5197F7
|
||||||
|
MODULE_TYPE = UEFI_APPLICATION
|
||||||
|
VERSION_STRING = 1.0
|
||||||
|
ENTRY_POINT = ShellCEntryLib
|
||||||
|
|
||||||
|
#
|
||||||
|
# The following information is for reference only and not required by the build tools.
|
||||||
|
#
|
||||||
|
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||||
|
#
|
||||||
|
|
||||||
|
[Sources]
|
||||||
|
ACPI.c
|
||||||
|
BootServicesTable.c
|
||||||
|
ConfigurationTable.c
|
||||||
|
DhcpOptions.c
|
||||||
|
DxeServicesTable.c
|
||||||
|
Firmware.c
|
||||||
|
Handles.c
|
||||||
|
Hello.c
|
||||||
|
HTTP.c
|
||||||
|
Index.c
|
||||||
|
PageList.c
|
||||||
|
Reboot.c
|
||||||
|
RuntimeServicesTable.c
|
||||||
|
SystemTable.c
|
||||||
|
WebServer.c
|
||||||
|
|
||||||
|
|
||||||
|
[Pcd]
|
||||||
|
gStdLibTokenSpaceGuid.WebServer_HttpPort
|
||||||
|
|
||||||
|
|
||||||
|
[Packages]
|
||||||
|
MdePkg/MdePkg.dec
|
||||||
|
MdeModulePkg/MdeModulePkg.dec
|
||||||
|
ShellPkg/ShellPkg.dec
|
||||||
|
StdLib/StdLib.dec
|
||||||
|
|
||||||
|
|
||||||
|
[LibraryClasses]
|
||||||
|
BaseMemoryLib
|
||||||
|
BsdSocketLib
|
||||||
|
DebugLib
|
||||||
|
DevShell
|
||||||
|
# EfiSocketLib
|
||||||
|
LibC
|
||||||
|
ShellLib
|
||||||
|
ShellCEntryLib
|
||||||
|
UefiBootServicesTableLib
|
||||||
|
UefiLib
|
||||||
|
UefiRuntimeServicesTableLib
|
||||||
|
UseSocketDxe
|
||||||
|
|
||||||
|
[Guids]
|
||||||
|
gEfiAcpi10TableGuid
|
||||||
|
gEfiAcpiTableGuid
|
||||||
|
gEfiDebugImageInfoTableGuid
|
||||||
|
gEfiDxeServicesTableGuid
|
||||||
|
gEfiHobListGuid
|
||||||
|
gEfiMemoryTypeInformationGuid
|
||||||
|
gLoadFixedAddressConfigurationTableGuid
|
||||||
|
|
||||||
|
[Protocols]
|
||||||
|
gEfiDhcp4ServiceBindingProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||||
|
gEfiDhcp4ProtocolGuid # PROTOCOL ALWAYS_CONSUMED
|
||||||
|
|
||||||
|
[BuildOptions]
|
||||||
|
INTEL:*_*_*_CC_FLAGS = /Qdiag-disable:181,186
|
||||||
|
MSFT:*_*_*_CC_FLAGS = /Od
|
||||||
|
GCC:*_*_*_CC_FLAGS = -O0 -Wno-unused-variable
|
||||||
|
|
Loading…
Reference in New Issue