]>
Commit | Line | Data |
---|---|---|
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 | |
18 | EFI_STATUS\r | |
19 | ParseIp (\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 |
2ef2b01e A |
31 | \r |
32 | return EFI_SUCCESS;\r | |
33 | }\r | |
34 | \r | |
35 | EFI_STATUS\r | |
36 | EblIpCmd (\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 | |
44 | \r | |
45 | if (Argc == 1) { \r | |
46 | // Get current IP/MAC\r | |
47 | \r | |
48 | // Get current MAC address\r | |
49 | Status = EblGetCurrentMacAddress (&Mac);\r | |
50 | if (EFI_ERROR (Status)) {\r | |
51 | goto Exit;\r | |
52 | }\r | |
53 | \r | |
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 | |
55 | \r | |
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 | |
62 | } \r | |
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 | |
65 | \r | |
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 | |
75 | \r | |
76 | Status = EblSetStationIp (&Ip, NULL);\r | |
77 | }\r | |
78 | \r | |
79 | Exit:\r | |
80 | return Status;\r | |
81 | }\r | |
82 | \r | |
83 | GLOBAL_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 | |
97 | VOID\r | |
98 | EblInitializeNetworkCmd (\r | |
99 | VOID\r | |
100 | )\r | |
101 | {\r | |
102 | EblAddCommands (mCmdNetworkTemplate, sizeof (mCmdNetworkTemplate)/sizeof (EBL_COMMAND_TABLE));\r | |
103 | }\r | |
104 | \r |