]> git.proxmox.com Git - mirror_edk2.git/blame - EmbeddedPkg/Ebl/Network.c
ArmPlatformPkg: remove EblCmdLib implementation
[mirror_edk2.git] / EmbeddedPkg / Ebl / Network.c
CommitLineData
2ef2b01e
A
1/** @file\r
2 EBL commands for Network Devices\r
3\r
60274cca 4 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
50c6a4d2 5 (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
2ef2b01e 6\r
60274cca 7 This program and the accompanying materials\r
2ef2b01e
A
8 are licensed and made available under the terms and conditions of the BSD License\r
9 which accompanies this distribution. The full text of the license may be found at\r
10 http://opensource.org/licenses/bsd-license.php\r
11\r
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
14\r
15**/\r
16\r
17#include "Ebl.h"\r
18\r
19EFI_STATUS\r
20ParseIp (\r
21 IN CHAR8 *String,\r
22 OUT EFI_IP_ADDRESS *Address\r
23 )\r
24{\r
e70c3793 25 Address->v4.Addr[0] = (UINT8)AsciiStrDecimalToUintn (String);\r
2ef2b01e 26 String = AsciiStrStr(String, ".") + 1;\r
e70c3793 27 Address->v4.Addr[1] = (UINT8)AsciiStrDecimalToUintn (String);\r
2ef2b01e 28 String = AsciiStrStr(String, ".") + 1;\r
e70c3793 29 Address->v4.Addr[2] = (UINT8)AsciiStrDecimalToUintn (String);\r
2ef2b01e 30 String = AsciiStrStr(String, ".") + 1;\r
e70c3793 31 Address->v4.Addr[3] = (UINT8)AsciiStrDecimalToUintn (String);\r
3402aac7 32\r
2ef2b01e
A
33 return EFI_SUCCESS;\r
34}\r
35\r
36EFI_STATUS\r
50c6a4d2 37EFIAPI\r
2ef2b01e
A
38EblIpCmd (\r
39 IN UINTN Argc,\r
40 IN CHAR8 **Argv\r
41 )\r
42{\r
43 EFI_STATUS Status = EFI_INVALID_PARAMETER;\r
44 EFI_MAC_ADDRESS Mac;\r
45 EFI_IP_ADDRESS Ip;\r
3402aac7
RC
46\r
47 if (Argc == 1) {\r
2ef2b01e 48 // Get current IP/MAC\r
3402aac7 49\r
2ef2b01e
A
50 // Get current MAC address\r
51 Status = EblGetCurrentMacAddress (&Mac);\r
52 if (EFI_ERROR (Status)) {\r
53 goto Exit;\r
54 }\r
3402aac7 55\r
2ef2b01e 56 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]);\r
3402aac7 57\r
2ef2b01e
A
58 // Get current IP address\r
59 Status = EblGetCurrentIpAddress (&Ip);\r
60 if (EFI_ERROR(Status)) {\r
61 AsciiPrint("IP Address is not configured.\n");\r
62 Status = EFI_SUCCESS;\r
63 goto Exit;\r
3402aac7 64 }\r
2ef2b01e 65\r
91c38d4e 66 AsciiPrint("IP Address: %d.%d.%d.%d\n", Ip.v4.Addr[0], Ip.v4.Addr[1],Ip.v4.Addr[2], Ip.v4.Addr[3]);\r
3402aac7 67\r
2ef2b01e
A
68 } else if ((Argv[1][0] == 'r') && (Argc == 2)) {\r
69 // Get new address via dhcp\r
70 Status = EblPerformDHCP (TRUE);\r
71 } else if ((Argv[1][0] == 's') && (Argc == 3)) {\r
72 // Set static IP\r
73 Status = ParseIp (Argv[2], &Ip);\r
74 if (EFI_ERROR (Status)) {\r
75 goto Exit;\r
76 }\r
3402aac7 77\r
2ef2b01e
A
78 Status = EblSetStationIp (&Ip, NULL);\r
79 }\r
3402aac7 80\r
2ef2b01e
A
81Exit:\r
82 return Status;\r
83}\r
84\r
85GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mCmdNetworkTemplate[] =\r
86{\r
87 {\r
88 "ip",\r
89 " ; print current ip address\n\r [r]; request DHCP address\n\r [s] ipaddr; set static IP address",\r
90 NULL,\r
91 EblIpCmd\r
92 }\r
93};\r
94\r
95\r
96/**\r
97 Initialize the commands in this in this file\r
98**/\r
99VOID\r
100EblInitializeNetworkCmd (\r
101 VOID\r
102 )\r
103{\r
104 EblAddCommands (mCmdNetworkTemplate, sizeof (mCmdNetworkTemplate)/sizeof (EBL_COMMAND_TABLE));\r
105}\r
106\r