TianoCore EDK2 master
Loading...
Searching...
No Matches
Dhcp6Utility.c File Reference
#include "Dhcp6Impl.h"

Go to the source code of this file.

Macros

#define IS_INVALID_PACKET_CURSOR(PacketCursor, Packet)
 

Functions

EFI_DHCP6_DUIDDhcp6GenerateClientId (IN EFI_SIMPLE_NETWORK_MODE *Mode)
 
EFI_STATUS Dhcp6CopyConfigData (IN EFI_DHCP6_CONFIG_DATA *DstCfg, IN EFI_DHCP6_CONFIG_DATA *SorCfg)
 
VOID Dhcp6CleanupConfigData (IN OUT EFI_DHCP6_CONFIG_DATA *CfgData)
 
VOID Dhcp6CleanupModeData (IN OUT EFI_DHCP6_MODE_DATA *ModeData)
 
UINT32 Dhcp6CalculateExpireTime (IN UINT32 Base, IN BOOLEAN IsFirstRt, IN BOOLEAN NeedSigned)
 
VOID Dhcp6CalculateLeaseTime (IN DHCP6_IA_CB *IaCb)
 
EFI_STATUS Dhcp6CheckAddress (IN EFI_DHCP6_IA *Ia, IN UINT32 AddressCount, IN EFI_IPv6_ADDRESS *Addresses)
 
EFI_DHCP6_IADhcp6DepriveAddress (IN EFI_DHCP6_IA *Ia, IN UINT32 AddressCount, IN EFI_IPv6_ADDRESS *Addresses)
 
VOID EFIAPI Dhcp6DummyExtFree (IN VOID *Arg)
 
VOID EFIAPI Dhcp6OnTransmitted (IN NET_BUF *Wrap, IN UDP_END_POINT *EndPoint, IN EFI_STATUS IoStatus, IN VOID *Context)
 
EFI_STATUS Dhcp6AppendOption (IN OUT EFI_DHCP6_PACKET *Packet, IN OUT UINT8 **PacketCursor, IN UINT16 OptType, IN UINT16 OptLen, IN UINT8 *Data)
 
EFI_STATUS Dhcp6AppendIaAddrOption (IN OUT EFI_DHCP6_PACKET *Packet, IN OUT UINT8 **PacketCursor, IN EFI_DHCP6_IA_ADDRESS *IaAddr, IN UINT32 MessageType)
 
EFI_STATUS Dhcp6AppendIaOption (IN OUT EFI_DHCP6_PACKET *Packet, IN OUT UINT8 **PacketCursor, IN EFI_DHCP6_IA *Ia, IN UINT32 T1, IN UINT32 T2, IN UINT32 MessageType)
 
EFI_STATUS Dhcp6AppendETOption (IN OUT EFI_DHCP6_PACKET *Packet, IN OUT UINT8 **PacketCursor, IN DHCP6_INSTANCE *Instance, OUT UINT16 **Elapsed)
 
VOID SetElapsedTime (IN UINT16 *Elapsed, IN DHCP6_INSTANCE *Instance)
 
UINT8 * Dhcp6SeekOption (IN UINT8 *Buf, IN UINT32 SeekLen, IN UINT16 OptType)
 
UINT8 * Dhcp6SeekIaOption (IN UINT8 *Buf, IN UINT32 SeekLen, IN EFI_DHCP6_IA_DESCRIPTOR *IaDesc)
 
BOOLEAN Dhcp6AddrIsInCurrentIa (IN EFI_DHCP6_IA_ADDRESS *IaAddr, IN EFI_DHCP6_IA *CurrentIa)
 
VOID Dhcp6ParseAddrOption (IN EFI_DHCP6_IA *CurrentIa, IN UINT8 *IaInnerOpt, IN UINT16 IaInnerLen, OUT UINT32 *AddrNum, IN OUT EFI_DHCP6_IA_ADDRESS *AddrBuf)
 
EFI_STATUS Dhcp6GenerateIaCb (IN DHCP6_INSTANCE *Instance, IN UINT8 *IaInnerOpt, IN UINT16 IaInnerLen, IN UINT32 T1, IN UINT32 T2)
 
EFI_STATUS Dhcp6CacheIa (IN DHCP6_INSTANCE *Instance)
 
VOID Dhcp6AppendCacheIa (IN DHCP6_INSTANCE *Instance)
 
EFI_STATUS Dhcp6GetMappingTimeOut (IN EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg, OUT UINTN *TimeOut)
 

Detailed Description

Dhcp6 support functions implementation.

(C) Copyright 2015 Hewlett-Packard Development Company, L.P.
Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.

SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file Dhcp6Utility.c.

Macro Definition Documentation

◆ IS_INVALID_PACKET_CURSOR

#define IS_INVALID_PACKET_CURSOR (   PacketCursor,
  Packet 
)
Value:
(((*PacketCursor) < (Packet)->Dhcp6.Option) || \
((*PacketCursor) >= (Packet)->Dhcp6.Option + ((Packet)->Size - sizeof(EFI_DHCP6_HEADER))) \
) \

Definition at line 17 of file Dhcp6Utility.c.

Function Documentation

◆ Dhcp6AddrIsInCurrentIa()

BOOLEAN Dhcp6AddrIsInCurrentIa ( IN EFI_DHCP6_IA_ADDRESS IaAddr,
IN EFI_DHCP6_IA CurrentIa 
)

Check whether the incoming IPv6 address in IaAddr is one of the maintained addresses in the IA control block.

Parameters
[in]IaAddrThe pointer to the IA Address to be checked.
[in]CurrentIaThe pointer to the IA in IA control block.
Return values
TRUEYes, this Address is already in IA control block.
FALSENo, this Address is NOT in IA control block.

Definition at line 1206 of file Dhcp6Utility.c.

◆ Dhcp6AppendCacheIa()

VOID Dhcp6AppendCacheIa ( IN DHCP6_INSTANCE Instance)

Append CacheIa to the current IA. Meanwhile, clear CacheIa.ValidLifetime to 0.

Parameters
[in]InstanceThe pointer to DHCP6 instance.

Definition at line 1440 of file Dhcp6Utility.c.

◆ Dhcp6AppendETOption()

EFI_STATUS Dhcp6AppendETOption ( IN OUT EFI_DHCP6_PACKET Packet,
IN OUT UINT8 **  PacketCursor,
IN DHCP6_INSTANCE Instance,
OUT UINT16 **  Elapsed 
)

Append the appointed Elapsed time option to Buf, and move Buf to the end.

Parameters
[in,out]PacketA pointer to the packet, on success Packet->Length will be updated.
[in,out]PacketCursorThe pointer in the packet, on success PacketCursor will be moved to the end of the option.
[in]InstanceThe pointer to the Dhcp6 instance.
[out]ElapsedThe pointer to the elapsed time value in the generated packet.
Return values
EFI_INVALID_PARAMETERAn argument provided to the function was invalid
EFI_BUFFER_TOO_SMALLThe buffer is too small to append the option.
EFI_SUCCESSThe option is appended successfully.

Definition at line 968 of file Dhcp6Utility.c.

◆ Dhcp6AppendIaAddrOption()

EFI_STATUS Dhcp6AppendIaAddrOption ( IN OUT EFI_DHCP6_PACKET Packet,
IN OUT UINT8 **  PacketCursor,
IN EFI_DHCP6_IA_ADDRESS IaAddr,
IN UINT32  MessageType 
)

Append the appointed IA Address option to Buf, and move Buf to the end.

Parameters
[in,out]PacketA pointer to the packet, on success Packet->Length will be updated.
[in,out]PacketCursorThe pointer in the packet, on success PacketCursor will be moved to the end of the option.
[in]IaAddrThe pointer to the IA Address.
[in]MessageTypeMessage type of DHCP6 package.
Return values
EFI_INVALID_PARAMETERAn argument provided to the function was invalid
EFI_BUFFER_TOO_SMALLThe buffer is too small to append the option.
EFI_SUCCESSThe option is appended successfully.

Definition at line 697 of file Dhcp6Utility.c.

◆ Dhcp6AppendIaOption()

EFI_STATUS Dhcp6AppendIaOption ( IN OUT EFI_DHCP6_PACKET Packet,
IN OUT UINT8 **  PacketCursor,
IN EFI_DHCP6_IA Ia,
IN UINT32  T1,
IN UINT32  T2,
IN UINT32  MessageType 
)

Append the appointed Ia option to Buf, and move Buf to the end.

Parameters
[in,out]PacketA pointer to the packet, on success Packet->Length will be updated.
[in,out]PacketCursorThe pointer in the packet, on success PacketCursor will be moved to the end of the option.
[in]IaThe pointer to the Ia.
[in]T1The time of T1.
[in]T2The time of T2.
[in]MessageTypeMessage type of DHCP6 package.
Return values
EFI_INVALID_PARAMETERAn argument provided to the function was invalid
EFI_BUFFER_TOO_SMALLThe buffer is too small to append the option.
EFI_SUCCESSThe option is appended successfully.

Definition at line 824 of file Dhcp6Utility.c.

◆ Dhcp6AppendOption()

EFI_STATUS Dhcp6AppendOption ( IN OUT EFI_DHCP6_PACKET Packet,
IN OUT UINT8 **  PacketCursor,
IN UINT16  OptType,
IN UINT16  OptLen,
IN UINT8 *  Data 
)

Append the option to Buf, update the length of packet, and move Buf to the end.

Parameters
[in,out]PacketA pointer to the packet, on success Packet->Length will be updated.
[in,out]PacketCursorThe pointer in the packet, on success PacketCursor will be moved to the end of the option.
[in]OptTypeThe option type.
[in]OptLenThe length of option contents.
[in]DataThe pointer to the option content.
Return values
EFI_INVALID_PARAMETERAn argument provided to the function was invalid
EFI_BUFFER_TOO_SMALLThe buffer is too small to append the option.
EFI_SUCCESSThe option is appended successfully.

Definition at line 606 of file Dhcp6Utility.c.

◆ Dhcp6CacheIa()

EFI_STATUS Dhcp6CacheIa ( IN DHCP6_INSTANCE Instance)

Cache the current IA configuration information.

Parameters
[in]InstanceThe pointer to DHCP6 Instance.
Return values
EFI_SUCCESSCache the current IA successfully.
EFI_OUT_OF_RESOURCESRequired system resources could not be allocated.

Definition at line 1407 of file Dhcp6Utility.c.

◆ Dhcp6CalculateExpireTime()

UINT32 Dhcp6CalculateExpireTime ( IN UINT32  Base,
IN BOOLEAN  IsFirstRt,
IN BOOLEAN  NeedSigned 
)

Calculate the expire time by the algorithm defined in rfc.

Parameters
[in]BaseThe base value of the time.
[in]IsFirstRtIf TRUE, it is the first time to calculate expire time.
[in]NeedSignedIf TRUE, the signed factor is needed.
Returns
Expire The calculated result for the new expire time.

Definition at line 321 of file Dhcp6Utility.c.

◆ Dhcp6CalculateLeaseTime()

VOID Dhcp6CalculateLeaseTime ( IN DHCP6_IA_CB IaCb)

Calculate the lease time by the algorithm defined in rfc.

Parameters
[in]IaCbThe pointer to the Ia control block.

Definition at line 372 of file Dhcp6Utility.c.

◆ Dhcp6CheckAddress()

EFI_STATUS Dhcp6CheckAddress ( IN EFI_DHCP6_IA Ia,
IN UINT32  AddressCount,
IN EFI_IPv6_ADDRESS Addresses 
)

Check whether the addresses are all included by the configured Ia.

Parameters
[in]IaThe pointer to the Ia.
[in]AddressCountThe number of addresses.
[in]AddressesThe pointer to the addresses buffer.
Return values
EFI_SUCCESSThe addresses are all included by the configured IA.
EFI_NOT_FOUNDThe addresses are not included by the configured IA.

Definition at line 416 of file Dhcp6Utility.c.

◆ Dhcp6CleanupConfigData()

VOID Dhcp6CleanupConfigData ( IN OUT EFI_DHCP6_CONFIG_DATA CfgData)

Clean up the configure data.

Parameters
[in,out]CfgDataThe pointer to the configure data.

Definition at line 251 of file Dhcp6Utility.c.

◆ Dhcp6CleanupModeData()

VOID Dhcp6CleanupModeData ( IN OUT EFI_DHCP6_MODE_DATA ModeData)

Clean up the mode data.

Parameters
[in,out]ModeDataThe pointer to the mode data.

Definition at line 286 of file Dhcp6Utility.c.

◆ Dhcp6CopyConfigData()

EFI_STATUS Dhcp6CopyConfigData ( IN EFI_DHCP6_CONFIG_DATA DstCfg,
IN EFI_DHCP6_CONFIG_DATA SorCfg 
)

Copy the Dhcp6 configure data.

Parameters
[in]DstCfgThe pointer to the destination configure data.
[in]SorCfgThe pointer to the source configure data.
Return values
EFI_SUCCESSCopy the content from SorCfg from DstCfg successfully.
EFI_OUT_OF_RESOURCESRequired system resources could not be allocated.

Definition at line 180 of file Dhcp6Utility.c.

◆ Dhcp6DepriveAddress()

EFI_DHCP6_IA * Dhcp6DepriveAddress ( IN EFI_DHCP6_IA Ia,
IN UINT32  AddressCount,
IN EFI_IPv6_ADDRESS Addresses 
)

Deprive the addresses from current Ia, and generate another eliminated Ia.

Parameters
[in]IaThe pointer to the Ia.
[in]AddressCountThe number of addresses.
[in]AddressesThe pointer to the addresses buffer.
Return values
NULLIf it failed to generate the deprived Ia.
othersThe pointer to the deprived Ia.

Definition at line 465 of file Dhcp6Utility.c.

◆ Dhcp6DummyExtFree()

VOID EFIAPI Dhcp6DummyExtFree ( IN VOID *  Arg)

The dummy ext buffer free callback routine.

Parameters
[in]ArgThe pointer to the parameter.

Definition at line 562 of file Dhcp6Utility.c.

◆ Dhcp6GenerateClientId()

EFI_DHCP6_DUID * Dhcp6GenerateClientId ( IN EFI_SIMPLE_NETWORK_MODE Mode)

Generate client Duid in the format of Duid-llt.

Parameters
[in]ModeThe pointer to the mode of SNP.
Return values
NULLIf it failed to generate a client Id.
othersThe pointer to the new client id.

Definition at line 33 of file Dhcp6Utility.c.

◆ Dhcp6GenerateIaCb()

EFI_STATUS Dhcp6GenerateIaCb ( IN DHCP6_INSTANCE Instance,
IN UINT8 *  IaInnerOpt,
IN UINT16  IaInnerLen,
IN UINT32  T1,
IN UINT32  T2 
)

Create a control block for the Ia according to the corresponding options.

Parameters
[in]InstanceThe pointer to DHCP6 Instance.
[in]IaInnerOptThe pointer to the inner options in the Ia option.
[in]IaInnerLenThe length of all the inner options in the Ia option.
[in]T1T1 time in the Ia option.
[in]T2T2 time in the Ia option.
Return values
EFI_NOT_FOUNDNo valid IA option is found.
EFI_SUCCESSCreate an IA control block successfully.
EFI_OUT_OF_RESOURCESRequired system resources could not be allocated.
EFI_DEVICE_ERRORAn unexpected error.

Definition at line 1326 of file Dhcp6Utility.c.

◆ Dhcp6GetMappingTimeOut()

EFI_STATUS Dhcp6GetMappingTimeOut ( IN EFI_IP6_CONFIG_PROTOCOL Ip6Cfg,
OUT UINTN TimeOut 
)

Calculate the Dhcp6 get mapping timeout by adding additional delay to the IP6 DAD transmits count.

Parameters
[in]Ip6CfgThe pointer to Ip6 config protocol.
[out]TimeOutThe time out value in 100ns units.
Return values
EFI_INVALID_PARAMETERInput parameters are invalid.
EFI_SUCCESSCalculate the time out value successfully.

Definition at line 1499 of file Dhcp6Utility.c.

◆ Dhcp6OnTransmitted()

VOID EFIAPI Dhcp6OnTransmitted ( IN NET_BUF Wrap,
IN UDP_END_POINT EndPoint,
IN EFI_STATUS  IoStatus,
IN VOID *  Context 
)

The callback routine once message transmitted.

Parameters
[in]WrapThe pointer to the received net buffer.
[in]EndPointThe pointer to the udp end point.
[in]IoStatusThe return status from udp io.
[in]ContextThe opaque parameter to the function.

Definition at line 579 of file Dhcp6Utility.c.

◆ Dhcp6ParseAddrOption()

VOID Dhcp6ParseAddrOption ( IN EFI_DHCP6_IA CurrentIa,
IN UINT8 *  IaInnerOpt,
IN UINT16  IaInnerLen,
OUT UINT32 *  AddrNum,
IN OUT EFI_DHCP6_IA_ADDRESS AddrBuf 
)

Parse the address option and update the address information.

Parameters
[in]CurrentIaThe pointer to the Ia Address in control block.
[in]IaInnerOptThe pointer to the buffer.
[in]IaInnerLenThe length to parse.
[out]AddrNumThe number of addresses.
[in,out]AddrBufThe pointer to the address buffer.

Definition at line 1235 of file Dhcp6Utility.c.

◆ Dhcp6SeekIaOption()

UINT8 * Dhcp6SeekIaOption ( IN UINT8 *  Buf,
IN UINT32  SeekLen,
IN EFI_DHCP6_IA_DESCRIPTOR IaDesc 
)

Seek the address of the first byte of the Ia option header.

Parameters
[in]BufThe pointer to the buffer.
[in]SeekLenThe length to seek.
[in]IaDescThe pointer to the Ia descriptor.
Return values
NULLIf it failed to seek the Ia option.
othersThe position to the Ia option.

Definition at line 1161 of file Dhcp6Utility.c.

◆ Dhcp6SeekOption()

UINT8 * Dhcp6SeekOption ( IN UINT8 *  Buf,
IN UINT32  SeekLen,
IN UINT16  OptType 
)

Seek the address of the first byte of the option header.

Parameters
[in]BufThe pointer to the buffer.
[in]SeekLenThe length to seek.
[in]OptTypeThe option type.
Return values
NULLIf it failed to seek the option.
othersThe position to the option.

Definition at line 1118 of file Dhcp6Utility.c.

◆ SetElapsedTime()

VOID SetElapsedTime ( IN UINT16 *  Elapsed,
IN DHCP6_INSTANCE Instance 
)

Set the elapsed time based on the given instance and the pointer to the elapsed time option.

Parameters
[in]ElapsedThe pointer to the position to append.
[in]InstanceThe pointer to the Dhcp6 instance.

Definition at line 1062 of file Dhcp6Utility.c.