]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | EBL commands for Network Devices\r | |
3 | \r | |
4 | Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r | |
5 | (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r | |
6 | \r | |
7 | This program and the accompanying materials\r | |
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 | |
19 | EFI_STATUS\r | |
20 | ParseIp (\r | |
21 | IN CHAR8 *String,\r | |
22 | OUT EFI_IP_ADDRESS *Address\r | |
23 | )\r | |
24 | {\r | |
25 | Address->v4.Addr[0] = (UINT8)AsciiStrDecimalToUintn (String);\r | |
26 | String = AsciiStrStr(String, ".") + 1;\r | |
27 | Address->v4.Addr[1] = (UINT8)AsciiStrDecimalToUintn (String);\r | |
28 | String = AsciiStrStr(String, ".") + 1;\r | |
29 | Address->v4.Addr[2] = (UINT8)AsciiStrDecimalToUintn (String);\r | |
30 | String = AsciiStrStr(String, ".") + 1;\r | |
31 | Address->v4.Addr[3] = (UINT8)AsciiStrDecimalToUintn (String);\r | |
32 | \r | |
33 | return EFI_SUCCESS;\r | |
34 | }\r | |
35 | \r | |
36 | EFI_STATUS\r | |
37 | EFIAPI\r | |
38 | EblIpCmd (\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 | |
46 | \r | |
47 | if (Argc == 1) {\r | |
48 | // Get current IP/MAC\r | |
49 | \r | |
50 | // Get current MAC address\r | |
51 | Status = EblGetCurrentMacAddress (&Mac);\r | |
52 | if (EFI_ERROR (Status)) {\r | |
53 | goto Exit;\r | |
54 | }\r | |
55 | \r | |
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 | |
57 | \r | |
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 | |
64 | }\r | |
65 | \r | |
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 | |
67 | \r | |
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 | |
77 | \r | |
78 | Status = EblSetStationIp (&Ip, NULL);\r | |
79 | }\r | |
80 | \r | |
81 | Exit:\r | |
82 | return Status;\r | |
83 | }\r | |
84 | \r | |
85 | GLOBAL_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 | |
99 | VOID\r | |
100 | EblInitializeNetworkCmd (\r | |
101 | VOID\r | |
102 | )\r | |
103 | {\r | |
104 | EblAddCommands (mCmdNetworkTemplate, sizeof (mCmdNetworkTemplate)/sizeof (EBL_COMMAND_TABLE));\r | |
105 | }\r | |
106 | \r |