]> git.proxmox.com Git - mirror_edk2.git/blob - ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.c
ShellPkg: Add NetworkPkg/NetworkPkg.dec as the package dependency
[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 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8 #include "UefiShellNetwork1CommandsLib.h"
9
10 CONST CHAR16 gShellNetwork1FileName[] = L"ShellCommands";
11 EFI_HANDLE gShellNetwork1HiiHandle = NULL;
12
13 /**
14 return the file name of the help text file if not using HII.
15
16 @return The string pointer to the file name.
17 **/
18 CONST CHAR16*
19 EFIAPI
20 ShellCommandGetManFileNameNetwork1 (
21 VOID
22 )
23 {
24 return (gShellNetwork1FileName);
25 }
26
27 /**
28 Constructor for the Shell Network1 Commands library.
29
30 Install the handlers for Network1 UEFI Shell 2.0 profile commands.
31
32 @param ImageHandle The image handle of the process.
33 @param SystemTable The EFI System Table pointer.
34
35 @retval EFI_SUCCESS The shell command handlers were installed sucessfully.
36 @retval EFI_UNSUPPORTED The shell level required was not found.
37 **/
38 EFI_STATUS
39 EFIAPI
40 ShellNetwork1CommandsLibConstructor (
41 IN EFI_HANDLE ImageHandle,
42 IN EFI_SYSTEM_TABLE *SystemTable
43 )
44 {
45 gShellNetwork1HiiHandle = NULL;
46
47 //
48 // check our bit of the profiles mask
49 //
50 if ((PcdGet8(PcdShellProfileMask) & BIT3) == 0) {
51 return (EFI_SUCCESS);
52 }
53
54 gShellNetwork1HiiHandle = HiiAddPackages (&gShellNetwork1HiiGuid, gImageHandle, UefiShellNetwork1CommandsLibStrings, NULL);
55 if (gShellNetwork1HiiHandle == NULL) {
56 return (EFI_DEVICE_ERROR);
57 }
58 //
59 // install our shell command handlers
60 //
61 ShellCommandRegisterCommandName(L"ping", ShellCommandRunPing , ShellCommandGetManFileNameNetwork1, 0, L"network1", TRUE , gShellNetwork1HiiHandle, STRING_TOKEN(STR_GET_HELP_PING));
62 ShellCommandRegisterCommandName(L"ifconfig",ShellCommandRunIfconfig , ShellCommandGetManFileNameNetwork1, 0, L"network1", TRUE , gShellNetwork1HiiHandle, STRING_TOKEN(STR_GET_HELP_IFCONFIG));
63
64 return (EFI_SUCCESS);
65 }
66
67 /**
68 Destructor for the library. free any resources.
69
70 @param ImageHandle The image handle of the process.
71 @param SystemTable The EFI System Table pointer.
72 **/
73 EFI_STATUS
74 EFIAPI
75 ShellNetwork1CommandsLibDestructor (
76 IN EFI_HANDLE ImageHandle,
77 IN EFI_SYSTEM_TABLE *SystemTable
78 )
79 {
80 if (gShellNetwork1HiiHandle != NULL) {
81 HiiRemovePackages(gShellNetwork1HiiHandle);
82 }
83 return (EFI_SUCCESS);
84 }