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