Home | History | Annotate | Download | only in UefiShellNetwork2CommandsLib
      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   This program and the accompanying materials are licensed and made available under
      6   the terms and conditions of the BSD License which accompanies this distribution.
      7   The full text of the license may be found at http://opensource.org/licenses/bsd-license.php
      8 
      9   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     10   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     11 
     12 **/
     13 #include "UefiShellNetwork2CommandsLib.h"
     14 
     15 CONST CHAR16 gShellNetwork2FileName[] = L"ShellCommands";
     16 EFI_HANDLE gShellNetwork2HiiHandle = NULL;
     17 
     18 /**
     19   return the file name of the help text file if not using HII.
     20 
     21   @return The string pointer to the file name.
     22 **/
     23 CONST CHAR16*
     24 EFIAPI
     25 ShellCommandGetManFileNameNetwork2 (
     26   VOID
     27   )
     28 {
     29   return (gShellNetwork2FileName);
     30 }
     31 
     32 /**
     33   Constructor for the Shell Network2 Commands library.
     34 
     35   Install the handlers for Network2 UEFI Shell 2.0 profile commands.
     36 
     37   @param ImageHandle            The image handle of the process.
     38   @param SystemTable            The EFI System Table pointer.
     39 
     40   @retval EFI_SUCCESS           The shell command handlers were installed sucessfully.
     41   @retval EFI_UNSUPPORTED       The shell level required was not found.
     42 **/
     43 EFI_STATUS
     44 EFIAPI
     45 ShellNetwork2CommandsLibConstructor (
     46   IN EFI_HANDLE        ImageHandle,
     47   IN EFI_SYSTEM_TABLE  *SystemTable
     48   )
     49 {
     50   gShellNetwork2HiiHandle = NULL;
     51 
     52   //
     53   // check our bit of the profiles mask
     54   //
     55   if ((PcdGet8(PcdShellProfileMask) & BIT4) == 0) {
     56     return (EFI_SUCCESS);
     57   }
     58 
     59   gShellNetwork2HiiHandle = HiiAddPackages (&gShellNetwork2HiiGuid, gImageHandle, UefiShellNetwork2CommandsLibStrings, NULL);
     60   if (gShellNetwork2HiiHandle == NULL) {
     61     return (EFI_DEVICE_ERROR);
     62   }
     63   //
     64   // install our shell command handlers
     65   //
     66   ShellCommandRegisterCommandName(L"ping6",    ShellCommandRunPing6     , ShellCommandGetManFileNameNetwork2, 0, L"network2", TRUE , gShellNetwork2HiiHandle, STRING_TOKEN(STR_GET_HELP_PING6));
     67   ShellCommandRegisterCommandName(L"ifconfig6",ShellCommandRunIfconfig6 , ShellCommandGetManFileNameNetwork2, 0, L"network2", TRUE , gShellNetwork2HiiHandle, STRING_TOKEN(STR_GET_HELP_IFCONFIG6));
     68 
     69   return EFI_SUCCESS;
     70 
     71 }
     72 
     73 /**
     74   Destructor for the library.  free any resources.
     75 
     76   @param ImageHandle            The image handle of the process.
     77   @param SystemTable            The EFI System Table pointer.
     78 **/
     79 EFI_STATUS
     80 EFIAPI
     81 ShellNetwork2CommandsLibDestructor (
     82   IN EFI_HANDLE        ImageHandle,
     83   IN EFI_SYSTEM_TABLE  *SystemTable
     84   )
     85 {
     86   if (gShellNetwork2HiiHandle != NULL) {
     87     HiiRemovePackages(gShellNetwork2HiiHandle);
     88   }
     89   return EFI_SUCCESS;
     90 }
     91 
     92