/** @file
Dhcp6 internal functions implementation.
Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "Dhcp6Impl.h"
/**
Enqueue the packet into the retry list in case of timeout.
@param[in] Instance The pointer to the Dhcp6 instance.
@param[in] Packet The pointer to the Dhcp6 packet to retry.
@param[in] Elapsed The pointer to the elapsed time value in the packet.
@param[in] RetryCtl The pointer to the transmission control of the packet.
This parameter is optional and may be NULL.
@retval EFI_SUCCESS Successfully enqueued the packet into the retry list according
to its message type.
@retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
@retval EFI_DEVICE_ERROR An unexpected message type.
**/
)
{
return EFI_OUT_OF_RESOURCES;
}
//
// Save tx packet pointer, and it will be destoryed when reply received.
//
//
// Save pointer to elapsed-time value so we can update it on retransmits.
//
//
// Calculate the retransmission according to the the message type.
//
case Dhcp6MsgSolicit:
//
// Calculate the retransmission threshold value for solicit packet.
// Use the default value by rfc-3315 if user doesn't configure.
//
} else {
}
TRUE,
);
break;
case Dhcp6MsgRequest:
//
// Calculate the retransmission threshold value for request packet.
//
TRUE,
);
break;
case Dhcp6MsgConfirm:
//
// Calculate the retransmission threshold value for confirm packet.
//
TRUE,
);
break;
case Dhcp6MsgRenew:
//
// Calculate the retransmission threshold value for renew packet.
//
TRUE,
);
break;
case Dhcp6MsgRebind:
//
// Calculate the retransmission threshold value for rebind packet.
//
TRUE,
);
break;
case Dhcp6MsgDecline:
//
// Calculate the retransmission threshold value for decline packet.
//
TRUE,
);
break;
case Dhcp6MsgRelease:
//
// Calculate the retransmission threshold value for release packet.
//
TRUE,
);
break;
case Dhcp6MsgInfoRequest:
//
// Calculate the retransmission threshold value for info-request packet.
// Use the default value by rfc-3315 if user doesn't configure.
//
} else {
}
TRUE,
);
break;
default:
//
// Unexpected message type.
//
return EFI_DEVICE_ERROR;
}
//
// Insert into the retransmit list of the instance.
//
return EFI_SUCCESS;
}
/**
Dequeue the packet from retry list if reply received or timeout at last.
@param[in] Instance The pointer to the Dhcp6 instance.
@param[in] PacketXid The packet transaction id to match.
@param[in] NeedSignal If TRUE, then an timeout event need be signaled when it is existed.
Otherwise, this parameter is ignored.
@retval EFI_SUCCESS Successfully dequeued the packet into retry list .
@retval EFI_NOT_FOUND There is no xid matched in retry list.
**/
)
{
//
// Seek the retransmit node in the retransmit list by packet xid.
//
//
// Seek the info-request node in the info-request list by packet xid.
//
//
// Remove the info-request node, and signal the event if timeout.
//
}
}
}
}
//
// Remove the retransmit node.
//
return EFI_SUCCESS;
}
}
return EFI_NOT_FOUND;
}
/**
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.
**/
)
{
//
// Clean up all the stateful messages from the retransmit list.
//
}
}
}
//
// Clean up all the stateless messages from the retransmit list.
//
//
// Clean up all the retransmit list for stateless messages.
//
}
}
//
// Clean up all the info-request messages list.
//
}
}
}
}
/**
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.
**/
)
{
//
// Clean up the retransmit list for stateful messages.
//
}
}
}
//
// Reinitialize the Ia fields of the instance.
//
//
// Clear start time
//
//
// Set the addresses as zero lifetime, and then the notify
// function in Ip6Config will remove these timeout address.
//
}
//
//
// Signal the Ia information updated event to informal user.
//
}
}
/**
@param[in] Instance The pointer to the Dhcp6 instance.
@param[in] Event The current Dhcp6 event.
@param[in, out] Packet The pointer to the packet sending or received.
@retval EFI_SUCCESS The user function returns success.
@retval EFI_NOT_READY Direct the caller to continue collecting the offer.
@retval EFI_ABORTED The user function ask it to abort.
**/
)
{
//
// Callback to user with the new message if has.
//
*Packet,
);
//
// Updated the new packet from user to replace the original one.
//
}
}
return Status;
}
/**
Update Ia according to the new reply message.
@param[in, out] Instance The pointer to the Dhcp6 instance.
@param[in] Packet The pointer to reply messages.
@retval EFI_SUCCESS Updated the Ia information successfully.
@retval EFI_DEVICE_ERROR An unexpected error.
**/
)
{
//
// If the reply was received in reponse to a solicit with rapid commit option,
// request, renew or rebind message, the client updates the information it has
// recorded about IAs from the IA options contained in the reply message:
// 1. record the T1 and T2 times
// 2. add any new addresses in the IA
// 3. discard any addresses from the IA, that have a valid lifetime of 0
// 4. update lifetimes for any addresses that alread recorded
// 5. leave unchanged any information about addresses
//
// See details in the section-18.1.8 of rfc-3315.
//
);
return EFI_DEVICE_ERROR;
}
//
// The format of the IA_NA option is:
//
// 0 1 2 3
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | OPTION_IA_NA | option-len |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | IAID (4 octets) |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | T1 |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | T2 |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | |
// . IA_NA-options .
// . .
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
//
// The format of the IA_TA option is:
//
// 0 1 2 3
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | OPTION_IA_TA | option-len |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | IAID (4 octets) |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | |
// . IA_TA-options .
// . .
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
//
//
// sizeof (option-code + option-len + IaId) = 8
// sizeof (option-code + option-len + IaId + T1) = 12
// sizeof (option-code + option-len + IaId + T1 + T2) = 16
//
// The inner options still start with 2 bytes option-code and 2 bytes option-len.
//
} else {
T1 = 0;
T2 = 0;
}
//
// The format of the Status Code option is:
//
// 0 1 2 3
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | OPTION_STATUS_CODE | option-len |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | status-code | |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
// . .
// . status-message .
// . .
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
//
//
// sizeof (option-code + option-len) = 4
//
if (StsCode != Dhcp6StsSuccess) {
return EFI_DEVICE_ERROR;
}
}
//
// Generate control block for the Ia.
//
T1,
);
return Status;
}
/**
Seek StatusCode Option in package. A Status Code option may appear in the
See details in section 22.13, RFC3315.
@param[in] Instance The pointer to the Dhcp6 instance.
@param[in] Packet The pointer to reply messages.
@param[out] Option The pointer to status code option.
@retval EFI_SUCCESS Seek status code option successfully.
@retval EFI_DEVICE_ERROR An unexpected error.
**/
)
{
//
// Seek StatusCode option directly in DHCP message body. That is, search in
// non-encapsulated option fields.
//
*Option = Dhcp6SeekOption (
);
if (StsCode != Dhcp6StsSuccess) {
return EFI_DEVICE_ERROR;
}
}
//
// Seek in encapsulated options, IA_NA and IA_TA.
//
*Option = Dhcp6SeekIaOption (
);
return EFI_DEVICE_ERROR;
}
//
// The format of the IA_NA option is:
//
// 0 1 2 3
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | OPTION_IA_NA | option-len |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | IAID (4 octets) |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | T1 |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | T2 |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | |
// . IA_NA-options .
// . .
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
//
// The format of the IA_TA option is:
//
// 0 1 2 3
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | OPTION_IA_TA | option-len |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | IAID (4 octets) |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | |
// . IA_TA-options .
// . .
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
//
//
// sizeof (option-code + option-len + IaId) = 8
// sizeof (option-code + option-len + IaId + T1) = 12
// sizeof (option-code + option-len + IaId + T1 + T2) = 16
//
// The inner options still start with 2 bytes option-code and 2 bytes option-len.
//
} else {
}
//
// The format of the Status Code option is:
//
// 0 1 2 3
// 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | OPTION_STATUS_CODE | option-len |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
// | status-code | |
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
// . .
// . status-message .
// . .
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
//
//
// sizeof (option-code + option-len) = 4
//
if (StsCode != Dhcp6StsSuccess) {
return EFI_DEVICE_ERROR;
}
}
return EFI_SUCCESS;
}
/**
Transmit Dhcp6 message by udpio.
@param[in] Instance The pointer to the Dhcp6 instance.
@param[in] Packet The pointer to transmit message.
@param[in] Elapsed The pointer to the elapsed time value to fill in.
@retval EFI_SUCCESS Successfully transmitted the packet.
@retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
@retval Others Failed to transmit the packet.
**/
)
{
//
// Wrap it into a netbuf then send it.
//
//
// Do not register free packet here, which will be handled in retry list.
//
return EFI_OUT_OF_RESOURCES;
}
//
// Multicast the Dhcp6 message, unless get the unicast server address by option.
//
CopyMem (
sizeof (EFI_IPv6_ADDRESS)
);
} else {
CopyMem (
sizeof (EFI_IPv6_ADDRESS)
);
}
//
// Update the elapsed time value.
//
}
//
// Send out the message by the configured Udp6Io.
//
Wrap,
&EndPt,
NULL,
);
NetbufFree (Wrap);
return Status;
}
return EFI_SUCCESS;
}
/**
Create the solicit message and send it.
@param[in] Instance The pointer to the Dhcp6 instance.
@retval EFI_SUCCESS Created and sent the solicit message successfully.
@retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
@retval Others Failed to send the solicit message.
**/
)
{
UserLen = 0;
//
// Calculate the added length of customized option list.
//
}
//
// Create the Dhcp6 packet and initialize commone fields.
//
return EFI_OUT_OF_RESOURCES;
}
//
// Assembly Dhcp6 options for solicit message.
//
);
);
);
//
// Append user-defined when configurate Dhcp6 service.
//
);
}
//
//
//
// Callback to user with the packet to be sent and check the user's feedback.
//
return Status;
}
//
// Send solicit packet with the state transition from Dhcp6init to
// Dhcp6selecting.
//
return Status;
}
//
// Enqueue the sent packet for the retransmission in case reply timeout.
//
return Dhcp6EnqueueRetry (
);
}
/**
Configure some parameter to initiate SolicitMsg.
@param[in] Instance The pointer to the Dhcp6 instance.
@retval EFI_SUCCESS Created and sent the solicit message successfully.
@retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
@retval Others Failed to send the solicit message.
**/
)
{
return Dhcp6SendSolicitMsg (Instance);
}
/**
Create the request message and send it.
@param[in] Instance The pointer to the Dhcp6 instance.
@retval EFI_SUCCESS Created and sent 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.
**/
)
{
//
// Get the server Id from the selected advertisement message.
//
);
return EFI_DEVICE_ERROR;
}
//
// Calculate the added length of customized option list.
//
UserLen = 0;
}
//
// Create the Dhcp6 packet and initialize commone fields.
//
return EFI_OUT_OF_RESOURCES;
}
//
// Assembly Dhcp6 options for request message.
//
);
);
);
);
//
// Append user-defined when configurate Dhcp6 service.
//
);
}
//
//
//
// Callback to user with the packet to be sent and check the user's feedback.
//
return Status;
}
//
// Send request packet with the state transition from Dhcp6selecting to
// Dhcp6requesting.
//
return Status;
}
//
// Enqueue the sent packet for the retransmission in case reply timeout.
//
}
/**
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 Created and sent 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.
**/
)
{
//
// Get the server Id from the last reply message.
//
);
return EFI_DEVICE_ERROR;
}
//
// EFI_DHCP6_DUID contains a length field of 2 bytes.
//
//
// Create the Dhcp6 packet and initialize commone fields.
//
return EFI_OUT_OF_RESOURCES;
}
//
//
);
);
);
//
//
//
// Callback to user with the packet to be sent and check the user's feedback.
//
return Status;
}
//
// Send decline packet with the state transition from Dhcp6bound to
// Dhcp6declining.
//
return Status;
}
//
// Enqueue the sent packet for the retransmission in case reply timeout.
//
}
/**
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 Created and sent 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.
**/
)
{
//
// Get the server Id from the last reply message.
//
);
return EFI_DEVICE_ERROR;
}
//
// Create the Dhcp6 packet and initialize commone fields.
//
return EFI_OUT_OF_RESOURCES;
}
//
//
);
//
// ServerId is extracted from packet, it's network order.
//
);
);
//
//
//
// Callback to user with the packet to be sent and check the user's feedback.
//
return Status;
}
//
// Send release packet with the state transition from Dhcp6bound to
// Dhcp6releasing.
//
return Status;
}
//
// Enqueue the sent packet for the retransmission in case reply timeout.
//
}
/**
@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_OUT_OF_RESOURCES Required system resources could not be allocated.
@retval EFI_DEVICE_ERROR An unexpected error.
**/
)
{
//
// Calculate the added length of customized option list.
//
UserLen = 0;
}
//
// Create the Dhcp6 packet and initialize commone fields.
//
return EFI_OUT_OF_RESOURCES;
}
//
//
);
);
);
if (!RebindRequest) {
//
// Get the server Id from the last reply message and
// insert it for rebind request.
//
);
return EFI_DEVICE_ERROR;
}
);
}
//
// Append user-defined when configurate Dhcp6 service.
//
);
}
//
//
//
// Callback to user with the packet to be sent and check the user's feedback.
//
return Status;
}
//
// Dhcp6renew/rebind.
//
return Status;
}
//
// Enqueue the sent packet for the retransmission in case reply timeout.
//
}
/**
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 Created and sent 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.
**/
)
{
//
// Calculate the added length of customized option list.
//
}
//
// Create the Dhcp6 packet and initialize commone fields.
//
return EFI_OUT_OF_RESOURCES;
}
//
// Assembly Dhcp6 options for info-request message.
//
if (SendClientId) {
);
}
);
);
//
// Append user-defined when configurate Dhcp6 service.
//
);
}
//
//
//
// Send info-request packet with no state.
//
return Status;
}
//
// Enqueue the sent packet for the retransmission in case reply timeout.
//
}
/**
Create the Confirm message and send it.
@param[in] Instance The pointer to the Dhcp6 instance.
@retval EFI_SUCCESS Created and sent the confirm 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 confirm message.
**/
)
{
//
// Calculate the added length of customized option list.
//
UserLen = 0;
}
//
// Create the Dhcp6 packet and initialize common fields.
//
return EFI_OUT_OF_RESOURCES;
}
//
// Assembly Dhcp6 options for solicit message.
//
);
);
);
//
// Append user-defined when configurate Dhcp6 service.
//
);
}
//
//
//
// Callback to user with the packet to be sent and check the user's feedback.
//
return Status;
}
//
// Send confirm packet with the state transition from Dhcp6Bound to
// Dhcp6Confirming.
//
return Status;
}
//
// Enqueue the sent packet for the retransmission in case reply timeout.
//
}
/**
Handle with the Dhcp6 reply message.
@param[in] Instance The pointer to Dhcp6 instance.
@param[in] Packet The pointer to the Dhcp6 reply message.
@retval EFI_SUCCESS Processed the reply 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 process the reply message.
**/
)
{
return EFI_DEVICE_ERROR;
}
//
// If the client subsequently receives a valid reply message that includes a
// rapid commit option since send a solicit with rapid commit option before,
// preocess the reply message and discard any reply messages received in
// response to the request message.
// See details in the section-17.1.4 of rfc-3315.
//
);
if ((Option != NULL && !Instance->Config->RapidCommit) || (Option == NULL && Instance->Config->RapidCommit)) {
return EFI_DEVICE_ERROR;
}
//
// ignore the packet if not contains the Ia option
//
) {
);
return EFI_DEVICE_ERROR;
}
}
//
// Callback to user with the received packet and check the user's feedback.
//
return Status;
}
//
// Dequeue the sent packet from retransmit list since reply received.
//
);
return Status;
}
//
// status code.
//
} else {
}
//
//
//
// For async, signal the Ia event to inform Ia infomation update.
//
}
//
// Reset start time for next exchange.
//
return EFI_SUCCESS;
}
//
// Upon the receipt of a valid reply packet in response to a solicit, request,
// confirm, renew and rebind, the behavior depends on the status code option.
// See the details in the section-18.1.8 of rfc-3315.
//
);
//
// Reset start time for next exchange.
//
//
// No status code or no error status code means succeed to reply.
//
return Status;
}
//
// Set bound state and store the reply packet.
//
}
return EFI_OUT_OF_RESOURCES;
}
//
// For sync, set the success flag out of polling in start/renewrebind.
//
//
// Maybe this is a new round DHCP process due to some reason, such as NotOnLink
// ReplyMsg for ConfirmMsg should triger new round to acquire new address. In that
// case, clear old address.ValidLifetime and append to new address. Therefore, DHCP
// consumers can be notified to flush old address.
//
//
// For async, signal the Ia event to inform Ia infomation update.
//
}
//
// Any error status code option is found.
//
switch (StsCode) {
case Dhcp6StsUnspecFail:
//
// It indicates the server is unable to process the message due to an
// unspecified failure condition, so just retry if possible.
//
break;
case Dhcp6StsUseMulticast:
//
// It indicates the server receives a message via unicast from a client
// to which the server has not sent a unicast option, so retry it by
// multi-cast address.
//
}
break;
case Dhcp6StsNotOnLink:
//
// Before initiate new round DHCP, cache the current IA.
//
return Status;
}
//
// Restart S.A.R.R process to acquire new address.
//
return Status;
}
}
break;
default:
//
// The other status code, just restart solicitation.
//
break;
}
}
return EFI_SUCCESS;
}
/**
Select the appointed Dhcp6 advertisement message.
@param[in] Instance The pointer to the Dhcp6 instance.
@param[in] AdSelect The pointer to the selected Dhcp6 advertisement message.
@retval EFI_SUCCESS Selected the right advertisement message successfully.
@retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated.
@retval Others Failed to select the advertise message.
**/
)
{
//
// Callback to user with the selected advertisement packet, and the user
// might overwrite it.
//
return Status;
}
//
// Dequeue the sent packet for the retransmission since advertisement selected.
//
);
return Status;
}
//
// Check whether there is server unicast option in the selected advertise
// packet, and update it.
//
);
return EFI_OUT_OF_RESOURCES;
}
}
//
// Update the information of the Ia by the selected advertisement message.
//
return Status;
}
//
// Send the request message to continue the S.A.R.R. process.
//
return Dhcp6SendRequestMsg (Instance);
}
/**
Handle with the Dhcp6 advertisement message.
@param[in] Instance The pointer to the Dhcp6 instance.
@param[in] Packet The pointer to the Dhcp6 advertisement message.
@retval EFI_SUCCESS Processed the advertisement 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 process the advertise message.
**/
)
{
//
// If the client does receives a valid reply message that includes a rapid
// commit option since a solicit with rapid commit optioin sent before, select
// this reply message. Or else, process the advertise messages as normal.
// See details in the section-17.1.4 of rfc-3315.
//
);
if (Option != NULL && Instance->Config->RapidCommit && Packet->Dhcp6.Header.MessageType == Dhcp6MsgReply) {
}
return EFI_DEVICE_ERROR;
}
//
// Client must ignore any advertise message that includes a status code option
// containing the value noaddrsavail, with the exception that the client may
// display the associated status message to the user.
// See the details in the section-17.1.3 of rfc-3315.
//
);
if (StsCode != Dhcp6StsSuccess) {
return EFI_DEVICE_ERROR;
}
}
//
// Callback to user with the received packet and check the user's feedback.
//
//
// Success means user choose the current advertisement packet.
//
}
//
// Store the selected advertisement packet and set a flag.
//
return EFI_OUT_OF_RESOURCES;
}
} else if (Status == EFI_NOT_READY) {
//
// Not_ready means user wants to continue to receive more advertise packets.
//
//
// It's a tricky point. The timer routine set adpref as 0xff if the first
// rt timeout and no advertisement received, which means any advertisement
// received will be selected after the first rt.
//
}
//
// Check whether the current packet has a 255 preference option or not.
// Take non-preference option as 0 value.
//
);
//
// No advertisements received before or preference is more than other
// advertisements received before. Then store the new packet and the
// preference value.
//
}
return EFI_OUT_OF_RESOURCES;
}
}
} else {
//
// Non-preference and other advertisements received before or current
// preference is less than other advertisements received before.
// Leave the packet alone.
}
} else {
//
// Other error status means termination.
//
return Status;
}
//
// Client must collect advertise messages as more as possible until the first
// RT has elapsed, or get a highest preference 255 advertise.
// See details in the section-17.1.2 of rfc-3315.
//
}
return Status;
}
/**
The Dhcp6 stateful exchange process routine.
@param[in] Instance The pointer to the Dhcp6 instance.
@param[in] Packet The pointer to the received Dhcp6 message.
**/
)
{
goto ON_CONTINUE;
}
//
// Discard the packet if not advertisement or reply packet.
//
if (Packet->Dhcp6.Header.MessageType != Dhcp6MsgAdvertise && Packet->Dhcp6.Header.MessageType != Dhcp6MsgReply) {
goto ON_CONTINUE;
}
//
// Check whether include client Id or not.
//
);
goto ON_CONTINUE;
}
//
// Check whether include server Id or not.
//
);
goto ON_CONTINUE;
}
case Dhcp6Selecting:
//
// Handle the advertisement message when in the Dhcp6Selecting state.
// Do not need check return status, if failed, just continue to the next.
//
break;
case Dhcp6Requesting:
case Dhcp6Confirming:
case Dhcp6Renewing:
case Dhcp6Rebinding:
case Dhcp6Releasing:
case Dhcp6Declining:
//
// Handle the reply message when in the Dhcp6Requesting, Dhcp6Renewing
// Dhcp6Rebinding, Dhcp6Releasing and Dhcp6Declining state.
// If failed here, it should reset the current session.
//
goto ON_EXIT;
}
break;
default:
//
// Other state has not supported yet.
//
break;
}
//
// Continue to receive the following Dhcp6 message.
//
0
);
}
}
/**
The Dhcp6 stateless exchange process routine.
@param[in] Instance The pointer to the Dhcp6 instance.
@param[in] Packet The pointer to the received Dhcp6 message.
**/
)
{
goto ON_EXIT;
}
goto ON_EXIT;
}
//
// Check whether it's a desired Info-request message by Xid.
//
break;
}
}
if (!IsMatched) {
goto ON_EXIT;
}
//
// Check whether include server Id or not.
//
);
goto ON_EXIT;
}
//
// Callback to user with the received packet and check the user's feedback.
//
);
if (Status == EFI_NOT_READY) {
//
// Success or aborted will both stop this info-request exchange process,
// but not ready means user wants to continue to receive reply.
//
goto ON_EXIT;
}
//
// Dequeue the sent packet from the txlist if the xid matched, and ignore
// if no xid matched.
//
);
//
// For sync, set the status out of polling for info-request.
//
0
);
}
}
/**
The receive callback function for 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.
**/
)
{
IsStateless = FALSE;
return ;
}
//
// Copy the net buffer received from upd6 to a Dhcp6 packet.
//
goto ON_CONTINUE;
}
goto ON_CONTINUE;
}
//
// Dispatch packet to right instance by transaction id.
//
//
// Find the corresponding packet in tx list, and check it whether belongs
// to stateful exchange process.
//
IsStateless = TRUE;
}
IsDispatched = TRUE;
break;
}
}
if (IsDispatched) {
break;
}
}
//
// Skip this packet if not dispatched to any instance.
//
if (!IsDispatched) {
goto ON_CONTINUE;
}
//
// Dispatch the received packet ot the right instance.
//
if (IsStateless) {
} else {
}
}
}
/**
Detect Link movement for specified network device.
This routine will try to invoke Snp->GetStatus() to get the media status.
If media present status switches from unpresent to present, a link movement
is detected. Note that the underlying UNDI driver may not support reporting
media status from GET_STATUS command. If that, fail to detect link movement.
@param[in] Instance The pointer to DHCP6_INSTANCE.
@retval TRUE A link movement is detected.
@retval FALSE A link movement is not detected.
**/
)
{
//
// Check whether SNP support media detection
//
return FALSE;
}
//
// Invoke Snp->GetStatus() to refresh MediaPresent field in SNP mode data
//
return FALSE;
}
//
// Media transimit Unpresent to Present means new link movement is detected.
//
return TRUE;
}
return FALSE;
}
/**
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.
**/
)
{
//
// 1. Loop the tx list, count live time of every tx packet to check whether
// need re-transmit or not.
//
//
// Handle the first rt in the transmission of solicit specially.
//
if ((TxCb->RetryCnt == 0 || TxCb->SolicitRetry) && TxCb->TxPacket->Dhcp6.Header.MessageType == Dhcp6MsgSolicit) {
//
// Set adpref as 0xff here to indicate select any advertisement
// afterwards.
//
} else {
//
// Select the advertisement received before.
//
}
return;
}
}
//
// Increase the retry count for the packet and add up the total loss time.
//
//
// Check whether overflow the max retry count limit for this packet
//
goto ON_CLOSE;
}
//
// Check whether overflow the max retry duration for this packet
//
goto ON_CLOSE;
}
//
// Re-calculate retry expire timeout for the next time.
//
// Firstly, Check the new calculated time whether overflow the max retry
// expire time.
//
);
TRUE,
);
}
//
// Secondly, Check the new calculated time whether overflow the max retry
// duration time.
//
}
//
// Reset the tick time for the next retransmission
//
//
// Retransmit the last sent packet again.
//
}
}
}
//
// 2. Check the configured Ia, count lease time of every valid Ia to check
// whether need to renew or rebind this Ia.
//
return;
}
if (IaCb->Ia->State == Dhcp6Bound || IaCb->Ia->State == Dhcp6Renewing || IaCb->Ia->State == Dhcp6Rebinding) {
//
// Exceed t2, send rebind packet to extend the Ia lease.
//
//
// Exceed t1, send renew packet to extend the Ia lease.
//
}
}
//
// 3. In any situation when a client may have moved to a new link, the
//
}
return;
) {
//
//
}
//
// The failure of info-request will return no response.
//
}
);
} else {
//
// The failure of the others will terminate current state machine if timeout.
//
}
}