/** @file
Shell application for VLAN configuration.
Copyright (C) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include <Uefi.h>
#include <Protocol/VlanConfig.h>
#include <Library/UefiApplicationEntryPoint.h>
#include <Library/ShellLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
//
// This is the generated String package data for all .UNI files.
// This data array is ready to be used as input of HiiAddPackages() to
// create a packagelist (which contains Form packages, String packages, etc).
//
extern UINT8 VConfigStrings[];
{
L"-l",
},
{
L"-a",
},
{
L"-d",
},
{
NULL,
}
};
/**
Locate the network interface handle buffer.
@param[out] NumberOfHandles Pointer to the number of handles.
@param[out] HandleBuffer Pointer to the buffer to store the returned handles.
**/
)
{
*NumberOfHandles = 0;
*HandleBuffer = NULL;
NULL,
);
}
}
/**
Extract the decimal index from the network interface name.
@param[in] Name Name of the network interface.
@retval INVALID_NIC_INDEX Failed to extract the network interface index.
@return others The network interface index.
**/
)
{
return INVALID_NIC_INDEX;
}
while (*Str != 0) {
return INVALID_NIC_INDEX;
}
Str++;
}
}
/**
Find network interface device handle by its name.
@param[in] Name Name of the network interface.
@retval NULL Cannot find the network interface.
@return others Handle of the network interface.
**/
)
{
//
// Find all NIC handles.
//
if (NumberOfHandles == 0) {
return NULL;
}
if (Index >= NumberOfHandles) {
} else {
}
return Handle;
}
/**
Open VlanConfig protocol from a handle.
@param[in] Handle The handle to open the VlanConfig protocol.
@return The VlanConfig protocol interface.
**/
)
{
VlanConfig = NULL;
gBS->OpenProtocol (
(VOID **) &VlanConfig,
);
return VlanConfig;
}
/**
Close VlanConfig protocol of a handle.
@param[in] Handle The handle to close the VlanConfig protocol.
**/
)
{
gBS->CloseProtocol (
);
}
/**
Display VLAN configuration of a network interface.
@param[in] Handle Handle of the network interface.
@param[in] NicIndex Index of the network interface.
**/
)
{
if (VlanConfig == NULL) {
return ;
}
goto Exit;
}
if (Status == EFI_NOT_FOUND) {
} else {
}
goto Exit;
}
-1,
-1,
NULL,
);
}
Exit:
}
}
/**
Display the VLAN configuration of all, or a specified network interface.
@param[in] Name Name of the network interface. If NULL, the VLAN
configuration of all network will be displayed.
**/
)
{
//
// Display specified NIC
//
return ;
}
ShowNicVlanInfo (NicHandle, 0);
return ;
}
//
// Find all NIC handles
//
if (NumberOfHandles == 0) {
return ;
}
}
}
/**
Convert a NULL-terminated unicode decimal VLAN ID string to VLAN ID.
@param[in] String Pointer to VLAN ID string from user input.
@retval Value translated from String, or INVALID_VLAN_ID is string is invalid.
**/
)
{
return INVALID_VLAN_ID;
}
Str++;
}
if (*Str != 0) {
return INVALID_VLAN_ID;
}
}
/**
Add a VLAN device.
@param[in] ParamStr Parameter string from user input.
**/
AddVlan (
)
{
VlanConfig = NULL;
Priority = 0;
return ;
}
return ;
}
PriorityStr = NULL;
while (*StrPtr != 0) {
if (*StrPtr == L' ') {
*StrPtr = 0;
} else {
if (IsSpace) {
//
// Start of a parameter.
//
//
// 2nd parameter is VLAN ID.
//
} else if (PriorityStr == NULL) {
//
// 3rd parameter is Priority.
//
} else {
//
// Ignore else parameters.
//
break;
}
}
}
StrPtr++;
}
goto Exit;
}
if (VlanConfig == NULL) {
goto Exit;
}
//
// Check VLAN ID.
//
goto Exit;
}
if (VlanId > 4094) {
goto Exit;
}
//
// Check Priority.
//
if (Priority > 7) {
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_VCONFIG_INVALID_PRIORITY), mHiiHandle, PriorityStr);
goto Exit;
}
}
//
// Set VLAN
//
goto Exit;
}
//
// Connect the VLAN device.
//
if (VlanHandle != NULL) {
}
Exit:
if (VlanConfig != NULL) {
}
}
/**
Remove a VLAN device.
@param[in] ParamStr Parameter string from user input.
**/
)
{
VlanConfig = NULL;
return ;
}
return ;
}
while (*StrPtr != 0) {
if (*StrPtr == L'.') {
*StrPtr = 0;
break;
}
StrPtr++;
}
goto Exit;
}
if (VlanConfig == NULL) {
goto Exit;
}
//
// Check VLAN ID
//
goto Exit;
}
if (VlanId > 4094) {
goto Exit;
}
//
// Delete VLAN.
//
if (Status == EFI_NOT_FOUND) {
} else {
}
goto Exit;
}
//
// Check whether this is the last VLAN to remove.
//
//
// This is the last VLAN to remove, try to connect the controller handle.
//
} else {
}
Exit:
if (VlanConfig != NULL) {
}
}
/**
The actual entry point for the application.
@param[in] ImageHandle The firmware allocated handle for the EFI image.
@param[in] SystemTable A pointer to the EFI System Table.
@retval EFI_SUCCESS The entry point executed successfully.
@retval other Some error occur when executing this entry point.
**/
)
{
//
// Register our string package to HII database.
//
if (mHiiHandle == NULL) {
return EFI_SUCCESS;
}
goto Exit;
}
goto Exit;
}
goto Exit;
}
goto Exit;
}
goto Exit;
}
//
// No valid argument till now.
//
Exit:
}
//
// Remove our string package from HII database.
//
return EFI_SUCCESS;
}