Add NetworkPkg (P.UDK2010.UP3.Network.P1)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10986 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
312
NetworkPkg/Dhcp6Dxe/ComponentName.c
Normal file
312
NetworkPkg/Dhcp6Dxe/ComponentName.c
Normal file
@@ -0,0 +1,312 @@
|
||||
/** @file
|
||||
UEFI Component Name(2) protocol implementation for Dhcp6 driver.
|
||||
|
||||
Copyright (c) 2009 - 2010, 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
|
||||
http://opensource.org/licenses/bsd-license.php.
|
||||
|
||||
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 "Dhcp6Impl.h"
|
||||
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user-readable name of the driver.
|
||||
|
||||
This function retrieves the user-readable name of a driver in the form of a
|
||||
Unicode string. If the driver specified by This has a user-readable name in
|
||||
the language specified by Language, then a pointer to the driver name is
|
||||
returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
|
||||
by This does not support the language specified by Language,
|
||||
then EFI_UNSUPPORTED is returned.
|
||||
|
||||
@param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
|
||||
EFI_COMPONENT_NAME_PROTOCOL instance.
|
||||
|
||||
@param[in] Language A pointer to a Null-terminated ASCII string
|
||||
array indicating the language. This is the
|
||||
language of the driver name that the caller is
|
||||
requesting, and it must match one of the
|
||||
languages specified in SupportedLanguages. The
|
||||
number of languages supported by a driver is up
|
||||
to the driver writer. Language is specified
|
||||
in RFC 4646 or ISO 639-2 language code format.
|
||||
|
||||
@param[out] DriverName A pointer to the Unicode string to return.
|
||||
This Unicode string is the name of the
|
||||
driver specified by This in the language
|
||||
specified by Language.
|
||||
|
||||
@retval EFI_SUCCESS The Unicode string for the Driver specified by
|
||||
This and the language specified by Language was
|
||||
returned in DriverName.
|
||||
|
||||
@retval EFI_INVALID_PARAMETER Language is NULL.
|
||||
|
||||
@retval EFI_INVALID_PARAMETER DriverName is NULL.
|
||||
|
||||
@retval EFI_UNSUPPORTED The driver specified by This does not support
|
||||
the language specified by Language.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
Dhcp6ComponentNameGetDriverName (
|
||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
||||
IN CHAR8 *Language,
|
||||
OUT CHAR16 **DriverName
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user-readable name of the controller
|
||||
that is being managed by a driver.
|
||||
|
||||
This function retrieves the user-readable name of the controller specified by
|
||||
ControllerHandle and ChildHandle in the form of a Unicode string. If the
|
||||
driver specified by This has a user-readable name in the language specified by
|
||||
Language, then a pointer to the controller name is returned in ControllerName,
|
||||
and EFI_SUCCESS is returned. If the driver specified by This is not currently
|
||||
managing the controller specified by ControllerHandle and ChildHandle,
|
||||
then EFI_UNSUPPORTED is returned. If the driver specified by This does not
|
||||
support the language specified by Language, then EFI_UNSUPPORTED is returned.
|
||||
|
||||
@param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
|
||||
EFI_COMPONENT_NAME_PROTOCOL instance.
|
||||
|
||||
@param[in] ControllerHandle The handle of a controller that the driver
|
||||
specified by This is managing. This handle
|
||||
specifies the controller whose name is to be
|
||||
returned.
|
||||
|
||||
@param[in] ChildHandle The handle of the child controller to retrieve
|
||||
the name of. This is an optional parameter that
|
||||
may be NULL. It will be NULL for device
|
||||
drivers. It will also be NULL for a bus drivers
|
||||
that attempt to retrieve the name of the bus
|
||||
controller. It will not be NULL for a bus
|
||||
driver that attempts to retrieve the name of a
|
||||
child controller.
|
||||
|
||||
@param[in] Language A pointer to a Null-terminated ASCII string
|
||||
array indicating the language. This is the
|
||||
language of the driver name that the caller is
|
||||
requesting, and it must match one of the
|
||||
languages specified in SupportedLanguages. The
|
||||
number of languages supported by a driver is up
|
||||
to the driver writer. Language is specified in
|
||||
RFC 4646 or ISO 639-2 language code format.
|
||||
|
||||
@param[out] ControllerName A pointer to the Unicode string to return.
|
||||
This Unicode string is the name of the
|
||||
controller specified by ControllerHandle and
|
||||
ChildHandle in the language specified by
|
||||
Language, from the point of view of the driver
|
||||
specified by This.
|
||||
|
||||
@retval EFI_SUCCESS The Unicode string for the user-readable name in
|
||||
the language specified by Language for the
|
||||
driver specified by This was returned in
|
||||
DriverName.
|
||||
|
||||
@retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
|
||||
|
||||
@retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it is not a valid
|
||||
EFI_HANDLE.
|
||||
|
||||
@retval EFI_INVALID_PARAMETER Language is NULL.
|
||||
|
||||
@retval EFI_INVALID_PARAMETER ControllerName is NULL.
|
||||
|
||||
@retval EFI_UNSUPPORTED The driver specified by This is not currently
|
||||
managing the controller specified by
|
||||
ControllerHandle and ChildHandle.
|
||||
|
||||
@retval EFI_UNSUPPORTED The driver specified by This does not support
|
||||
the language specified by Language.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
Dhcp6ComponentNameGetControllerName (
|
||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN EFI_HANDLE ChildHandle OPTIONAL,
|
||||
IN CHAR8 *Language,
|
||||
OUT CHAR16 **ControllerName
|
||||
);
|
||||
|
||||
|
||||
//
|
||||
// EFI Component Name Protocol
|
||||
//
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gDhcp6ComponentName = {
|
||||
Dhcp6ComponentNameGetDriverName,
|
||||
Dhcp6ComponentNameGetControllerName,
|
||||
"eng"
|
||||
};
|
||||
|
||||
//
|
||||
// EFI Component Name 2 Protocol
|
||||
//
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gDhcp6ComponentName2 = {
|
||||
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) Dhcp6ComponentNameGetDriverName,
|
||||
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) Dhcp6ComponentNameGetControllerName,
|
||||
"en"
|
||||
};
|
||||
|
||||
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mDhcp6DriverNameTable[] = {
|
||||
{
|
||||
"eng;en",
|
||||
L"DHCP6 Protocol Driver"
|
||||
},
|
||||
{
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user-readable name of the driver.
|
||||
|
||||
This function retrieves the user-readable name of a driver in the form of a
|
||||
Unicode string. If the driver specified by This has a user-readable name in
|
||||
the language specified by Language, then a pointer to the driver name is
|
||||
returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
|
||||
by This does not support the language specified by Language,
|
||||
then EFI_UNSUPPORTED is returned.
|
||||
|
||||
@param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
|
||||
EFI_COMPONENT_NAME_PROTOCOL instance.
|
||||
|
||||
@param[in] Language A pointer to a Null-terminated ASCII string
|
||||
array indicating the language. This is the
|
||||
language of the driver name that the caller is
|
||||
requesting, and it must match one of the
|
||||
languages specified in SupportedLanguages. The
|
||||
number of languages supported by a driver is up
|
||||
to the driver writer. Language is specified
|
||||
in RFC 4646 or ISO 639-2 language code format.
|
||||
|
||||
@param[out] DriverName A pointer to the Unicode string to return.
|
||||
This Unicode string is the name of the
|
||||
driver specified by This in the language
|
||||
specified by Language.
|
||||
|
||||
@retval EFI_SUCCESS The Unicode string for the Driver specified by
|
||||
This and the language specified by Language was
|
||||
returned in DriverName.
|
||||
|
||||
@retval EFI_INVALID_PARAMETER Language is NULL.
|
||||
|
||||
@retval EFI_INVALID_PARAMETER DriverName is NULL.
|
||||
|
||||
@retval EFI_UNSUPPORTED The driver specified by This does not support
|
||||
the language specified by Language.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
Dhcp6ComponentNameGetDriverName (
|
||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
||||
IN CHAR8 *Language,
|
||||
OUT CHAR16 **DriverName
|
||||
)
|
||||
{
|
||||
return LookupUnicodeString2 (
|
||||
Language,
|
||||
This->SupportedLanguages,
|
||||
mDhcp6DriverNameTable,
|
||||
DriverName,
|
||||
(BOOLEAN)(This == &gDhcp6ComponentName)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Retrieves a Unicode string that is the user-readable name of the controller
|
||||
that is being managed by a driver.
|
||||
|
||||
This function retrieves the user-readable name of the controller specified by
|
||||
ControllerHandle and ChildHandle in the form of a Unicode string. If the
|
||||
driver specified by This has a user-readable name in the language specified by
|
||||
Language, then a pointer to the controller name is returned in ControllerName,
|
||||
and EFI_SUCCESS is returned. If the driver specified by This is not currently
|
||||
managing the controller specified by ControllerHandle and ChildHandle,
|
||||
then EFI_UNSUPPORTED is returned. If the driver specified by This does not
|
||||
support the language specified by Language, then EFI_UNSUPPORTED is returned.
|
||||
|
||||
@param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
|
||||
EFI_COMPONENT_NAME_PROTOCOL instance.
|
||||
|
||||
@param[in] ControllerHandle The handle of a controller that the driver
|
||||
specified by This is managing. This handle
|
||||
specifies the controller whose name is to be
|
||||
returned.
|
||||
|
||||
@param[in] ChildHandle The handle of the child controller to retrieve
|
||||
the name of. This is an optional parameter that
|
||||
may be NULL. It will be NULL for device
|
||||
drivers. It will also be NULL for a bus drivers
|
||||
that wish to retrieve the name of the bus
|
||||
controller. It will not be NULL for a bus
|
||||
driver that wishes to retrieve the name of a
|
||||
child controller.
|
||||
|
||||
@param[in] Language A pointer to a Null-terminated ASCII string
|
||||
array indicating the language. This is the
|
||||
language of the driver name that the caller is
|
||||
requesting, and it must match one of the
|
||||
languages specified in SupportedLanguages. The
|
||||
number of languages supported by a driver is up
|
||||
to the driver writer. Language is specified in the
|
||||
RFC 4646 or ISO 639-2 language code format.
|
||||
|
||||
@param[out] ControllerName A pointer to the Unicode string to return.
|
||||
This Unicode string is the name of the
|
||||
controller specified by ControllerHandle and
|
||||
ChildHandle in the language specified by
|
||||
Language, from the point of view of the driver
|
||||
specified by This.
|
||||
|
||||
@retval EFI_SUCCESS The Unicode string for the user-readable name in
|
||||
the language specified by Language for the
|
||||
driver specified by This was returned in
|
||||
DriverName.
|
||||
|
||||
@retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
|
||||
|
||||
@retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it is not a valid
|
||||
EFI_HANDLE.
|
||||
|
||||
@retval EFI_INVALID_PARAMETER Language is NULL.
|
||||
|
||||
@retval EFI_INVALID_PARAMETER ControllerName is NULL.
|
||||
|
||||
@retval EFI_UNSUPPORTED The driver specified by This is not currently
|
||||
managing the controller specified by
|
||||
ControllerHandle and ChildHandle.
|
||||
|
||||
@retval EFI_UNSUPPORTED The driver specified by This does not support
|
||||
the language specified by Language.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
Dhcp6ComponentNameGetControllerName (
|
||||
IN EFI_COMPONENT_NAME_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN EFI_HANDLE ChildHandle OPTIONAL,
|
||||
IN CHAR8 *Language,
|
||||
OUT CHAR16 **ControllerName
|
||||
)
|
||||
{
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
782
NetworkPkg/Dhcp6Dxe/Dhcp6Driver.c
Normal file
782
NetworkPkg/Dhcp6Dxe/Dhcp6Driver.c
Normal file
@@ -0,0 +1,782 @@
|
||||
/** @file
|
||||
Driver Binding functions and Service Binding functions
|
||||
implementationfor for Dhcp6 Driver.
|
||||
|
||||
Copyright (c) 2009 - 2010, 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
|
||||
http://opensource.org/licenses/bsd-license.php.
|
||||
|
||||
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 "Dhcp6Impl.h"
|
||||
|
||||
|
||||
EFI_DRIVER_BINDING_PROTOCOL gDhcp6DriverBinding = {
|
||||
Dhcp6DriverBindingSupported,
|
||||
Dhcp6DriverBindingStart,
|
||||
Dhcp6DriverBindingStop,
|
||||
0xa,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
EFI_SERVICE_BINDING_PROTOCOL gDhcp6ServiceBindingTemplate = {
|
||||
Dhcp6ServiceBindingCreateChild,
|
||||
Dhcp6ServiceBindingDestroyChild
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
Configure the default Udp6Io to receive all the DHCP6 traffic
|
||||
on this network interface.
|
||||
|
||||
@param[in] UdpIo The pointer to Udp6Io to be configured.
|
||||
@param[in] Context The pointer to the context.
|
||||
|
||||
@retval EFI_SUCCESS The Udp6Io is successfully configured.
|
||||
@retval Others Failed to configure the Udp6Io.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
Dhcp6ConfigureUdpIo (
|
||||
IN UDP_IO *UdpIo,
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
EFI_UDP6_PROTOCOL *Udp6;
|
||||
EFI_UDP6_CONFIG_DATA *Config;
|
||||
|
||||
Udp6 = UdpIo->Protocol.Udp6;
|
||||
Config = &(UdpIo->Config.Udp6);
|
||||
|
||||
ZeroMem (Config, sizeof (EFI_UDP6_CONFIG_DATA));
|
||||
|
||||
//
|
||||
// Set Udp6 configure data for the Dhcp6 instance.
|
||||
//
|
||||
Config->AcceptPromiscuous = FALSE;
|
||||
Config->AcceptAnyPort = FALSE;
|
||||
Config->AllowDuplicatePort = FALSE;
|
||||
Config->TrafficClass = 0;
|
||||
Config->HopLimit = 128;
|
||||
Config->ReceiveTimeout = 0;
|
||||
Config->TransmitTimeout = 0;
|
||||
|
||||
//
|
||||
// Configure an endpoint of client(0, 546), server(0, 0), the addresses
|
||||
// will be overridden later. Note that we MUST not limit RemotePort.
|
||||
// More details, refer to RFC 3315 section 5.2.
|
||||
//
|
||||
Config->StationPort = DHCP6_PORT_CLIENT;
|
||||
Config->RemotePort = 0;
|
||||
|
||||
return Udp6->Configure (Udp6, Config);;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Destory the Dhcp6 service. The Dhcp6 service may be partly initialized,
|
||||
or partly destroyed. If a resource is destroyed, it is marked as such in
|
||||
case the destroy failed and being called again later.
|
||||
|
||||
@param[in, out] Service The pointer to Dhcp6 service to be destroyed.
|
||||
|
||||
**/
|
||||
VOID
|
||||
Dhcp6DestroyService (
|
||||
IN OUT DHCP6_SERVICE *Service
|
||||
)
|
||||
{
|
||||
//
|
||||
// All children instances should have been already destoryed here.
|
||||
//
|
||||
ASSERT (Service->NumOfChild == 0);
|
||||
|
||||
if (Service->ClientId != NULL) {
|
||||
FreePool (Service->ClientId);
|
||||
}
|
||||
|
||||
if (Service->UdpIo != NULL) {
|
||||
UdpIoFreeIo (Service->UdpIo);
|
||||
}
|
||||
|
||||
FreePool (Service);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Create a new Dhcp6 service for the Nic controller.
|
||||
|
||||
@param[in] Controller The controller to be installed DHCP6 service
|
||||
binding protocol.
|
||||
@param[in] ImageHandle The image handle of the Dhcp6 driver.
|
||||
@param[out] Service The return pointer of the new Dhcp6 service.
|
||||
|
||||
@retval EFI_SUCCESS The Dhcp6 service is created successfully.
|
||||
@retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
|
||||
@retval EFI_OUT_OF_RESOURCES Failed to allocate resource.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
Dhcp6CreateService (
|
||||
IN EFI_HANDLE Controller,
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
OUT DHCP6_SERVICE **Service
|
||||
)
|
||||
{
|
||||
DHCP6_SERVICE *Dhcp6Srv;
|
||||
|
||||
*Service = NULL;
|
||||
Dhcp6Srv = AllocateZeroPool (sizeof (DHCP6_SERVICE));
|
||||
|
||||
if (Dhcp6Srv == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
//
|
||||
// Open the SNP protocol to get mode data later.
|
||||
//
|
||||
Dhcp6Srv->Snp = NULL;
|
||||
NetLibGetSnpHandle (Controller, &Dhcp6Srv->Snp);
|
||||
if (Dhcp6Srv->Snp == NULL) {
|
||||
FreePool (Dhcp6Srv);
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// Initialize the fields of the new Dhcp6 service.
|
||||
//
|
||||
Dhcp6Srv->Signature = DHCP6_SERVICE_SIGNATURE;
|
||||
Dhcp6Srv->InDestory = FALSE;
|
||||
Dhcp6Srv->Controller = Controller;
|
||||
Dhcp6Srv->Image = ImageHandle;
|
||||
Dhcp6Srv->Xid = (0xffffff & NET_RANDOM (NetRandomInitSeed ()));
|
||||
|
||||
CopyMem (
|
||||
&Dhcp6Srv->ServiceBinding,
|
||||
&gDhcp6ServiceBindingTemplate,
|
||||
sizeof (EFI_SERVICE_BINDING_PROTOCOL)
|
||||
);
|
||||
|
||||
//
|
||||
// Generate client Duid in the format of Duid-llt.
|
||||
//
|
||||
Dhcp6Srv->ClientId = Dhcp6GenerateClientId (Dhcp6Srv->Snp->Mode);
|
||||
|
||||
if (Dhcp6Srv->ClientId == NULL) {
|
||||
FreePool (Dhcp6Srv);
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// Create an Udp6Io for stateful transmit/receive of each Dhcp6 instance.
|
||||
//
|
||||
Dhcp6Srv->UdpIo = UdpIoCreateIo (
|
||||
Controller,
|
||||
ImageHandle,
|
||||
Dhcp6ConfigureUdpIo,
|
||||
UDP_IO_UDP6_VERSION,
|
||||
NULL
|
||||
);
|
||||
|
||||
if (Dhcp6Srv->UdpIo == NULL) {
|
||||
FreePool (Dhcp6Srv->ClientId);
|
||||
FreePool (Dhcp6Srv);
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
InitializeListHead (&Dhcp6Srv->Child);
|
||||
|
||||
*Service = Dhcp6Srv;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Destroy the Dhcp6 instance and recycle the resources.
|
||||
|
||||
@param[in, out] Instance The pointer to the Dhcp6 instance.
|
||||
|
||||
**/
|
||||
VOID
|
||||
Dhcp6DestroyInstance (
|
||||
IN OUT DHCP6_INSTANCE *Instance
|
||||
)
|
||||
{
|
||||
//
|
||||
// Clean up the retry list first.
|
||||
//
|
||||
Dhcp6CleanupRetry (Instance, DHCP6_PACKET_ALL);
|
||||
gBS->CloseEvent (Instance->Timer);
|
||||
|
||||
//
|
||||
// Clean up the current configure data.
|
||||
//
|
||||
if (Instance->Config != NULL) {
|
||||
Dhcp6CleanupConfigData (Instance->Config);
|
||||
FreePool (Instance->Config);
|
||||
}
|
||||
|
||||
//
|
||||
// Clean up the current Ia.
|
||||
//
|
||||
if (Instance->IaCb.Ia != NULL) {
|
||||
if (Instance->IaCb.Ia->ReplyPacket != NULL) {
|
||||
FreePool (Instance->IaCb.Ia->ReplyPacket);
|
||||
}
|
||||
FreePool (Instance->IaCb.Ia);
|
||||
}
|
||||
|
||||
if (Instance->Unicast != NULL) {
|
||||
FreePool (Instance->Unicast);
|
||||
}
|
||||
|
||||
if (Instance->AdSelect != NULL) {
|
||||
FreePool (Instance->AdSelect);
|
||||
}
|
||||
|
||||
FreePool (Instance);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Create the Dhcp6 instance and initialize it.
|
||||
|
||||
@param[in] Service The pointer to the Dhcp6 service.
|
||||
@param[out] Instance The pointer to the Dhcp6 instance.
|
||||
|
||||
@retval EFI_SUCCESS The Dhcp6 instance is created.
|
||||
@retval EFI_OUT_OF_RESOURCES Failed to allocate resources.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
Dhcp6CreateInstance (
|
||||
IN DHCP6_SERVICE *Service,
|
||||
OUT DHCP6_INSTANCE **Instance
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
DHCP6_INSTANCE *Dhcp6Ins;
|
||||
|
||||
*Instance = NULL;
|
||||
Dhcp6Ins = AllocateZeroPool (sizeof (DHCP6_INSTANCE));
|
||||
|
||||
if (Dhcp6Ins == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
//
|
||||
// Initialize the fields of the new Dhcp6 instance.
|
||||
//
|
||||
Dhcp6Ins->Signature = DHCP6_INSTANCE_SIGNATURE;
|
||||
Dhcp6Ins->UdpSts = EFI_ALREADY_STARTED;
|
||||
Dhcp6Ins->Service = Service;
|
||||
Dhcp6Ins->InDestory = FALSE;
|
||||
Dhcp6Ins->MediaPresent = TRUE;
|
||||
|
||||
CopyMem (
|
||||
&Dhcp6Ins->Dhcp6,
|
||||
&gDhcp6ProtocolTemplate,
|
||||
sizeof (EFI_DHCP6_PROTOCOL)
|
||||
);
|
||||
|
||||
InitializeListHead (&Dhcp6Ins->TxList);
|
||||
InitializeListHead (&Dhcp6Ins->InfList);
|
||||
|
||||
//
|
||||
// There is a timer for each Dhcp6 instance, which is used to track the
|
||||
// lease time of Ia and the retransmisson time of all sent packets.
|
||||
//
|
||||
Status = gBS->CreateEvent (
|
||||
EVT_NOTIFY_SIGNAL | EVT_TIMER,
|
||||
TPL_CALLBACK,
|
||||
Dhcp6OnTimerTick,
|
||||
Dhcp6Ins,
|
||||
&Dhcp6Ins->Timer
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
FreePool (Dhcp6Ins);
|
||||
return Status;
|
||||
}
|
||||
|
||||
*Instance = Dhcp6Ins;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Entry point of the DHCP6 driver to install various protocols.
|
||||
|
||||
@param[in] ImageHandle The handle of the UEFI image file.
|
||||
@param[in] SystemTable The pointer to the EFI System Table.
|
||||
|
||||
@retval EFI_SUCCESS The operation completed successfully.
|
||||
@retval Others Unexpected error occurs.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
Dhcp6DriverEntryPoint (
|
||||
IN EFI_HANDLE ImageHandle,
|
||||
IN EFI_SYSTEM_TABLE *SystemTable
|
||||
)
|
||||
{
|
||||
return EfiLibInstallDriverBindingComponentName2 (
|
||||
ImageHandle,
|
||||
SystemTable,
|
||||
&gDhcp6DriverBinding,
|
||||
ImageHandle,
|
||||
&gDhcp6ComponentName,
|
||||
&gDhcp6ComponentName2
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Test to see if this driver supports ControllerHandle. This service
|
||||
is called by the EFI boot service ConnectController(). In
|
||||
order to make drivers as small as possible, there are a few calling
|
||||
restrictions for this service. ConnectController() must
|
||||
follow these calling restrictions. If any other agent wishes to call
|
||||
Supported() it must also follow these calling restrictions.
|
||||
|
||||
@param[in] This The pointer to the driver binding protocol.
|
||||
@param[in] ControllerHandle The handle of device to be tested.
|
||||
@param[in] RemainingDevicePath Optional parameter use to pick a specific child
|
||||
device to be started.
|
||||
|
||||
@retval EFI_SUCCESS This driver supports this device.
|
||||
@retval Others This driver does not support this device.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
Dhcp6DriverBindingSupported (
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
|
||||
)
|
||||
{
|
||||
return gBS->OpenProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiUdp6ServiceBindingProtocolGuid,
|
||||
NULL,
|
||||
This->DriverBindingHandle,
|
||||
ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_TEST_PROTOCOL
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Start this driver on ControllerHandle. This service is called by the
|
||||
EFI boot service ConnectController(). In order to make
|
||||
drivers as small as possible, there are a few calling restrictions for
|
||||
this service. ConnectController() must follow these
|
||||
calling restrictions. If any other agent wishes to call Start() it
|
||||
must also follow these calling restrictions.
|
||||
|
||||
@param[in] This The pointer to the driver binding protocol.
|
||||
@param[in] ControllerHandle The handle of device to be started.
|
||||
@param[in] RemainingDevicePath Optional parameter use to pick a specific child
|
||||
device to be started.
|
||||
|
||||
@retval EFI_SUCCESS This driver is installed to ControllerHandle.
|
||||
@retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle.
|
||||
@retval other This driver does not support this device.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
Dhcp6DriverBindingStart (
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
DHCP6_SERVICE *Service;
|
||||
|
||||
//
|
||||
// Check the Dhcp6 serivce whether already started.
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
ControllerHandle,
|
||||
&gEfiDhcp6ServiceBindingProtocolGuid,
|
||||
NULL,
|
||||
This->DriverBindingHandle,
|
||||
ControllerHandle,
|
||||
EFI_OPEN_PROTOCOL_TEST_PROTOCOL
|
||||
);
|
||||
|
||||
if (!EFI_ERROR (Status)) {
|
||||
return EFI_ALREADY_STARTED;
|
||||
}
|
||||
|
||||
//
|
||||
// Create and initialize the Dhcp6 service.
|
||||
//
|
||||
Status = Dhcp6CreateService (
|
||||
ControllerHandle,
|
||||
This->DriverBindingHandle,
|
||||
&Service
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
ASSERT (Service != NULL);
|
||||
|
||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||
&ControllerHandle,
|
||||
&gEfiDhcp6ServiceBindingProtocolGuid,
|
||||
&Service->ServiceBinding,
|
||||
NULL
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
Dhcp6DestroyService (Service);
|
||||
return Status;
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Stop this driver on ControllerHandle. This service is called by the
|
||||
EFI boot service DisconnectController(). In order to
|
||||
make drivers as small as possible, there are a few calling
|
||||
restrictions for this service. DisconnectController()
|
||||
must follow these calling restrictions. If any other agent wishes
|
||||
to call Stop() it must also follow these calling restrictions.
|
||||
|
||||
@param[in] This Protocol instance pointer.
|
||||
@param[in] ControllerHandle Handle of device to stop driver on
|
||||
@param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
|
||||
children is zero stop the entire bus driver.
|
||||
@param[in] ChildHandleBuffer List of Child Handles to Stop.
|
||||
|
||||
@retval EFI_SUCCESS This driver is removed ControllerHandle
|
||||
@retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
|
||||
@retval other This driver was not removed from this device
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
Dhcp6DriverBindingStop (
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN UINTN NumberOfChildren,
|
||||
IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_TPL OldTpl;
|
||||
EFI_HANDLE NicHandle;
|
||||
EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;
|
||||
DHCP6_SERVICE *Service;
|
||||
DHCP6_INSTANCE *Instance;
|
||||
|
||||
//
|
||||
// Find and check the Nic handle by the controller handle.
|
||||
//
|
||||
NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiUdp6ProtocolGuid);
|
||||
|
||||
if (NicHandle == NULL) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
Status = gBS->OpenProtocol (
|
||||
NicHandle,
|
||||
&gEfiDhcp6ServiceBindingProtocolGuid,
|
||||
(VOID **) &ServiceBinding,
|
||||
This->DriverBindingHandle,
|
||||
NicHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
Service = DHCP6_SERVICE_FROM_THIS (ServiceBinding);
|
||||
|
||||
if (Service->InDestory) {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
|
||||
|
||||
if (NumberOfChildren == 0) {
|
||||
//
|
||||
// Destory the service itself if no child instance left.
|
||||
//
|
||||
Service->InDestory = TRUE;
|
||||
|
||||
Status = gBS->UninstallProtocolInterface (
|
||||
NicHandle,
|
||||
&gEfiDhcp6ServiceBindingProtocolGuid,
|
||||
ServiceBinding
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
Service->InDestory = FALSE;
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
Dhcp6DestroyService (Service);
|
||||
|
||||
} else {
|
||||
//
|
||||
// Destory all the children instances before destory the service.
|
||||
//
|
||||
while (!IsListEmpty (&Service->Child)) {
|
||||
Instance = NET_LIST_HEAD (&Service->Child, DHCP6_INSTANCE, Link);
|
||||
ServiceBinding->DestroyChild (ServiceBinding, Instance->Handle);
|
||||
}
|
||||
//
|
||||
// Any of child failed to be destroyed.
|
||||
//
|
||||
if (Service->NumOfChild != 0) {
|
||||
Status = EFI_DEVICE_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
ON_EXIT:
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Creates a child handle and installs a protocol.
|
||||
|
||||
The CreateChild() function installs a protocol on ChildHandle.
|
||||
If ChildHandle is a pointer to NULL, then a new handle is created and returned in ChildHandle.
|
||||
If ChildHandle is not a pointer to NULL, then the protocol installs on the existing ChildHandle.
|
||||
|
||||
@param[in] This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
|
||||
@param[in, out] ChildHandle Pointer to the handle of the child to create. If it is NULL,
|
||||
then a new handle is created. If it is a pointer to an existing
|
||||
UEFI handle, then the protocol is added to the existing UEFI handle.
|
||||
|
||||
@retval EFI_SUCCES The protocol was added to ChildHandle.
|
||||
@retval EFI_INVALID_PARAMETER ChildHandle is NULL.
|
||||
@retval other The child handle was not created.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
Dhcp6ServiceBindingCreateChild (
|
||||
IN EFI_SERVICE_BINDING_PROTOCOL *This,
|
||||
IN OUT EFI_HANDLE *ChildHandle
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_TPL OldTpl;
|
||||
DHCP6_SERVICE *Service;
|
||||
DHCP6_INSTANCE *Instance;
|
||||
VOID *Udp6;
|
||||
|
||||
if (This == NULL || ChildHandle == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Service = DHCP6_SERVICE_FROM_THIS (This);
|
||||
|
||||
Status = Dhcp6CreateInstance (Service, &Instance);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
|
||||
ASSERT (Instance != NULL);
|
||||
|
||||
//
|
||||
// Start the timer when the instance is ready to use.
|
||||
//
|
||||
Status = gBS->SetTimer (
|
||||
Instance->Timer,
|
||||
TimerPeriodic,
|
||||
TICKS_PER_SECOND
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// Install the DHCP6 protocol onto ChildHandle.
|
||||
//
|
||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||
ChildHandle,
|
||||
&gEfiDhcp6ProtocolGuid,
|
||||
&Instance->Dhcp6,
|
||||
NULL
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
Instance->Handle = *ChildHandle;
|
||||
|
||||
//
|
||||
// Open the UDP6 protocol BY_CHILD.
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
Service->UdpIo->UdpHandle,
|
||||
&gEfiUdp6ProtocolGuid,
|
||||
(VOID **) &Udp6,
|
||||
gDhcp6DriverBinding.DriverBindingHandle,
|
||||
Instance->Handle,
|
||||
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
|
||||
gBS->UninstallMultipleProtocolInterfaces (
|
||||
Instance->Handle,
|
||||
&gEfiDhcp6ProtocolGuid,
|
||||
&Instance->Dhcp6,
|
||||
NULL
|
||||
);
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
//
|
||||
// Add into the children list of its parent service.
|
||||
//
|
||||
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
|
||||
|
||||
InsertTailList (&Service->Child, &Instance->Link);
|
||||
Service->NumOfChild++;
|
||||
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
return EFI_SUCCESS;
|
||||
|
||||
ON_ERROR:
|
||||
|
||||
Dhcp6DestroyInstance (Instance);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Destroys a child handle with a protocol installed on it.
|
||||
|
||||
The DestroyChild() function does the opposite of CreateChild(). It removes a protocol
|
||||
that was installed by CreateChild() from ChildHandle. If the removed protocol is the
|
||||
last protocol on ChildHandle, then ChildHandle is destroyed.
|
||||
|
||||
@param[in] This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
|
||||
@param[in] ChildHandle Handle of the child to destroy
|
||||
|
||||
@retval EFI_SUCCES The protocol was removed from ChildHandle.
|
||||
@retval EFI_UNSUPPORTED ChildHandle does not support the protocol that is being removed.
|
||||
@retval EFI_INVALID_PARAMETER Child handle is not a valid UEFI Handle.
|
||||
@retval EFI_ACCESS_DENIED The protocol could not be removed from the ChildHandle
|
||||
because its services are being used.
|
||||
@retval other The child handle was not destroyed
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
Dhcp6ServiceBindingDestroyChild (
|
||||
IN EFI_SERVICE_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE ChildHandle
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_TPL OldTpl;
|
||||
EFI_DHCP6_PROTOCOL *Dhcp6;
|
||||
DHCP6_SERVICE *Service;
|
||||
DHCP6_INSTANCE *Instance;
|
||||
|
||||
if (This == NULL || ChildHandle == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve the private context data structures
|
||||
//
|
||||
Status = gBS->OpenProtocol (
|
||||
ChildHandle,
|
||||
&gEfiDhcp6ProtocolGuid,
|
||||
(VOID **) &Dhcp6,
|
||||
gDhcp6DriverBinding.DriverBindingHandle,
|
||||
ChildHandle,
|
||||
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
Instance = DHCP6_INSTANCE_FROM_THIS (Dhcp6);
|
||||
Service = DHCP6_SERVICE_FROM_THIS (This);
|
||||
|
||||
if (Instance->Service != Service) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (Instance->InDestory) {
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
|
||||
|
||||
Instance->InDestory = TRUE;
|
||||
|
||||
Status = gBS->CloseProtocol (
|
||||
Service->UdpIo->UdpHandle,
|
||||
&gEfiUdp6ProtocolGuid,
|
||||
gDhcp6DriverBinding.DriverBindingHandle,
|
||||
ChildHandle
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
Instance->InDestory = FALSE;
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Uninstall the MTFTP6 protocol first to enable a top down destruction.
|
||||
//
|
||||
Status = gBS->UninstallProtocolInterface (
|
||||
ChildHandle,
|
||||
&gEfiDhcp6ProtocolGuid,
|
||||
Dhcp6
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
Instance->InDestory = FALSE;
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
// Remove it from the children list of its parent service.
|
||||
//
|
||||
RemoveEntryList (&Instance->Link);
|
||||
Service->NumOfChild--;
|
||||
|
||||
Dhcp6DestroyInstance (Instance);
|
||||
|
||||
gBS->RestoreTPL (OldTpl);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
155
NetworkPkg/Dhcp6Dxe/Dhcp6Driver.h
Normal file
155
NetworkPkg/Dhcp6Dxe/Dhcp6Driver.h
Normal file
@@ -0,0 +1,155 @@
|
||||
/** @file
|
||||
Driver Binding functions and Service Binding functions
|
||||
declaration for Dhcp6 Driver.
|
||||
|
||||
Copyright (c) 2009 - 2010, 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
|
||||
http://opensource.org/licenses/bsd-license.php.
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __EFI_DHCP6_DRIVER_H__
|
||||
#define __EFI_DHCP6_DRIVER_H__
|
||||
|
||||
#include <Protocol/ServiceBinding.h>
|
||||
|
||||
extern EFI_COMPONENT_NAME_PROTOCOL gDhcp6ComponentName;
|
||||
extern EFI_COMPONENT_NAME2_PROTOCOL gDhcp6ComponentName2;
|
||||
|
||||
/**
|
||||
Test to see if this driver supports ControllerHandle. This service
|
||||
is called by the EFI boot service ConnectController(). In
|
||||
order to make drivers as small as possible, there are a few calling
|
||||
restrictions for this service. ConnectController() must
|
||||
follow these calling restrictions. If any other agent wishes to call
|
||||
Supported(), it must also follow these calling restrictions.
|
||||
|
||||
@param[in] This Protocol instance pointer.
|
||||
@param[in] ControllerHandle Handle of device to test.
|
||||
@param[in] RemainingDevicePath Optional parameter use to pick a specific child
|
||||
device to start.
|
||||
|
||||
@retval EFI_SUCCESS This driver supports this device.
|
||||
@retval EFI_ALREADY_STARTED This driver is already running on this device.
|
||||
@retval other This driver does not support this device.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
Dhcp6DriverBindingSupported (
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
|
||||
);
|
||||
|
||||
/**
|
||||
Start this driver on ControllerHandle. This service is called by the
|
||||
EFI boot service ConnectController(). In order to make
|
||||
drivers as small as possible, there are a few calling restrictions for
|
||||
this service. ConnectController() must follow these
|
||||
calling restrictions. If any other agent wishes to call Start(), it
|
||||
must also follow these calling restrictions.
|
||||
|
||||
@param[in] This Protocol instance pointer.
|
||||
@param[in] ControllerHandle Handle of device to bind driver to.
|
||||
@param[in] RemainingDevicePath Optional parameter use to pick a specific child
|
||||
device to start.
|
||||
|
||||
@retval EFI_SUCCESS This driver is added to ControllerHandle.
|
||||
@retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle.
|
||||
@retval other This driver does not support this device.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
Dhcp6DriverBindingStart (
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
|
||||
);
|
||||
|
||||
/**
|
||||
Stop this driver on ControllerHandle. This service is called by the
|
||||
EFI boot service DisconnectController(). In order to
|
||||
make drivers as small as possible, there are a few calling
|
||||
restrictions for this service. DisconnectController()
|
||||
must follow these calling restrictions. If any other agent wishes
|
||||
to call Stop() it must also follow these calling restrictions.
|
||||
|
||||
@param[in] This Protocol instance pointer.
|
||||
@param[in] ControllerHandle Handle of device to stop driver on.
|
||||
@param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If the number of
|
||||
children is zero, stop the entire bus driver.
|
||||
@param[in] ChildHandleBuffer List of Child Handles to Stop.
|
||||
|
||||
@retval EFI_SUCCESS This driver is removed ControllerHandle.
|
||||
@retval other This driver was not removed from this device.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
Dhcp6DriverBindingStop (
|
||||
IN EFI_DRIVER_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE ControllerHandle,
|
||||
IN UINTN NumberOfChildren,
|
||||
IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
|
||||
);
|
||||
|
||||
/**
|
||||
Creates a child handle and installs a protocol.
|
||||
|
||||
The CreateChild() function installs a protocol on ChildHandle.
|
||||
If ChildHandle is a pointer to NULL, then a new handle is created and returned in ChildHandle.
|
||||
If ChildHandle is not a pointer to NULL, then the protocol installs on the existing ChildHandle.
|
||||
|
||||
@param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
|
||||
@param ChildHandle Pointer to the handle of the child to create. If it is NULL,
|
||||
then a new handle is created. If it is a pointer to an existing UEFI handle,
|
||||
then the protocol is added to the existing UEFI handle.
|
||||
|
||||
@retval EFI_SUCCES The protocol was added to ChildHandle.
|
||||
@retval EFI_INVALID_PARAMETER ChildHandle is NULL.
|
||||
@retval EFI_OUT_OF_RESOURCES There are not enough resources availabe to create
|
||||
the child.
|
||||
@retval other The child handle was not created.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
Dhcp6ServiceBindingCreateChild (
|
||||
IN EFI_SERVICE_BINDING_PROTOCOL *This,
|
||||
IN OUT EFI_HANDLE *ChildHandle
|
||||
);
|
||||
|
||||
/**
|
||||
Destroys a child handle with a protocol installed on it.
|
||||
|
||||
The DestroyChild() function does the opposite of CreateChild(). It removes a protocol
|
||||
that was installed by CreateChild() from ChildHandle. If the removed protocol is the
|
||||
last protocol on ChildHandle, then ChildHandle is destroyed.
|
||||
|
||||
@param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance.
|
||||
@param ChildHandle Handle of the child to destroy.
|
||||
|
||||
@retval EFI_SUCCES The protocol was removed from ChildHandle.
|
||||
@retval EFI_UNSUPPORTED ChildHandle does not support the protocol that is being removed.
|
||||
@retval EFI_INVALID_PARAMETER Child handle is not a valid UEFI Handle.
|
||||
@retval EFI_ACCESS_DENIED The protocol could not be removed from the ChildHandle
|
||||
because its services are being used.
|
||||
@retval other The child handle was not destroyed
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
Dhcp6ServiceBindingDestroyChild (
|
||||
IN EFI_SERVICE_BINDING_PROTOCOL *This,
|
||||
IN EFI_HANDLE ChildHandle
|
||||
);
|
||||
|
||||
#endif
|
69
NetworkPkg/Dhcp6Dxe/Dhcp6Dxe.inf
Normal file
69
NetworkPkg/Dhcp6Dxe/Dhcp6Dxe.inf
Normal file
@@ -0,0 +1,69 @@
|
||||
## @file
|
||||
# Component description file for Dhcp6 module.
|
||||
#
|
||||
# Copyright (c) 2009 - 2010, 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
|
||||
# http://opensource.org/licenses/bsd-license.php.
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
##
|
||||
|
||||
[Defines]
|
||||
INF_VERSION = 0x00010005
|
||||
BASE_NAME = Dhcp6Dxe
|
||||
FILE_GUID = 95E3669D-34BE-4775-A651-7EA41B69D89E
|
||||
MODULE_TYPE = UEFI_DRIVER
|
||||
VERSION_STRING = 1.0
|
||||
ENTRY_POINT = Dhcp6DriverEntryPoint
|
||||
UNLOAD_IMAGE = NetLibDefaultUnload
|
||||
#
|
||||
# The following information is for reference only and not required by the build tools.
|
||||
#
|
||||
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
|
||||
#
|
||||
# DRIVER_BINDING = gDhcp6DriverBinding
|
||||
# COMPONENT_NAME = gDhcp6ComponentName
|
||||
# COMPONENT_NAME2 = gDhcp6ComponentName2
|
||||
#
|
||||
|
||||
[Sources]
|
||||
Dhcp6Driver.c
|
||||
Dhcp6Driver.h
|
||||
Dhcp6Impl.c
|
||||
Dhcp6Impl.h
|
||||
Dhcp6Io.c
|
||||
Dhcp6Io.h
|
||||
Dhcp6Utility.c
|
||||
Dhcp6Utility.h
|
||||
ComponentName.c
|
||||
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
MdeModulePkg/MdeModulePkg.dec
|
||||
|
||||
|
||||
[LibraryClasses]
|
||||
UefiLib
|
||||
BaseLib
|
||||
BaseMemoryLib
|
||||
MemoryAllocationLib
|
||||
UefiDriverEntryPoint
|
||||
UefiBootServicesTableLib
|
||||
UefiRuntimeServicesTableLib
|
||||
DebugLib
|
||||
NetLib
|
||||
UdpIoLib
|
||||
|
||||
|
||||
[Protocols]
|
||||
gEfiUdp6ServiceBindingProtocolGuid
|
||||
gEfiUdp6ProtocolGuid
|
||||
gEfiDhcp6ServiceBindingProtocolGuid
|
||||
gEfiDhcp6ProtocolGuid
|
||||
|
1220
NetworkPkg/Dhcp6Dxe/Dhcp6Impl.c
Normal file
1220
NetworkPkg/Dhcp6Dxe/Dhcp6Impl.c
Normal file
File diff suppressed because it is too large
Load Diff
597
NetworkPkg/Dhcp6Dxe/Dhcp6Impl.h
Normal file
597
NetworkPkg/Dhcp6Dxe/Dhcp6Impl.h
Normal file
@@ -0,0 +1,597 @@
|
||||
/** @file
|
||||
Dhcp6 internal data structure and definition declaration.
|
||||
|
||||
Copyright (c) 2009 - 2010, 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
|
||||
http://opensource.org/licenses/bsd-license.php.
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __EFI_DHCP6_IMPL_H__
|
||||
#define __EFI_DHCP6_IMPL_H__
|
||||
|
||||
|
||||
#include <Uefi.h>
|
||||
|
||||
#include <Protocol/Dhcp6.h>
|
||||
#include <Protocol/Udp6.h>
|
||||
#include <Protocol/ServiceBinding.h>
|
||||
#include <Protocol/DriverBinding.h>
|
||||
|
||||
#include <Library/UdpIoLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/UefiRuntimeServicesTableLib.h>
|
||||
#include <Library/UefiLib.h>
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/NetLib.h>
|
||||
|
||||
|
||||
typedef struct _DHCP6_IA_CB DHCP6_IA_CB;
|
||||
typedef struct _DHCP6_INF_CB DHCP6_INF_CB;
|
||||
typedef struct _DHCP6_TX_CB DHCP6_TX_CB;
|
||||
typedef struct _DHCP6_SERVICE DHCP6_SERVICE;
|
||||
typedef struct _DHCP6_INSTANCE DHCP6_INSTANCE;
|
||||
|
||||
#include "Dhcp6Utility.h"
|
||||
#include "Dhcp6Io.h"
|
||||
#include "Dhcp6Driver.h"
|
||||
|
||||
#define DHCP6_SERVICE_SIGNATURE SIGNATURE_32 ('D', 'H', '6', 'S')
|
||||
#define DHCP6_INSTANCE_SIGNATURE SIGNATURE_32 ('D', 'H', '6', 'I')
|
||||
|
||||
//
|
||||
// Transmit parameters of solicit message, refers to section-5.5 of rfc-3315.
|
||||
//
|
||||
#define DHCP6_SOL_MAX_DELAY 1
|
||||
#define DHCP6_SOL_IRT 1
|
||||
#define DHCP6_SOL_MRC 0
|
||||
#define DHCP6_SOL_MRT 120
|
||||
#define DHCP6_SOL_MRD 0
|
||||
//
|
||||
// Transmit parameters of request message, refers to section-5.5 of rfc-3315.
|
||||
//
|
||||
#define DHCP6_REQ_IRT 1
|
||||
#define DHCP6_REQ_MRC 10
|
||||
#define DHCP6_REQ_MRT 30
|
||||
#define DHCP6_REQ_MRD 0
|
||||
//
|
||||
// Transmit parameters of confirm message, refers to section-5.5 of rfc-3315.
|
||||
//
|
||||
#define DHCP6_CNF_MAX_DELAY 1
|
||||
#define DHCP6_CNF_IRT 1
|
||||
#define DHCP6_CNF_MRC 0
|
||||
#define DHCP6_CNF_MRT 4
|
||||
#define DHCP6_CNF_MRD 10
|
||||
//
|
||||
// Transmit parameters of renew message, refers to section-5.5 of rfc-3315.
|
||||
//
|
||||
#define DHCP6_REN_IRT 10
|
||||
#define DHCP6_REN_MRC 0
|
||||
#define DHCP6_REN_MRT 600
|
||||
#define DHCP6_REN_MRD 0
|
||||
//
|
||||
// Transmit parameters of rebind message, refers to section-5.5 of rfc-3315.
|
||||
//
|
||||
#define DHCP6_REB_IRT 10
|
||||
#define DHCP6_REB_MRC 0
|
||||
#define DHCP6_REB_MRT 600
|
||||
#define DHCP6_REB_MRD 0
|
||||
//
|
||||
// Transmit parameters of information request message, refers to section-5.5 of rfc-3315.
|
||||
//
|
||||
#define DHCP6_INF_MAX_DELAY 1
|
||||
#define DHCP6_INF_IRT 1
|
||||
#define DHCP6_INF_MRC 0
|
||||
#define DHCP6_INF_MRT 120
|
||||
#define DHCP6_INF_MRD 0
|
||||
//
|
||||
// Transmit parameters of release message, refers to section-5.5 of rfc-3315.
|
||||
//
|
||||
#define DHCP6_REL_IRT 1
|
||||
#define DHCP6_REL_MRC 5
|
||||
#define DHCP6_REL_MRT 0
|
||||
#define DHCP6_REL_MRD 0
|
||||
//
|
||||
// Transmit parameters of decline message, refers to section-5.5 of rfc-3315.
|
||||
//
|
||||
#define DHCP6_DEC_IRT 1
|
||||
#define DHCP6_DEC_MRC 5
|
||||
#define DHCP6_DEC_MRT 0
|
||||
#define DHCP6_DEC_MRD 0
|
||||
|
||||
#define DHCP6_PACKET_ALL 0
|
||||
#define DHCP6_PACKET_STATEFUL 1
|
||||
#define DHCP6_PACKET_STATELESS 2
|
||||
|
||||
#define DHCP6_BASE_PACKET_SIZE 1024
|
||||
|
||||
#define DHCP6_PORT_CLIENT 546
|
||||
#define DHCP6_PORT_SERVER 547
|
||||
|
||||
#define DHCP6_INSTANCE_FROM_THIS(Instance) CR ((Instance), DHCP6_INSTANCE, Dhcp6, DHCP6_INSTANCE_SIGNATURE)
|
||||
#define DHCP6_SERVICE_FROM_THIS(Service) CR ((Service), DHCP6_SERVICE, ServiceBinding, DHCP6_SERVICE_SIGNATURE)
|
||||
|
||||
extern EFI_IPv6_ADDRESS mAllDhcpRelayAndServersAddress;
|
||||
extern EFI_IPv6_ADDRESS mAllDhcpServersAddress;
|
||||
extern EFI_DHCP6_PROTOCOL gDhcp6ProtocolTemplate;
|
||||
|
||||
//
|
||||
// Enumeration of Dhcp6 message type, refers to section-5.3 of rfc-3315.
|
||||
//
|
||||
typedef enum {
|
||||
Dhcp6MsgSolicit = 1,
|
||||
Dhcp6MsgAdvertise = 2,
|
||||
Dhcp6MsgRequest = 3,
|
||||
Dhcp6MsgConfirm = 4,
|
||||
Dhcp6MsgRenew = 5,
|
||||
Dhcp6MsgRebind = 6,
|
||||
Dhcp6MsgReply = 7,
|
||||
Dhcp6MsgRelease = 8,
|
||||
Dhcp6MsgDecline = 9,
|
||||
Dhcp6MsgReconfigure = 10,
|
||||
Dhcp6MsgInfoRequest = 11
|
||||
} DHCP6_MSG_TYPE;
|
||||
|
||||
//
|
||||
// Enumeration of option code in Dhcp6 packet, refers to section-24.3 of rfc-3315.
|
||||
//
|
||||
typedef enum {
|
||||
Dhcp6OptClientId = 1,
|
||||
Dhcp6OptServerId = 2,
|
||||
Dhcp6OptIana = 3,
|
||||
Dhcp6OptIata = 4,
|
||||
Dhcp6OptIaAddr = 5,
|
||||
Dhcp6OptRequestOption = 6,
|
||||
Dhcp6OptPreference = 7,
|
||||
Dhcp6OptElapsedTime = 8,
|
||||
Dhcp6OptReplayMessage = 9,
|
||||
Dhcp6OptAuthentication = 11,
|
||||
Dhcp6OptServerUnicast = 12,
|
||||
Dhcp6OptStatusCode = 13,
|
||||
Dhcp6OptRapidCommit = 14,
|
||||
Dhcp6OptUserClass = 15,
|
||||
Dhcp6OptVendorClass = 16,
|
||||
Dhcp6OptVendorInfo = 17,
|
||||
Dhcp6OptInterfaceId = 18,
|
||||
Dhcp6OptReconfigMessage = 19,
|
||||
Dhcp6OptReconfigureAccept = 20
|
||||
} DHCP6_OPT_CODE;
|
||||
|
||||
//
|
||||
// Enumeration of status code recorded by IANA, refers to section-24.4 of rfc-3315.
|
||||
//
|
||||
typedef enum {
|
||||
Dhcp6StsSuccess = 0,
|
||||
Dhcp6StsUnspecFail = 1,
|
||||
Dhcp6StsNoAddrsAvail = 2,
|
||||
Dhcp6StsNoBinding = 3,
|
||||
Dhcp6StsNotOnLink = 4,
|
||||
Dhcp6StsUseMulticast = 5
|
||||
} DHCP6_STS_CODE;
|
||||
|
||||
//
|
||||
// Enumeration of Duid type recorded by IANA, refers to section-24.5 of rfc-3315.
|
||||
//
|
||||
typedef enum {
|
||||
Dhcp6DuidTypeLlt = 1,
|
||||
Dhcp6DuidTypeEn = 2,
|
||||
Dhcp6DuidTypeLl = 3
|
||||
} DHCP6_DUID_TYPE;
|
||||
|
||||
//
|
||||
// Control block for each IA.
|
||||
//
|
||||
struct _DHCP6_IA_CB {
|
||||
EFI_DHCP6_IA *Ia;
|
||||
UINT32 T1;
|
||||
UINT32 T2;
|
||||
UINT32 AllExpireTime;
|
||||
UINT32 LeaseTime;
|
||||
};
|
||||
|
||||
//
|
||||
// Control block for each transmitted message.
|
||||
//
|
||||
struct _DHCP6_TX_CB {
|
||||
LIST_ENTRY Link;
|
||||
UINT32 Xid;
|
||||
EFI_DHCP6_PACKET *TxPacket;
|
||||
EFI_DHCP6_RETRANSMISSION RetryCtl;
|
||||
UINT32 RetryCnt;
|
||||
UINT32 RetryExp;
|
||||
UINT32 RetryLos;
|
||||
UINT32 TickTime;
|
||||
UINT16 *Elapsed;
|
||||
};
|
||||
|
||||
//
|
||||
// Control block for each info-request message.
|
||||
//
|
||||
struct _DHCP6_INF_CB {
|
||||
LIST_ENTRY Link;
|
||||
UINT32 Xid;
|
||||
EFI_DHCP6_INFO_CALLBACK ReplyCallback;
|
||||
VOID *CallbackContext;
|
||||
EFI_EVENT TimeoutEvent;
|
||||
};
|
||||
|
||||
//
|
||||
// Control block for Dhcp6 instance, it's per configuration data.
|
||||
//
|
||||
struct _DHCP6_INSTANCE {
|
||||
UINT32 Signature;
|
||||
EFI_HANDLE Handle;
|
||||
DHCP6_SERVICE *Service;
|
||||
LIST_ENTRY Link;
|
||||
EFI_DHCP6_PROTOCOL Dhcp6;
|
||||
EFI_EVENT Timer;
|
||||
EFI_DHCP6_CONFIG_DATA *Config;
|
||||
EFI_DHCP6_IA *CacheIa;
|
||||
DHCP6_IA_CB IaCb;
|
||||
LIST_ENTRY TxList;
|
||||
LIST_ENTRY InfList;
|
||||
EFI_DHCP6_PACKET *AdSelect;
|
||||
UINT8 AdPref;
|
||||
EFI_IPv6_ADDRESS *Unicast;
|
||||
EFI_STATUS UdpSts;
|
||||
BOOLEAN InDestory;
|
||||
BOOLEAN MediaPresent;
|
||||
UINT64 StartTime;
|
||||
};
|
||||
|
||||
//
|
||||
// Control block for Dhcp6 service, it's per Nic handle.
|
||||
//
|
||||
struct _DHCP6_SERVICE {
|
||||
UINT32 Signature;
|
||||
EFI_HANDLE Controller;
|
||||
EFI_HANDLE Image;
|
||||
EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;
|
||||
EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
|
||||
EFI_DHCP6_DUID *ClientId;
|
||||
UDP_IO *UdpIo;
|
||||
UINT32 Xid;
|
||||
LIST_ENTRY Child;
|
||||
UINTN NumOfChild;
|
||||
BOOLEAN InDestory;
|
||||
};
|
||||
|
||||
/**
|
||||
Starts the DHCPv6 standard S.A.R.R. process.
|
||||
|
||||
The Start() function starts the DHCPv6 standard process. This function can
|
||||
be called only when the state of Dhcp6 instance is in the Dhcp6Init state.
|
||||
If the DHCP process completes successfully, the state of the Dhcp6 instance
|
||||
will be transferred through Dhcp6Selecting and Dhcp6Requesting to the
|
||||
Dhcp6Bound state.
|
||||
Refer to rfc-3315 for precise state transitions during this process. At the
|
||||
time when each event occurs in this process, the callback function that was set
|
||||
by EFI_DHCP6_PROTOCOL.Configure() will be called and the user can take this
|
||||
opportunity to control the process.
|
||||
|
||||
@param[in] This The pointer to Dhcp6 protocol.
|
||||
|
||||
@retval EFI_SUCCESS The DHCPv6 standard process has started, or it
|
||||
completed when CompletionEvent was NULL.
|
||||
@retval EFI_ACCESS_DENIED The EFI DHCPv6 Child instance hasn't been configured.
|
||||
@retval EFI_INVALID_PARAMETER This is NULL.
|
||||
@retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
|
||||
@retval EFI_TIMEOUT The DHCPv6 configuration process failed because no
|
||||
response was received from the server within the
|
||||
specified timeout value.
|
||||
@retval EFI_ABORTED The user aborted the DHCPv6 process.
|
||||
@retval EFI_ALREADY_STARTED Some other Dhcp6 instance already started the DHCPv6
|
||||
standard process.
|
||||
@retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EfiDhcp6Start (
|
||||
IN EFI_DHCP6_PROTOCOL *This
|
||||
);
|
||||
|
||||
/**
|
||||
Stops the DHCPv6 standard S.A.R.R. process.
|
||||
|
||||
The Stop() function is used to stop the DHCPv6 standard process. After this
|
||||
function is called successfully, the state of Dhcp6 instance is transferred
|
||||
into the Dhcp6Init. EFI_DHCP6_PROTOCOL.Configure() needs to be called
|
||||
before DHCPv6 standard process can be started again. This function can be
|
||||
called when the Dhcp6 instance is in any state.
|
||||
|
||||
@param[in] This The pointer to the Dhcp6 protocol.
|
||||
|
||||
@retval EFI_SUCCESS The Dhcp6 instance is now in the Dhcp6Init state.
|
||||
@retval EFI_INVALID_PARAMETER This is NULL.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EfiDhcp6Stop (
|
||||
IN EFI_DHCP6_PROTOCOL *This
|
||||
);
|
||||
|
||||
/**
|
||||
Returns the current operating mode data for the Dhcp6 instance.
|
||||
|
||||
The GetModeData() function returns the current operating mode and
|
||||
cached data packet for the Dhcp6 instance.
|
||||
|
||||
@param[in] This The pointer to the Dhcp6 protocol.
|
||||
@param[out] Dhcp6ModeData The pointer to the Dhcp6 mode data.
|
||||
@param[out] Dhcp6ConfigData The pointer to the Dhcp6 configure data.
|
||||
|
||||
@retval EFI_SUCCESS The mode data was returned.
|
||||
@retval EFI_INVALID_PARAMETER This is NULL.
|
||||
@retval EFI_ACCESS_DENIED The EFI DHCPv6 Protocol instance has not
|
||||
been configured when Dhcp6ConfigData is
|
||||
not NULL.
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EfiDhcp6GetModeData (
|
||||
IN EFI_DHCP6_PROTOCOL *This,
|
||||
OUT EFI_DHCP6_MODE_DATA *Dhcp6ModeData OPTIONAL,
|
||||
OUT EFI_DHCP6_CONFIG_DATA *Dhcp6ConfigData OPTIONAL
|
||||
);
|
||||
|
||||
/**
|
||||
Initializes, changes, or resets the operational settings for the Dhcp6 instance.
|
||||
|
||||
The Configure() function is used to initialize or clean up the configuration
|
||||
data of the Dhcp6 instance:
|
||||
- When Dhcp6CfgData is not NULL and Configure() is called successfully, the
|
||||
configuration data will be initialized in the Dhcp6 instance and the state
|
||||
of the configured IA will be transferred into Dhcp6Init.
|
||||
- When Dhcp6CfgData is NULL and Configure() is called successfully, the
|
||||
configuration data will be cleaned up and no IA will be associated with
|
||||
the Dhcp6 instance.
|
||||
To update the configuration data for an Dhcp6 instance, the original data
|
||||
must be cleaned up before setting the new configuration data.
|
||||
|
||||
@param[in] This The pointer to the Dhcp6 protocol
|
||||
@param[in] Dhcp6CfgData The pointer to the EFI_DHCP6_CONFIG_DATA.
|
||||
|
||||
@retval EFI_SUCCESS The Dhcp6 is configured successfully with the
|
||||
Dhcp6Init state, or cleaned up the original
|
||||
configuration setting.
|
||||
@retval EFI_ACCESS_DENIED The Dhcp6 instance has been already configured
|
||||
when Dhcp6CfgData is not NULL.
|
||||
The Dhcp6 instance has already started the
|
||||
DHCPv6 S.A.R.R when Dhcp6CfgData is NULL.
|
||||
@retval EFI_INVALID_PARAMETER Some of the parameter is invalid.
|
||||
@retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
|
||||
@retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EfiDhcp6Configure (
|
||||
IN EFI_DHCP6_PROTOCOL *This,
|
||||
IN EFI_DHCP6_CONFIG_DATA *Dhcp6CfgData OPTIONAL
|
||||
);
|
||||
|
||||
/**
|
||||
Request configuration information without the assignment of any
|
||||
Ia addresses of the client.
|
||||
|
||||
The InfoRequest() function is used to request configuration information
|
||||
without the assignment of any IPv6 address of the client. Client sends
|
||||
out Information Request packet to obtain the required configuration
|
||||
information, and DHCPv6 server responds with Reply packet containing
|
||||
the information for the client. The received Reply packet will be passed
|
||||
to the user by ReplyCallback function. If user returns EFI_NOT_READY from
|
||||
ReplyCallback, the Dhcp6 instance will continue to receive other Reply
|
||||
packets unless timeout according to the Retransmission parameter.
|
||||
Otherwise, the Information Request exchange process will be finished
|
||||
successfully if user returns EFI_SUCCESS from ReplyCallback.
|
||||
|
||||
@param[in] This The pointer to the Dhcp6 protocol.
|
||||
@param[in] SendClientId If TRUE, the DHCPv6 protocol instance will build Client
|
||||
Identifier option and include it into Information Request
|
||||
packet. Otherwise, Client Identifier option will not be included.
|
||||
@param[in] OptionRequest The pointer to the buffer of option request options.
|
||||
@param[in] OptionCount The option number in the OptionList.
|
||||
@param[in] OptionList The list of appended options.
|
||||
@param[in] Retransmission The pointer to the retransmission of the message.
|
||||
@param[in] TimeoutEvent The event of timeout.
|
||||
@param[in] ReplyCallback The callback function when a reply was received.
|
||||
@param[in] CallbackContext The pointer to the parameter passed to the callback.
|
||||
|
||||
@retval EFI_SUCCESS The DHCPv6 information request exchange process
|
||||
completed when TimeoutEvent is NULL. Information
|
||||
Request packet has been sent to DHCPv6 server when
|
||||
TimeoutEvent is not NULL.
|
||||
@retval EFI_NO_RESPONSE The DHCPv6 information request exchange process failed
|
||||
because of no response, or not all requested-options
|
||||
are responded to by DHCPv6 servers when Timeout happened.
|
||||
@retval EFI_ABORTED The DHCPv6 information request exchange process was aborted
|
||||
by the user.
|
||||
@retval EFI_INVALID_PARAMETER Some parameter is NULL.
|
||||
@retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
|
||||
@retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EfiDhcp6InfoRequest (
|
||||
IN EFI_DHCP6_PROTOCOL *This,
|
||||
IN BOOLEAN SendClientId,
|
||||
IN EFI_DHCP6_PACKET_OPTION *OptionRequest,
|
||||
IN UINT32 OptionCount,
|
||||
IN EFI_DHCP6_PACKET_OPTION *OptionList[] OPTIONAL,
|
||||
IN EFI_DHCP6_RETRANSMISSION *Retransmission,
|
||||
IN EFI_EVENT TimeoutEvent OPTIONAL,
|
||||
IN EFI_DHCP6_INFO_CALLBACK ReplyCallback,
|
||||
IN VOID *CallbackContext OPTIONAL
|
||||
);
|
||||
|
||||
/**
|
||||
Manually extend the valid and preferred lifetimes for the IPv6 addresses
|
||||
of the configured IA and update other configuration parameters by sending
|
||||
Renew or Rebind packet.
|
||||
|
||||
The RenewRebind() function is used to manually extend the valid and preferred
|
||||
lifetimes for the IPv6 addresses of the configured IA and update other
|
||||
configuration parameters by sending a Renew or Rebind packet.
|
||||
- When RebindRequest is FALSE and the state of the configured IA is Dhcp6Bound,
|
||||
it will send Renew packet to the previously DHCPv6 server and transfer the
|
||||
state of the configured IA to Dhcp6Renewing. If valid Reply packet received,
|
||||
the state transfers to Dhcp6Bound and the valid and preferred timer restarts.
|
||||
If fails, the state transfers to Dhcp6Bound but the timer continues.
|
||||
- When RebindRequest is TRUE and the state of the configured IA is Dhcp6Bound,
|
||||
it will send a Rebind packet. If a valid Reply packet is received, the state transfers
|
||||
to Dhcp6Bound, and the valid and preferred timer restarts. If it fails, the state
|
||||
transfers to Dhcp6Init, and the IA can't be used.
|
||||
|
||||
@param[in] This The pointer to the Dhcp6 protocol.
|
||||
@param[in] RebindRequest If TRUE, Rebind packet will be sent and enter Dhcp6Rebinding state.
|
||||
Otherwise, Renew packet will be sent and enter Dhcp6Renewing state.
|
||||
|
||||
@retval EFI_SUCCESS The DHCPv6 renew/rebind exchange process
|
||||
completed and at least one IPv6 address of the
|
||||
configured IA was bound again when
|
||||
EFI_DHCP6_CONFIG_DATA.IaInfoEvent was NULL.
|
||||
The EFI DHCPv6 Protocol instance has sent Renew
|
||||
or Rebind packet when
|
||||
EFI_DHCP6_CONFIG_DATA.IaInfoEvent is not NULL.
|
||||
@retval EFI_ACCESS_DENIED The Dhcp6 instance hasn't been configured, or the
|
||||
state of the configured IA is not in Dhcp6Bound.
|
||||
@retval EFI_ALREADY_STARTED The state of the configured IA has already entered
|
||||
Dhcp6Renewing when RebindRequest is FALSE.
|
||||
The state of the configured IA has already entered
|
||||
Dhcp6Rebinding when RebindRequest is TRUE.
|
||||
@retval EFI_ABORTED The DHCPv6 renew/rebind exchange process aborted
|
||||
by user.
|
||||
@retval EFI_NO_RESPONSE The DHCPv6 renew/rebind exchange process failed
|
||||
because of no response.
|
||||
@retval EFI_NO_MAPPING No IPv6 address has been bound to the configured
|
||||
IA after the DHCPv6 renew/rebind exchange process.
|
||||
@retval EFI_INVALID_PARAMETER Some parameter is NULL.
|
||||
@retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EfiDhcp6RenewRebind (
|
||||
IN EFI_DHCP6_PROTOCOL *This,
|
||||
IN BOOLEAN RebindRequest
|
||||
);
|
||||
|
||||
/**
|
||||
Inform that one or more addresses assigned by a server are already
|
||||
in use by another node.
|
||||
|
||||
The Decline() function is used to manually decline the assignment of
|
||||
IPv6 addresses, which have been already used by another node. If all
|
||||
IPv6 addresses of the configured IA are declined through this function,
|
||||
the state of the IA will switch through Dhcp6Declining to Dhcp6Init.
|
||||
Otherwise, the state of the IA will restore to Dhcp6Bound after the
|
||||
declining process. The Decline() can only be called when the IA is in
|
||||
Dhcp6Bound state. If the EFI_DHCP6_CONFIG_DATA.IaInfoEvent is NULL,
|
||||
this function is a blocking operation. It will return after the
|
||||
declining process finishes, or aborted by user.
|
||||
|
||||
@param[in] This The pointer to the Dhcp6 protocol.
|
||||
@param[in] AddressCount The number of declining addresses.
|
||||
@param[in] Addresses The pointer to the buffer stored the declining
|
||||
addresses.
|
||||
|
||||
@retval EFI_SUCCESS The DHCPv6 decline exchange process completed
|
||||
when EFI_DHCP6_CONFIG_DATA.IaInfoEvent was NULL.
|
||||
The Dhcp6 instance has sent Decline packet when
|
||||
EFI_DHCP6_CONFIG_DATA.IaInfoEvent is not NULL.
|
||||
@retval EFI_ACCESS_DENIED The Dhcp6 instance hasn't been configured, or the
|
||||
state of the configured IA is not in Dhcp6Bound.
|
||||
@retval EFI_ABORTED The DHCPv6 decline exchange process was aborted by the user.
|
||||
@retval EFI_NOT_FOUND Any specified IPv6 address is not correlated with
|
||||
the configured IA for this instance.
|
||||
@retval EFI_INVALID_PARAMETER Some parameter is NULL.
|
||||
@retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EfiDhcp6Decline (
|
||||
IN EFI_DHCP6_PROTOCOL *This,
|
||||
IN UINT32 AddressCount,
|
||||
IN EFI_IPv6_ADDRESS *Addresses
|
||||
);
|
||||
|
||||
/**
|
||||
Release one or more addresses associated with the configured Ia
|
||||
for the current instance.
|
||||
|
||||
The Release() function is used to manually release the one or more
|
||||
IPv6 address. If AddressCount is zero, it will release all IPv6
|
||||
addresses of the configured IA. If all IPv6 addresses of the IA are
|
||||
released through this function, the state of the IA will switch
|
||||
through Dhcp6Releasing to Dhcp6Init, otherwise, the state of the
|
||||
IA will restore to Dhcp6Bound after the releasing process.
|
||||
The Release() can only be called when the IA is in a Dhcp6Bound state.
|
||||
If the EFI_DHCP6_CONFIG_DATA.IaInfoEvent is NULL, the function is
|
||||
a blocking operation. It will return after the releasing process
|
||||
finishes, or aborted by user.
|
||||
|
||||
@param[in] This The pointer to the Dhcp6 protocol.
|
||||
@param[in] AddressCount The number of releasing addresses.
|
||||
@param[in] Addresses The pointer to the buffer stored the releasing
|
||||
addresses.
|
||||
@retval EFI_SUCCESS The DHCPv6 release exchange process has
|
||||
completed when EFI_DHCP6_CONFIG_DATA.IaInfoEvent
|
||||
is NULL. The Dhcp6 instance has sent Release
|
||||
packet when EFI_DHCP6_CONFIG_DATA.IaInfoEvent
|
||||
is not NULL.
|
||||
@retval EFI_ACCESS_DENIED The Dhcp6 instance hasn't been configured, or the
|
||||
state of the configured IA is not in Dhcp6Bound.
|
||||
@retval EFI_ABORTED The DHCPv6 release exchange process was aborted by the user.
|
||||
@retval EFI_NOT_FOUND Any specified IPv6 address is not correlated with
|
||||
the configured IA for this instance.
|
||||
@retval EFI_INVALID_PARAMETER Some parameter is NULL.
|
||||
@retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EfiDhcp6Release (
|
||||
IN EFI_DHCP6_PROTOCOL *This,
|
||||
IN UINT32 AddressCount,
|
||||
IN EFI_IPv6_ADDRESS *Addresses
|
||||
);
|
||||
|
||||
/**
|
||||
Parse the option data in the Dhcp6 packet.
|
||||
|
||||
The Parse() function is used to retrieve the option list in the DHCPv6 packet.
|
||||
|
||||
@param[in] This The pointer to the Dhcp6 protocol.
|
||||
@param[in] Packet The pointer to the Dhcp6 packet.
|
||||
@param[in, out] OptionCount The number of option in the packet.
|
||||
@param[out] PacketOptionList The array of pointers to the each option in the packet.
|
||||
|
||||
@retval EFI_SUCCESS The packet was successfully parsed.
|
||||
@retval EFI_INVALID_PARAMETER Some parameter is NULL.
|
||||
@retval EFI_BUFFER_TOO_SMALL *OptionCount is smaller than the number of options
|
||||
that were found in the Packet.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
EFIAPI
|
||||
EfiDhcp6Parse (
|
||||
IN EFI_DHCP6_PROTOCOL *This,
|
||||
IN EFI_DHCP6_PACKET *Packet,
|
||||
IN OUT UINT32 *OptionCount,
|
||||
OUT EFI_DHCP6_PACKET_OPTION *PacketOptionList[] OPTIONAL
|
||||
);
|
||||
|
||||
#endif
|
2965
NetworkPkg/Dhcp6Dxe/Dhcp6Io.c
Normal file
2965
NetworkPkg/Dhcp6Dxe/Dhcp6Io.c
Normal file
File diff suppressed because it is too large
Load Diff
193
NetworkPkg/Dhcp6Dxe/Dhcp6Io.h
Normal file
193
NetworkPkg/Dhcp6Dxe/Dhcp6Io.h
Normal file
@@ -0,0 +1,193 @@
|
||||
/** @file
|
||||
Dhcp6 internal functions declaration.
|
||||
|
||||
Copyright (c) 2009 - 2010, 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
|
||||
http://opensource.org/licenses/bsd-license.php.
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __EFI_DHCP6_IO_H__
|
||||
#define __EFI_DHCP6_IO_H__
|
||||
|
||||
|
||||
/**
|
||||
Clean up the specific nodes in the retry list.
|
||||
|
||||
@param[in] Instance The pointer to the Dhcp6 instance.
|
||||
@param[in] Scope The scope of cleanup nodes.
|
||||
|
||||
**/
|
||||
VOID
|
||||
Dhcp6CleanupRetry (
|
||||
IN DHCP6_INSTANCE *Instance,
|
||||
IN UINT32 Scope
|
||||
);
|
||||
|
||||
/**
|
||||
Clean up the session of the instance stateful exchange.
|
||||
|
||||
@param[in, out] Instance The pointer to the Dhcp6 instance.
|
||||
@param[in] Status The return status from udp.
|
||||
|
||||
**/
|
||||
VOID
|
||||
Dhcp6CleanupSession (
|
||||
IN OUT DHCP6_INSTANCE *Instance,
|
||||
IN EFI_STATUS Status
|
||||
);
|
||||
|
||||
/**
|
||||
Create the solicit message and send it.
|
||||
|
||||
@param[in] Instance The pointer to Dhcp6 instance.
|
||||
|
||||
@retval EFI_SUCCESS Create and send the solicit message successfully.
|
||||
@retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
|
||||
@retval Others Failed to send the solicit message.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
Dhcp6SendSolicitMsg (
|
||||
IN DHCP6_INSTANCE *Instance
|
||||
);
|
||||
|
||||
/**
|
||||
Create the request message and send it.
|
||||
|
||||
@param[in] Instance The pointer to the Dhcp6 instance.
|
||||
|
||||
@retval EFI_SUCCESS Create and send the request message successfully.
|
||||
@retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
|
||||
@retval EFI_DEVICE_ERROR An unexpected error.
|
||||
@retval Others Failed to send the request message.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
Dhcp6SendRequestMsg (
|
||||
IN DHCP6_INSTANCE *Instance
|
||||
);
|
||||
|
||||
/**
|
||||
Create the renew/rebind message and send it.
|
||||
|
||||
@param[in] Instance The pointer to the Dhcp6 instance.
|
||||
@param[in] RebindRequest If TRUE, it is a Rebind type message.
|
||||
Otherwise, it is a Renew type message.
|
||||
|
||||
@retval EFI_SUCCESS Create and send the renew/rebind message successfully.
|
||||
@retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
|
||||
@retval EFI_DEVICE_ERROR An unexpected error.
|
||||
@retval Others Failed to send the renew/rebind message.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
Dhcp6SendRenewRebindMsg (
|
||||
IN DHCP6_INSTANCE *Instance,
|
||||
IN BOOLEAN RebindRequest
|
||||
);
|
||||
|
||||
/**
|
||||
Create the decline message and send it.
|
||||
|
||||
@param[in] Instance The pointer to the Dhcp6 instance.
|
||||
@param[in] DecIa The pointer to the decline Ia.
|
||||
|
||||
@retval EFI_SUCCESS Create and send the decline message successfully.
|
||||
@retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
|
||||
@retval EFI_DEVICE_ERROR An unexpected error.
|
||||
@retval Others Failed to send the decline message.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
Dhcp6SendDeclineMsg (
|
||||
IN DHCP6_INSTANCE *Instance,
|
||||
IN EFI_DHCP6_IA *DecIa
|
||||
);
|
||||
|
||||
/**
|
||||
Create the release message and send it.
|
||||
|
||||
@param[in] Instance The pointer to the Dhcp6 instance.
|
||||
@param[in] RelIa The pointer to the release Ia.
|
||||
|
||||
@retval EFI_SUCCESS Create and send the release message successfully.
|
||||
@retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
|
||||
@retval EFI_DEVICE_ERROR An unexpected error.
|
||||
@retval Others Failed to send the release message.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
Dhcp6SendReleaseMsg (
|
||||
IN DHCP6_INSTANCE *Instance,
|
||||
IN EFI_DHCP6_IA *RelIa
|
||||
);
|
||||
|
||||
/**
|
||||
Create the information request message and send it.
|
||||
|
||||
@param[in] Instance The pointer to the Dhcp6 instance.
|
||||
@param[in] InfCb The pointer to the information request control block.
|
||||
@param[in] SendClientId If TRUE, the client identifier option will be included in
|
||||
information request message. Otherwise, the client identifier
|
||||
option will not be included.
|
||||
@param[in] OptionRequest The pointer to the option request option.
|
||||
@param[in] OptionCount The number options in the OptionList.
|
||||
@param[in] OptionList The array pointers to the appended options.
|
||||
@param[in] Retransmission The pointer to the retransmission control.
|
||||
|
||||
@retval EFI_SUCCESS Create and send the info-request message successfully.
|
||||
@retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
|
||||
@retval Others Failed to send the info-request message.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
Dhcp6SendInfoRequestMsg (
|
||||
IN DHCP6_INSTANCE *Instance,
|
||||
IN DHCP6_INF_CB *InfCb,
|
||||
IN BOOLEAN SendClientId,
|
||||
IN EFI_DHCP6_PACKET_OPTION *OptionRequest,
|
||||
IN UINT32 OptionCount,
|
||||
IN EFI_DHCP6_PACKET_OPTION *OptionList[],
|
||||
IN EFI_DHCP6_RETRANSMISSION *Retransmission
|
||||
);
|
||||
|
||||
/**
|
||||
The receive callback function for the Dhcp6 exchange process.
|
||||
|
||||
@param[in] Udp6Wrap The pointer to the received net buffer.
|
||||
@param[in] EndPoint The pointer to the udp end point.
|
||||
@param[in] IoStatus The return status from udp io.
|
||||
@param[in] Context The opaque parameter to the function.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
Dhcp6ReceivePacket (
|
||||
IN NET_BUF *Udp6Wrap,
|
||||
IN UDP_END_POINT *EndPoint,
|
||||
IN EFI_STATUS IoStatus,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
/**
|
||||
The timer routine of the Dhcp6 instance for each second.
|
||||
|
||||
@param[in] Event The timer event.
|
||||
@param[in] Context The opaque parameter to the function.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
Dhcp6OnTimerTick (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
#endif
|
1146
NetworkPkg/Dhcp6Dxe/Dhcp6Utility.c
Normal file
1146
NetworkPkg/Dhcp6Dxe/Dhcp6Utility.c
Normal file
File diff suppressed because it is too large
Load Diff
340
NetworkPkg/Dhcp6Dxe/Dhcp6Utility.h
Normal file
340
NetworkPkg/Dhcp6Dxe/Dhcp6Utility.h
Normal file
@@ -0,0 +1,340 @@
|
||||
/** @file
|
||||
Dhcp6 support functions declaration.
|
||||
|
||||
Copyright (c) 2009 - 2010, 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
|
||||
http://opensource.org/licenses/bsd-license.php.
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __EFI_DHCP6_UTILITY_H__
|
||||
#define __EFI_DHCP6_UTILITY_H__
|
||||
|
||||
|
||||
#define DHCP6_10_BIT_MASK 0x3ff
|
||||
|
||||
/**
|
||||
Generate client Duid in the format of Duid-llt.
|
||||
|
||||
@param[in] Mode The pointer to the mode of SNP.
|
||||
|
||||
@retval NULL if failed to generate client Id.
|
||||
@retval Others The pointer to the new client id.
|
||||
|
||||
**/
|
||||
EFI_DHCP6_DUID *
|
||||
Dhcp6GenerateClientId (
|
||||
IN EFI_SIMPLE_NETWORK_MODE *Mode
|
||||
);
|
||||
|
||||
/**
|
||||
Copy the Dhcp6 configure data.
|
||||
|
||||
@param[in] DstCfg The pointer to the destination configure data.
|
||||
@param[in] SorCfg The pointer to the source configure data.
|
||||
|
||||
@retval EFI_SUCCESS Copy the content from SorCfg from DstCfg successfully.
|
||||
@retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
Dhcp6CopyConfigData (
|
||||
IN EFI_DHCP6_CONFIG_DATA *DstCfg,
|
||||
IN EFI_DHCP6_CONFIG_DATA *SorCfg
|
||||
);
|
||||
|
||||
/**
|
||||
Clean up the configure data.
|
||||
|
||||
@param[in, out] CfgData The pointer to the configure data.
|
||||
|
||||
**/
|
||||
VOID
|
||||
Dhcp6CleanupConfigData (
|
||||
IN OUT EFI_DHCP6_CONFIG_DATA *CfgData
|
||||
);
|
||||
|
||||
/**
|
||||
Clean up the mode data.
|
||||
|
||||
@param[in, out] ModeData The pointer to the mode data.
|
||||
|
||||
**/
|
||||
VOID
|
||||
Dhcp6CleanupModeData (
|
||||
IN OUT EFI_DHCP6_MODE_DATA *ModeData
|
||||
);
|
||||
|
||||
/**
|
||||
Calculate the expire time by the algorithm defined in rfc.
|
||||
|
||||
@param[in] Base The base value of the time.
|
||||
@param[in] IsFirstRt If TRUE, it is the first time to calculate expire time.
|
||||
@param[in] NeedSigned If TRUE, the the signed factor is needed.
|
||||
|
||||
@return Expire The calculated result for the new expire time.
|
||||
|
||||
**/
|
||||
UINT32
|
||||
Dhcp6CalculateExpireTime (
|
||||
IN UINT32 Base,
|
||||
IN BOOLEAN IsFirstRt,
|
||||
IN BOOLEAN NeedSigned
|
||||
);
|
||||
|
||||
/**
|
||||
Calculate the lease time by the algorithm defined in rfc.
|
||||
|
||||
@param[in] IaCb The pointer to the Ia control block.
|
||||
|
||||
**/
|
||||
VOID
|
||||
Dhcp6CalculateLeaseTime (
|
||||
IN DHCP6_IA_CB *IaCb
|
||||
);
|
||||
|
||||
/**
|
||||
Check whether the addresses are all included by the configured Ia.
|
||||
|
||||
@param[in] Ia The pointer to the Ia.
|
||||
@param[in] AddressCount The number of addresses.
|
||||
@param[in] Addresses The pointer to the addresses buffer.
|
||||
|
||||
@retval EFI_SUCCESS The addresses are all included by the configured IA.
|
||||
@retval EFI_NOT_FOUND The addresses are not included by the configured IA.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
Dhcp6CheckAddress (
|
||||
IN EFI_DHCP6_IA *Ia,
|
||||
IN UINT32 AddressCount,
|
||||
IN EFI_IPv6_ADDRESS *Addresses
|
||||
);
|
||||
|
||||
/**
|
||||
Deprive the addresses from current Ia, and generate another eliminated Ia.
|
||||
|
||||
@param[in] Ia The pointer to the Ia.
|
||||
@param[in] AddressCount The number of addresses.
|
||||
@param[in] Addresses The pointer to the addresses buffer.
|
||||
|
||||
@retval NULL If failed to generate the deprived Ia.
|
||||
@retval others The pointer to the deprived Ia.
|
||||
|
||||
**/
|
||||
EFI_DHCP6_IA *
|
||||
Dhcp6DepriveAddress (
|
||||
IN EFI_DHCP6_IA *Ia,
|
||||
IN UINT32 AddressCount,
|
||||
IN EFI_IPv6_ADDRESS *Addresses
|
||||
);
|
||||
|
||||
/**
|
||||
The dummy ext buffer free callback routine.
|
||||
|
||||
@param[in] Arg The pointer to the parameter.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
Dhcp6DummyExtFree (
|
||||
IN VOID *Arg
|
||||
);
|
||||
|
||||
/**
|
||||
The callback routine once message transmitted.
|
||||
|
||||
@param[in] Udp6Wrap The pointer to the received net buffer.
|
||||
@param[in] EndPoint The pointer to the udp end point.
|
||||
@param[in] IoStatus The return status from udp io.
|
||||
@param[in] Context The opaque parameter to the function.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
Dhcp6OnTransmitted (
|
||||
IN NET_BUF *Wrap,
|
||||
IN UDP_END_POINT *EndPoint,
|
||||
IN EFI_STATUS IoStatus,
|
||||
IN VOID *Context
|
||||
);
|
||||
|
||||
/**
|
||||
Append the appointed option to the buf, and move the buf to the end.
|
||||
|
||||
@param[in, out] Buf The pointer to buffer.
|
||||
@param[in] OptType The option type.
|
||||
@param[in] OptLen The lenght of option content.s
|
||||
@param[in] Data The pointer to the option content.
|
||||
|
||||
@return Buf The position to append the next option.
|
||||
|
||||
**/
|
||||
UINT8 *
|
||||
Dhcp6AppendOption (
|
||||
IN OUT UINT8 *Buf,
|
||||
IN UINT16 OptType,
|
||||
IN UINT16 OptLen,
|
||||
IN UINT8 *Data
|
||||
);
|
||||
|
||||
/**
|
||||
Append the Ia option to Buf, and move Buf to the end.
|
||||
|
||||
@param[in, out] Buf The pointer to the position to append.
|
||||
@param[in] Ia The pointer to the Ia.
|
||||
@param[in] T1 The time of T1.
|
||||
@param[in] T2 The time of T2.
|
||||
|
||||
@return Buf The position to append the next Ia option.
|
||||
|
||||
**/
|
||||
UINT8 *
|
||||
Dhcp6AppendIaOption (
|
||||
IN OUT UINT8 *Buf,
|
||||
IN EFI_DHCP6_IA *Ia,
|
||||
IN UINT32 T1,
|
||||
IN UINT32 T2
|
||||
);
|
||||
|
||||
/**
|
||||
Append the appointed Elapsed time option to Buf, and move Buf to the end.
|
||||
|
||||
@param[in, out] Buf The pointer to the position to append.
|
||||
@param[in] Instance The pointer to the Dhcp6 instance.
|
||||
@param[out] Elapsed The pointer to the elapsed time value in
|
||||
the generated packet.
|
||||
|
||||
@return Buf The position to append the next Ia option.
|
||||
|
||||
**/
|
||||
UINT8 *
|
||||
Dhcp6AppendETOption (
|
||||
IN OUT UINT8 *Buf,
|
||||
IN DHCP6_INSTANCE *Instance,
|
||||
OUT UINT16 **Elapsed
|
||||
);
|
||||
|
||||
/**
|
||||
Set the elapsed time based on the given instance and the pointer to the
|
||||
elapsed time option.
|
||||
|
||||
@param[in] Elapsed The pointer to the position to append.
|
||||
@param[in] Instance The pointer to the Dhcp6 instance.
|
||||
**/
|
||||
VOID
|
||||
SetElapsedTime (
|
||||
IN UINT16 *Elapsed,
|
||||
IN DHCP6_INSTANCE *Instance
|
||||
);
|
||||
|
||||
/**
|
||||
Seek the address of the first byte of the option header.
|
||||
|
||||
@param[in] Buf The pointer to buffer.
|
||||
@param[in] SeekLen The length to seek.
|
||||
@param[in] OptType The option type.
|
||||
|
||||
@retval NULL If failed to seek the option.
|
||||
@retval others The position to the option.
|
||||
|
||||
**/
|
||||
UINT8 *
|
||||
Dhcp6SeekOption (
|
||||
IN UINT8 *Buf,
|
||||
IN UINT32 SeekLen,
|
||||
IN UINT16 OptType
|
||||
);
|
||||
|
||||
/**
|
||||
Seek the address of the first byte of the Ia option header.
|
||||
|
||||
@param[in] Buf The pointer to the buffer.
|
||||
@param[in] SeekLen The length to seek.
|
||||
@param[in] IaDesc The pointer to the Ia descriptor.
|
||||
|
||||
@retval NULL If failed to seek the Ia option.
|
||||
@retval others The position to the Ia option.
|
||||
|
||||
**/
|
||||
UINT8 *
|
||||
Dhcp6SeekIaOption (
|
||||
IN UINT8 *Buf,
|
||||
IN UINT32 SeekLen,
|
||||
IN EFI_DHCP6_IA_DESCRIPTOR *IaDesc
|
||||
);
|
||||
|
||||
/**
|
||||
Parse the address option and update the address info.
|
||||
|
||||
@param[in] IaInnerOpt The pointer to the buffer.
|
||||
@param[in] IaInnerLen The length to parse.
|
||||
@param[out] AddrNum The number of addresses.
|
||||
@param[in, out] AddrBuf The pointer to the address buffer.
|
||||
|
||||
**/
|
||||
VOID
|
||||
Dhcp6ParseAddrOption (
|
||||
IN UINT8 *IaInnerOpt,
|
||||
IN UINT16 IaInnerLen,
|
||||
OUT UINT32 *AddrNum,
|
||||
IN OUT EFI_DHCP6_IA_ADDRESS *AddrBuf
|
||||
);
|
||||
|
||||
/**
|
||||
Create a control blcok for the Ia according to the corresponding options.
|
||||
|
||||
@param[in] Instance The pointer to DHCP6 Instance.
|
||||
@param[in] IaInnerOpt The pointer to the inner options in the Ia option.
|
||||
@param[in] IaInnerLen The length of all the inner options in the Ia option.
|
||||
@param[in] T1 T1 time in the Ia option.
|
||||
@param[in] T2 T2 time in the Ia option.
|
||||
|
||||
@retval EFI_NOT_FOUND No valid IA option is found.
|
||||
@retval EFI_SUCCESS Create an IA control block successfully.
|
||||
@retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
Dhcp6GenerateIaCb (
|
||||
IN DHCP6_INSTANCE *Instance,
|
||||
IN UINT8 *IaInnerOpt,
|
||||
IN UINT16 IaInnerLen,
|
||||
IN UINT32 T1,
|
||||
IN UINT32 T2
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Cache the current IA configuration information.
|
||||
|
||||
@param[in] Instance The pointer to DHCP6 Instance.
|
||||
|
||||
@retval EFI_SUCCESS Cache the current IA successfully.
|
||||
@retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
Dhcp6CacheIa (
|
||||
IN DHCP6_INSTANCE *Instance
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
Append CacheIa to the currrent IA. Meanwhile, clear CacheIa.ValidLifetime to 0.
|
||||
|
||||
@param[in] Instance The pointer to DHCP6 instance.
|
||||
|
||||
**/
|
||||
VOID
|
||||
Dhcp6AppendCacheIa (
|
||||
IN DHCP6_INSTANCE *Instance
|
||||
);
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user