]> git.proxmox.com Git - mirror_edk2.git/blob - ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2CommandsLib.c
ShellPkg: Apply uncrustify changes
[mirror_edk2.git] / ShellPkg / Library / UefiShellNetwork2CommandsLib / UefiShellNetwork2CommandsLib.c
1 /** @file
2 Main file for NULL named library for network2 shell command functions.
3
4 Copyright (c) 2016, Intel Corporation. All rights reserved. <BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8 #include "UefiShellNetwork2CommandsLib.h"
9
10 CONST CHAR16 gShellNetwork2FileName[] = L"ShellCommands";
11 EFI_HII_HANDLE gShellNetwork2HiiHandle = 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 ShellCommandGetManFileNameNetwork2 (
21 VOID
22 )
23 {
24 return (gShellNetwork2FileName);
25 }
26
27 /**
28 Constructor for the Shell Network2 Commands library.
29
30 Install the handlers for Network2 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 ShellNetwork2CommandsLibConstructor (
41 IN EFI_HANDLE ImageHandle,
42 IN EFI_SYSTEM_TABLE *SystemTable
43 )
44 {
45 gShellNetwork2HiiHandle = NULL;
46
47 //
48 // check our bit of the profiles mask
49 //
50 if ((PcdGet8 (PcdShellProfileMask) & BIT4) == 0) {
51 return (EFI_SUCCESS);
52 }
53
54 gShellNetwork2HiiHandle = HiiAddPackages (&gShellNetwork2HiiGuid, gImageHandle, UefiShellNetwork2CommandsLibStrings, NULL);
55 if (gShellNetwork2HiiHandle == NULL) {
56 return (EFI_DEVICE_ERROR);
57 }
58
59 //
60 // install our shell command handlers
61 //
62 ShellCommandRegisterCommandName (L"ping6", ShellCommandRunPing6, ShellCommandGetManFileNameNetwork2, 0, L"network2", TRUE, gShellNetwork2HiiHandle, STRING_TOKEN (STR_GET_HELP_PING6));
63 ShellCommandRegisterCommandName (L"ifconfig6", ShellCommandRunIfconfig6, ShellCommandGetManFileNameNetwork2, 0, L"network2", TRUE, gShellNetwork2HiiHandle, STRING_TOKEN (STR_GET_HELP_IFCONFIG6));
64
65 return EFI_SUCCESS;
66 }
67
68 /**
69 Destructor for the library. free any resources.
70
71 @param ImageHandle The image handle of the process.
72 @param SystemTable The EFI System Table pointer.
73 **/
74 EFI_STATUS
75 EFIAPI
76 ShellNetwork2CommandsLibDestructor (
77 IN EFI_HANDLE ImageHandle,
78 IN EFI_SYSTEM_TABLE *SystemTable
79 )
80 {
81 if (gShellNetwork2HiiHandle != NULL) {
82 HiiRemovePackages (gShellNetwork2HiiHandle);
83 }
84
85 return EFI_SUCCESS;
86 }