]> git.proxmox.com Git - mirror_edk2.git/blob - ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.c
add support to easily remove profiles and shell levels. the libraries will not do...
[mirror_edk2.git] / ShellPkg / Library / UefiShellNetwork1CommandsLib / UefiShellNetwork1CommandsLib.c
1 /** @file
2 Main file for NULL named library for network1 shell command functions.
3
4 Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved. <BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14 #include "UefiShellNetwork1CommandsLib.h"
15
16 CONST CHAR16 gShellNetwork1FileName[] = L"ShellCommands";
17 EFI_HANDLE gShellNetwork1HiiHandle = NULL;
18 STATIC CONST EFI_GUID gShellNetwork1HiiGuid = \
19 { \
20 0xf3d301bb, 0xf4a5, 0x45a8, { 0xb0, 0xb7, 0xfa, 0x99, 0x9c, 0x62, 0x37, 0xae } \
21 };
22
23 /**
24 return the file name of the help text file if not using HII.
25
26 @return The string pointer to the file name.
27 **/
28 CONST CHAR16*
29 EFIAPI
30 ShellCommandGetManFileNameNetwork1 (
31 VOID
32 )
33 {
34 return (gShellNetwork1FileName);
35 }
36
37 /**
38 Constructor for the Shell Network1 Commands library.
39
40 Install the handlers for Network1 UEFI Shell 2.0 profile commands.
41
42 @param ImageHandle The image handle of the process.
43 @param SystemTable The EFI System Table pointer.
44
45 @retval EFI_SUCCESS The shell command handlers were installed sucessfully.
46 @retval EFI_UNSUPPORTED The shell level required was not found.
47 **/
48 EFI_STATUS
49 EFIAPI
50 ShellNetwork1CommandsLibConstructor (
51 IN EFI_HANDLE ImageHandle,
52 IN EFI_SYSTEM_TABLE *SystemTable
53 )
54 {
55 gShellNetwork1HiiHandle = NULL;
56
57 //
58 // check our bit of the profiles mask
59 //
60 if ((PcdGet8(PcdShellProfileMask) & BIT3) == 0) {
61 return (EFI_SUCCESS);
62 }
63
64 gShellNetwork1HiiHandle = HiiAddPackages (&gShellNetwork1HiiGuid, gImageHandle, UefiShellNetwork1CommandsLibStrings, NULL);
65 if (gShellNetwork1HiiHandle == NULL) {
66 return (EFI_DEVICE_ERROR);
67 }
68 //
69 // install our shell command handlers
70 //
71 ShellCommandRegisterCommandName(L"ping", ShellCommandRunPing , ShellCommandGetManFileNameNetwork1, 0, L"network1", TRUE , gShellNetwork1HiiHandle, STRING_TOKEN(STR_GET_HELP_PING));
72 ShellCommandRegisterCommandName(L"ifconfig",ShellCommandRunIfconfig , ShellCommandGetManFileNameNetwork1, 0, L"network1", TRUE , gShellNetwork1HiiHandle, STRING_TOKEN(STR_GET_HELP_IFCONFIG));
73
74 return (EFI_SUCCESS);
75 }
76
77 /**
78 Destructor for the library. free any resources.
79
80 @param ImageHandle The image handle of the process.
81 @param SystemTable The EFI System Table pointer.
82 **/
83 EFI_STATUS
84 EFIAPI
85 ShellNetwork1CommandsLibDestructor (
86 IN EFI_HANDLE ImageHandle,
87 IN EFI_SYSTEM_TABLE *SystemTable
88 )
89 {
90 if (gShellNetwork1HiiHandle != NULL) {
91 HiiRemovePackages(gShellNetwork1HiiHandle);
92 }
93 return (EFI_SUCCESS);
94 }