Driver Binding functions and Service Binding functions\r
implementationfor for Dhcp6 Driver.\r
\r
- Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>\r
\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
)\r
{\r
DHCP6_SERVICE *Dhcp6Srv;\r
+ EFI_STATUS Status;\r
\r
*Service = NULL;\r
Dhcp6Srv = AllocateZeroPool (sizeof (DHCP6_SERVICE));\r
sizeof (EFI_SERVICE_BINDING_PROTOCOL)\r
);\r
\r
+ //\r
+ // Locate Ip6->Ip6Config and store it for get IP6 Duplicate Address Detection transmits.\r
+ //\r
+ Status = gBS->HandleProtocol (\r
+ Controller,\r
+ &gEfiIp6ConfigProtocolGuid,\r
+ (VOID **) &Dhcp6Srv->Ip6Cfg\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ FreePool (Dhcp6Srv);\r
+ return Status;\r
+ }\r
+\r
//\r
// Generate client Duid: If SMBIOS system UUID is located, generate DUID in DUID-UUID format.\r
// Otherwise, in DUID-LLT format.\r
## @file\r
# Component description file for Dhcp6 module.\r
#\r
-# Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>\r
#\r
# This program and the accompanying materials\r
# are licensed and made available under the terms and conditions of the BSD License\r
gEfiUdp6ProtocolGuid\r
gEfiDhcp6ServiceBindingProtocolGuid\r
gEfiDhcp6ProtocolGuid\r
-\r
+ gEfiIp6ConfigProtocolGuid\r
)\r
{\r
EFI_STATUS Status;\r
- EFI_TPL OldTpl;\r
DHCP6_INSTANCE *Instance;\r
DHCP6_SERVICE *Service;\r
- DHCP6_INF_CB *InfCb;\r
UINTN Index;\r
+ EFI_EVENT Timer;\r
+ EFI_STATUS TimerStatus;\r
+ UINTN GetMappingTimeOut;\r
\r
if (This == NULL || OptionRequest == NULL || Retransmission == NULL || ReplyCallback == NULL) {\r
return EFI_INVALID_PARAMETER;\r
Instance = DHCP6_INSTANCE_FROM_THIS (This);\r
Service = Instance->Service;\r
\r
- OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
- Instance->UdpSts = EFI_ALREADY_STARTED;\r
-\r
- //\r
- // Create and initialize the control block for the info-request.\r
- //\r
- InfCb = AllocateZeroPool (sizeof(DHCP6_INF_CB));\r
-\r
- if (InfCb == NULL) {\r
- gBS->RestoreTPL (OldTpl);\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
-\r
- InfCb->ReplyCallback = ReplyCallback;\r
- InfCb->CallbackContext = CallbackContext;\r
- InfCb->TimeoutEvent = TimeoutEvent;\r
-\r
- InsertTailList (&Instance->InfList, &InfCb->Link);\r
-\r
- //\r
- // Send the info-request message to start exchange process.\r
- //\r
- Status = Dhcp6SendInfoRequestMsg (\r
+ Status = Dhcp6StartInfoRequest (\r
Instance,\r
- InfCb,\r
SendClientId,\r
OptionRequest,\r
OptionCount,\r
OptionList,\r
- Retransmission\r
+ Retransmission,\r
+ TimeoutEvent,\r
+ ReplyCallback,\r
+ CallbackContext\r
);\r
+ if (Status == EFI_NO_MAPPING) {\r
+ //\r
+ // The link local address is not ready, wait for some time and restart\r
+ // the DHCP6 information request process.\r
+ //\r
+ Status = Dhcp6GetMappingTimeOut(Service->Ip6Cfg, &GetMappingTimeOut);\r
+ if (EFI_ERROR(Status)) {\r
+ return Status;\r
+ }\r
\r
- if (EFI_ERROR (Status)) {\r
- goto ON_ERROR;\r
- }\r
+ Status = gBS->CreateEvent (EVT_TIMER, TPL_CALLBACK, NULL, NULL, &Timer);\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
\r
- //\r
- // Register receive callback for the stateless exchange process.\r
- //\r
- Status = UdpIoRecvDatagram(\r
- Service->UdpIo,\r
- Dhcp6ReceivePacket,\r
- Service,\r
- 0\r
- );\r
+ //\r
+ // Start the timer, wait for link local address DAD to finish.\r
+ //\r
+ Status = gBS->SetTimer (Timer, TimerRelative, GetMappingTimeOut);\r
+ if (EFI_ERROR (Status)) {\r
+ gBS->CloseEvent (Timer);\r
+ return Status;\r
+ }\r
\r
- if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {\r
- goto ON_ERROR;\r
+ do { \r
+ TimerStatus = gBS->CheckEvent (Timer);\r
+ if (!EFI_ERROR (TimerStatus)) {\r
+ Status = Dhcp6StartInfoRequest (\r
+ Instance,\r
+ SendClientId,\r
+ OptionRequest,\r
+ OptionCount,\r
+ OptionList,\r
+ Retransmission,\r
+ TimeoutEvent,\r
+ ReplyCallback,\r
+ CallbackContext\r
+ );\r
+ }\r
+ } while (TimerStatus == EFI_NOT_READY);\r
+ \r
+ gBS->CloseEvent (Timer);\r
+ }\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
}\r
-\r
- gBS->RestoreTPL (OldTpl);\r
\r
//\r
// Poll udp out of the net tpl if synchoronus call.\r
}\r
\r
return EFI_SUCCESS;\r
-\r
-ON_ERROR:\r
-\r
- RemoveEntryList (&InfCb->Link);\r
- FreePool (InfCb);\r
- gBS->RestoreTPL (OldTpl);\r
-\r
- return Status;\r
}\r
\r
\r
/** @file\r
Dhcp6 internal data structure and definition declaration.\r
\r
- Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>\r
\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
\r
#include <Protocol/Dhcp6.h>\r
#include <Protocol/Udp6.h>\r
+#include <Protocol/Ip6Config.h>\r
#include <Protocol/ServiceBinding.h>\r
#include <Protocol/DriverBinding.h>\r
\r
EFI_HANDLE Image;\r
EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;\r
EFI_SIMPLE_NETWORK_PROTOCOL *Snp;\r
+ EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg;\r
EFI_DHCP6_DUID *ClientId;\r
UDP_IO *UdpIo;\r
UINT32 Xid;\r
/** @file\r
Dhcp6 internal functions implementation.\r
\r
- Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>\r
\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
return Dhcp6EnqueueRetry (Instance, Packet, Elapsed, NULL);\r
}\r
\r
+/**\r
+ Start the information request process.\r
+\r
+ @param[in] Instance The pointer to the Dhcp6 instance.\r
+ @param[in] SendClientId If TRUE, the client identifier option will be included in\r
+ information request message. Otherwise, the client identifier\r
+ option will not be included.\r
+ @param[in] OptionRequest The pointer to the option request option.\r
+ @param[in] OptionCount The number options in the OptionList.\r
+ @param[in] OptionList The array pointers to the appended options.\r
+ @param[in] Retransmission The pointer to the retransmission control.\r
+ @param[in] TimeoutEvent The event of timeout.\r
+ @param[in] ReplyCallback The callback function when the reply was received.\r
+ @param[in] CallbackContext The pointer to the parameter passed to the callback.\r
+\r
+ @retval EFI_SUCCESS Start the info-request process successfully.\r
+ @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.\r
+ @retval EFI_NO_MAPPING No source address is available for use.\r
+ @retval Others Failed to start the info-request process.\r
+\r
+**/\r
+EFI_STATUS\r
+Dhcp6StartInfoRequest (\r
+ IN DHCP6_INSTANCE *Instance,\r
+ IN BOOLEAN SendClientId,\r
+ IN EFI_DHCP6_PACKET_OPTION *OptionRequest,\r
+ IN UINT32 OptionCount,\r
+ IN EFI_DHCP6_PACKET_OPTION *OptionList[] OPTIONAL,\r
+ IN EFI_DHCP6_RETRANSMISSION *Retransmission,\r
+ IN EFI_EVENT TimeoutEvent OPTIONAL,\r
+ IN EFI_DHCP6_INFO_CALLBACK ReplyCallback,\r
+ IN VOID *CallbackContext OPTIONAL\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ DHCP6_INF_CB *InfCb;\r
+ DHCP6_SERVICE *Service;\r
+ EFI_TPL OldTpl;\r
+\r
+ Service = Instance->Service;\r
+\r
+ OldTpl = gBS->RaiseTPL (TPL_CALLBACK);\r
+ Instance->UdpSts = EFI_ALREADY_STARTED;\r
+ //\r
+ // Create and initialize the control block for the info-request.\r
+ //\r
+ InfCb = AllocateZeroPool (sizeof(DHCP6_INF_CB));\r
+\r
+ if (InfCb == NULL) {\r
+ gBS->RestoreTPL (OldTpl);\r
+ return EFI_OUT_OF_RESOURCES;\r
+ }\r
+\r
+ InfCb->ReplyCallback = ReplyCallback;\r
+ InfCb->CallbackContext = CallbackContext;\r
+ InfCb->TimeoutEvent = TimeoutEvent;\r
+\r
+ InsertTailList (&Instance->InfList, &InfCb->Link);\r
+\r
+ //\r
+ // Send the info-request message to start exchange process.\r
+ //\r
+ Status = Dhcp6SendInfoRequestMsg (\r
+ Instance,\r
+ InfCb,\r
+ SendClientId,\r
+ OptionRequest,\r
+ OptionCount,\r
+ OptionList,\r
+ Retransmission\r
+ );\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ goto ON_ERROR;\r
+ }\r
+\r
+ //\r
+ // Register receive callback for the stateless exchange process.\r
+ //\r
+ Status = UdpIoRecvDatagram(\r
+ Service->UdpIo,\r
+ Dhcp6ReceivePacket,\r
+ Service,\r
+ 0\r
+ );\r
+\r
+ if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {\r
+ goto ON_ERROR;\r
+ }\r
+ \r
+ gBS->RestoreTPL (OldTpl);\r
+ return EFI_SUCCESS;\r
+ \r
+ON_ERROR:\r
+ gBS->RestoreTPL (OldTpl); \r
+ RemoveEntryList (&InfCb->Link);\r
+ FreePool (InfCb);\r
+\r
+ return Status;\r
+}\r
\r
/**\r
Create the information request message and send it.\r
/** @file\r
Dhcp6 internal functions declaration.\r
\r
- Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>\r
\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
IN EFI_DHCP6_IA *RelIa\r
);\r
\r
+/**\r
+ Start the information request process.\r
+\r
+ @param[in] Instance The pointer to the Dhcp6 instance.\r
+ @param[in] SendClientId If TRUE, the client identifier option will be included in\r
+ information request message. Otherwise, the client identifier\r
+ option will not be included.\r
+ @param[in] OptionRequest The pointer to the option request option.\r
+ @param[in] OptionCount The number options in the OptionList.\r
+ @param[in] OptionList The array pointers to the appended options.\r
+ @param[in] Retransmission The pointer to the retransmission control.\r
+ @param[in] TimeoutEvent The event of timeout.\r
+ @param[in] ReplyCallback The callback function when the reply was received.\r
+ @param[in] CallbackContext The pointer to the parameter passed to the callback.\r
+\r
+ @retval EFI_SUCCESS Start the info-request process successfully.\r
+ @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.\r
+ @retval EFI_NO_MAPPING No source address is available for use.\r
+ @retval Others Failed to start the info-request process.\r
+\r
+**/\r
+EFI_STATUS\r
+Dhcp6StartInfoRequest (\r
+ IN DHCP6_INSTANCE *Instance,\r
+ IN BOOLEAN SendClientId,\r
+ IN EFI_DHCP6_PACKET_OPTION *OptionRequest,\r
+ IN UINT32 OptionCount,\r
+ IN EFI_DHCP6_PACKET_OPTION *OptionList[] OPTIONAL,\r
+ IN EFI_DHCP6_RETRANSMISSION *Retransmission,\r
+ IN EFI_EVENT TimeoutEvent OPTIONAL,\r
+ IN EFI_DHCP6_INFO_CALLBACK ReplyCallback,\r
+ IN VOID *CallbackContext OPTIONAL\r
+ );\r
+\r
/**\r
Create the information request message and send it.\r
\r
Instance->IaCb.Ia = NewIa;\r
}\r
}\r
+\r
+/**\r
+ Calculate the Dhcp6 get mapping timeout by adding additinal delay to the IP6 DAD transmits count.\r
+\r
+ @param[in] Ip6Cfg The pointer to Ip6 config protocol.\r
+ @param[out] TimeOut The time out value in 100ns units.\r
+\r
+ @retval EFI_INVALID_PARAMETER Input parameters are invalid.\r
+ @retval EFI_SUCCESS Calculate the time out value successfully.\r
+**/\r
+EFI_STATUS\r
+Dhcp6GetMappingTimeOut (\r
+ IN EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg,\r
+ OUT UINTN *TimeOut\r
+ ) \r
+{\r
+ EFI_STATUS Status;\r
+ UINTN DataSize;\r
+ EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS DadXmits;\r
+\r
+ if (Ip6Cfg == NULL || TimeOut == NULL) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ DataSize = sizeof (EFI_IP6_CONFIG_DUP_ADDR_DETECT_TRANSMITS);\r
+ Status = Ip6Cfg->GetData (\r
+ Ip6Cfg,\r
+ Ip6ConfigDataTypeDupAddrDetectTransmits,\r
+ &DataSize,\r
+ &DadXmits\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+ \r
+ *TimeOut = TICKS_PER_SECOND * DadXmits.DupAddrDetectTransmits + DHCP6_DAD_ADDITIONAL_DELAY;\r
+ \r
+ return EFI_SUCCESS;\r
+}\r
/** @file\r
Dhcp6 support functions declaration.\r
\r
- Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>\r
\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
#define __EFI_DHCP6_UTILITY_H__\r
\r
\r
-#define DHCP6_10_BIT_MASK 0x3ff\r
+#define DHCP6_10_BIT_MASK 0x3ff\r
+#define DHCP6_DAD_ADDITIONAL_DELAY 30000000 // 3 seconds\r
\r
/**\r
Generate client Duid in the format of Duid-llt.\r
IN DHCP6_INSTANCE *Instance\r
);\r
\r
+/**\r
+ Calculate the Dhcp6 get mapping timeout by adding additinal delay to the IP6 DAD transmits count.\r
+\r
+ @param[in] Ip6Cfg The pointer to Ip6 config protocol.\r
+ @param[out] TimeOut The time out value in 100ns units.\r
+\r
+ @retval EFI_INVALID_PARAMETER Input parameters are invalid.\r
+ @retval EFI_SUCCESS Calculate the time out value successfully.\r
+**/\r
+EFI_STATUS\r
+Dhcp6GetMappingTimeOut (\r
+ IN EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg,\r
+ OUT UINTN *TimeOut\r
+ );\r
#endif\r