2009-12-06 02:57:05 +01:00
|
|
|
/** @file
|
|
|
|
EBL commands for Network Devices
|
|
|
|
|
2010-04-29 14:40:51 +02:00
|
|
|
Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
|
2015-10-29 13:59:06 +01:00
|
|
|
(C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>
|
2009-12-06 02:57:05 +01:00
|
|
|
|
2010-04-29 14:40:51 +02:00
|
|
|
This program and the accompanying materials
|
2009-12-06 02:57:05 +01:00
|
|
|
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 "Ebl.h"
|
|
|
|
|
|
|
|
EFI_STATUS
|
|
|
|
ParseIp (
|
|
|
|
IN CHAR8 *String,
|
|
|
|
OUT EFI_IP_ADDRESS *Address
|
|
|
|
)
|
|
|
|
{
|
2010-01-30 21:20:37 +01:00
|
|
|
Address->v4.Addr[0] = (UINT8)AsciiStrDecimalToUintn (String);
|
2009-12-06 02:57:05 +01:00
|
|
|
String = AsciiStrStr(String, ".") + 1;
|
2010-01-30 21:20:37 +01:00
|
|
|
Address->v4.Addr[1] = (UINT8)AsciiStrDecimalToUintn (String);
|
2009-12-06 02:57:05 +01:00
|
|
|
String = AsciiStrStr(String, ".") + 1;
|
2010-01-30 21:20:37 +01:00
|
|
|
Address->v4.Addr[2] = (UINT8)AsciiStrDecimalToUintn (String);
|
2009-12-06 02:57:05 +01:00
|
|
|
String = AsciiStrStr(String, ".") + 1;
|
2010-01-30 21:20:37 +01:00
|
|
|
Address->v4.Addr[3] = (UINT8)AsciiStrDecimalToUintn (String);
|
2014-08-19 15:29:52 +02:00
|
|
|
|
2009-12-06 02:57:05 +01:00
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
EFI_STATUS
|
2015-10-29 13:59:06 +01:00
|
|
|
EFIAPI
|
2009-12-06 02:57:05 +01:00
|
|
|
EblIpCmd (
|
|
|
|
IN UINTN Argc,
|
|
|
|
IN CHAR8 **Argv
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status = EFI_INVALID_PARAMETER;
|
|
|
|
EFI_MAC_ADDRESS Mac;
|
|
|
|
EFI_IP_ADDRESS Ip;
|
2014-08-19 15:29:52 +02:00
|
|
|
|
|
|
|
if (Argc == 1) {
|
2009-12-06 02:57:05 +01:00
|
|
|
// Get current IP/MAC
|
2014-08-19 15:29:52 +02:00
|
|
|
|
2009-12-06 02:57:05 +01:00
|
|
|
// Get current MAC address
|
|
|
|
Status = EblGetCurrentMacAddress (&Mac);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
goto Exit;
|
|
|
|
}
|
2014-08-19 15:29:52 +02:00
|
|
|
|
2009-12-06 02:57:05 +01:00
|
|
|
AsciiPrint ("MAC Address: %02x:%02x:%02x:%02x:%02x:%02x\n", Mac.Addr[0], Mac.Addr[1], Mac.Addr[2], Mac.Addr[3], Mac.Addr[4], Mac.Addr[5]);
|
2014-08-19 15:29:52 +02:00
|
|
|
|
2009-12-06 02:57:05 +01:00
|
|
|
// Get current IP address
|
|
|
|
Status = EblGetCurrentIpAddress (&Ip);
|
|
|
|
if (EFI_ERROR(Status)) {
|
|
|
|
AsciiPrint("IP Address is not configured.\n");
|
|
|
|
Status = EFI_SUCCESS;
|
|
|
|
goto Exit;
|
2014-08-19 15:29:52 +02:00
|
|
|
}
|
2009-12-06 02:57:05 +01:00
|
|
|
|
ARM Packages: Replace tabs by spaces for indentation
Replace tabs by spaces for indentation to comply to EDK2 coding standards.
Done in files with extension ".S", ".c", ".h", ".asm", ".dsc", ".inc", "*.inf",
"*.dec" or ".fdf" and located in ArmPkg, ArmPlatformPkg, EmbeddedPkg,
BeagleBoardPkg or Omap35xxPkg.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ronald Cron <ronald.cron@arm.com>
Reviewed-By: Olivier Martin <olivier.martin@arm.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15901 6f19259b-4bc3-4df7-8a09-765794883524
2014-08-26 12:14:17 +02:00
|
|
|
AsciiPrint("IP Address: %d.%d.%d.%d\n", Ip.v4.Addr[0], Ip.v4.Addr[1],Ip.v4.Addr[2], Ip.v4.Addr[3]);
|
2014-08-19 15:29:52 +02:00
|
|
|
|
2009-12-06 02:57:05 +01:00
|
|
|
} else if ((Argv[1][0] == 'r') && (Argc == 2)) {
|
|
|
|
// Get new address via dhcp
|
|
|
|
Status = EblPerformDHCP (TRUE);
|
|
|
|
} else if ((Argv[1][0] == 's') && (Argc == 3)) {
|
|
|
|
// Set static IP
|
|
|
|
Status = ParseIp (Argv[2], &Ip);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
goto Exit;
|
|
|
|
}
|
2014-08-19 15:29:52 +02:00
|
|
|
|
2009-12-06 02:57:05 +01:00
|
|
|
Status = EblSetStationIp (&Ip, NULL);
|
|
|
|
}
|
2014-08-19 15:29:52 +02:00
|
|
|
|
2009-12-06 02:57:05 +01:00
|
|
|
Exit:
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mCmdNetworkTemplate[] =
|
|
|
|
{
|
|
|
|
{
|
|
|
|
"ip",
|
|
|
|
" ; print current ip address\n\r [r]; request DHCP address\n\r [s] ipaddr; set static IP address",
|
|
|
|
NULL,
|
|
|
|
EblIpCmd
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Initialize the commands in this in this file
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
EblInitializeNetworkCmd (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EblAddCommands (mCmdNetworkTemplate, sizeof (mCmdNetworkTemplate)/sizeof (EBL_COMMAND_TABLE));
|
|
|
|
}
|
|
|
|
|