TianoCore EDK2 master
Loading...
Searching...
No Matches
Ip6Common.h File Reference

Go to the source code of this file.

Data Structures

struct  IP6_DESTROY_CHILD_BY_ADDR_CALLBACK_CONTEXT
 

Macros

#define IP6_LINK_EQUAL(Mac1, Mac2)   (CompareMem ((Mac1), (Mac2), sizeof (EFI_MAC_ADDRESS)) == 0)
 
#define IP6_US_TO_SEC(Us)   (((Us) + 999999) / 1000000)
 
#define IP6_ETHER_PROTO   0x86DD
 
#define IP6_MAC_LEN   6
 
#define IP6_IF_ID_LEN   8
 
#define IP6_INTERFACE_LOCAL_SCOPE   1
 
#define IP6_LINK_LOCAL_SCOPE   2
 
#define IP6_SITE_LOCAL_SCOPE   5
 
#define IP6_INFINIT_LIFETIME   0xFFFFFFFF
 
#define IP6_HOP_LIMIT   255
 
#define IP6_LINK_LOCAL_PREFIX_LENGTH   64
 
#define IP6_TIMER_INTERVAL_IN_MS   100
 
#define IP6_ONE_SECOND_IN_MS   1000
 
#define IP6_LINK_BROADCAST   0x00000001
 
#define IP6_LINK_MULTICAST   0x00000002
 
#define IP6_LINK_PROMISC   0x00000004
 
#define IP6_U_BIT   0x02
 

Typedefs

typedef struct _IP6_INTERFACE IP6_INTERFACE
 
typedef struct _IP6_PROTOCOL IP6_PROTOCOL
 
typedef struct _IP6_SERVICE IP6_SERVICE
 
typedef struct _IP6_ADDRESS_INFO IP6_ADDRESS_INFO
 

Enumerations

enum  IP6_ADDRESS_TYPE { Ip6Promiscuous = 1 , Ip6Unicast , Ip6Multicast , Ip6AnyCast }
 

Functions

EFI_STATUS Ip6BuildEfiAddressList (IN IP6_SERVICE *IpSb, OUT UINT32 *AddressCount, OUT EFI_IP6_ADDRESS_INFO **AddressList OPTIONAL)
 
EFI_STATUS Ip6SetToAllNodeMulticast (IN BOOLEAN Router, IN UINT8 Scope, OUT EFI_IPv6_ADDRESS *Ip6Addr)
 
UINT8 * Ip6CreateInterfaceID (IN OUT IP6_SERVICE *IpSb)
 
EFI_IPv6_ADDRESSIp6CreateLinkLocalAddr (IN OUT IP6_SERVICE *IpSb)
 
VOID Ip6CreateSNMulticastAddr (IN EFI_IPv6_ADDRESS *Ip6Addr, OUT EFI_IPv6_ADDRESS *MulticastAddr)
 
BOOLEAN Ip6IsSNMulticastAddr (IN EFI_IPv6_ADDRESS *Ip6)
 
BOOLEAN Ip6IsOneOfSetAddress (IN IP6_SERVICE *IpSb, IN EFI_IPv6_ADDRESS *Address, OUT IP6_INTERFACE **Interface OPTIONAL, OUT IP6_ADDRESS_INFO **AddressInfo OPTIONAL)
 
BOOLEAN Ip6IsValidLinkAddress (IN IP6_SERVICE *IpSb, IN EFI_MAC_ADDRESS *LinkAddress)
 
VOID Ip6CopyAddressByPrefix (OUT EFI_IPv6_ADDRESS *Dest, IN EFI_IPv6_ADDRESS *Src, IN UINT8 PrefixLength)
 
VOID Ip6AddAddr (IN OUT IP6_INTERFACE *IpIf, IN IP6_ADDRESS_INFO *AddrInfo)
 
EFI_STATUS Ip6RemoveAddr (IN IP6_SERVICE *IpSb OPTIONAL, IN OUT LIST_ENTRY *AddressList, IN OUT UINT32 *AddressCount, IN EFI_IPv6_ADDRESS *Prefix OPTIONAL, IN UINT8 PrefixLength)
 
EFI_STATUS Ip6GetMulticastMac (IN EFI_MANAGED_NETWORK_PROTOCOL *Mnp, IN EFI_IPv6_ADDRESS *Multicast, OUT EFI_MAC_ADDRESS *Mac)
 
EFI_IP6_HEADERIp6NtohHead (IN OUT EFI_IP6_HEADER *Head)
 

Detailed Description

Common definition and functions for IP6 driver.

Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.

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

Definition in file Ip6Common.h.

Macro Definition Documentation

◆ IP6_ETHER_PROTO

#define IP6_ETHER_PROTO   0x86DD

Definition at line 21 of file Ip6Common.h.

◆ IP6_HOP_LIMIT

#define IP6_HOP_LIMIT   255

Definition at line 32 of file Ip6Common.h.

◆ IP6_IF_ID_LEN

#define IP6_IF_ID_LEN   8

Definition at line 24 of file Ip6Common.h.

◆ IP6_INFINIT_LIFETIME

#define IP6_INFINIT_LIFETIME   0xFFFFFFFF

Definition at line 30 of file Ip6Common.h.

◆ IP6_INTERFACE_LOCAL_SCOPE

#define IP6_INTERFACE_LOCAL_SCOPE   1

Definition at line 26 of file Ip6Common.h.

◆ IP6_LINK_BROADCAST

#define IP6_LINK_BROADCAST   0x00000001

Definition at line 44 of file Ip6Common.h.

◆ IP6_LINK_EQUAL

#define IP6_LINK_EQUAL (   Mac1,
  Mac2 
)    (CompareMem ((Mac1), (Mac2), sizeof (EFI_MAC_ADDRESS)) == 0)

Definition at line 13 of file Ip6Common.h.

◆ IP6_LINK_LOCAL_PREFIX_LENGTH

#define IP6_LINK_LOCAL_PREFIX_LENGTH   64

Definition at line 36 of file Ip6Common.h.

◆ IP6_LINK_LOCAL_SCOPE

#define IP6_LINK_LOCAL_SCOPE   2

Definition at line 27 of file Ip6Common.h.

◆ IP6_LINK_MULTICAST

#define IP6_LINK_MULTICAST   0x00000002

Definition at line 45 of file Ip6Common.h.

◆ IP6_LINK_PROMISC

#define IP6_LINK_PROMISC   0x00000004

Definition at line 46 of file Ip6Common.h.

◆ IP6_MAC_LEN

#define IP6_MAC_LEN   6

Definition at line 23 of file Ip6Common.h.

◆ IP6_ONE_SECOND_IN_MS

#define IP6_ONE_SECOND_IN_MS   1000

Definition at line 39 of file Ip6Common.h.

◆ IP6_SITE_LOCAL_SCOPE

#define IP6_SITE_LOCAL_SCOPE   5

Definition at line 28 of file Ip6Common.h.

◆ IP6_TIMER_INTERVAL_IN_MS

#define IP6_TIMER_INTERVAL_IN_MS   100

Definition at line 38 of file Ip6Common.h.

◆ IP6_U_BIT

#define IP6_U_BIT   0x02

Definition at line 48 of file Ip6Common.h.

◆ IP6_US_TO_SEC

#define IP6_US_TO_SEC (   Us)    (((Us) + 999999) / 1000000)

Definition at line 19 of file Ip6Common.h.

Typedef Documentation

◆ IP6_ADDRESS_INFO

Definition at line 65 of file Ip6Common.h.

◆ IP6_INTERFACE

typedef struct _IP6_INTERFACE IP6_INTERFACE

Definition at line 62 of file Ip6Common.h.

◆ IP6_PROTOCOL

typedef struct _IP6_PROTOCOL IP6_PROTOCOL

Definition at line 63 of file Ip6Common.h.

◆ IP6_SERVICE

typedef struct _IP6_SERVICE IP6_SERVICE

Definition at line 64 of file Ip6Common.h.

Enumeration Type Documentation

◆ IP6_ADDRESS_TYPE

enum IP6_ADDRESS_TYPE

Definition at line 50 of file Ip6Common.h.

Function Documentation

◆ Ip6AddAddr()

VOID Ip6AddAddr ( IN OUT IP6_INTERFACE IpIf,
IN IP6_ADDRESS_INFO AddrInfo 
)

Insert a node IP6_ADDRESS_INFO to an IP6 interface.

Parameters
[in,out]IpIfPoints to an IP6 interface.
[in]AddrInfoPoints to an IP6_ADDRESS_INFO.

Insert a node IP6_ADDRESS_INFO to an IP6 interface.

Parameters
[in,out]IpIfPoints to an IP6 interface.
[in]AddrInfoPoints to IP6_ADDRESS_INFO

Definition at line 316 of file Ip6Common.c.

◆ Ip6BuildEfiAddressList()

EFI_STATUS Ip6BuildEfiAddressList ( IN IP6_SERVICE IpSb,
OUT UINT32 *  AddressCount,
OUT EFI_IP6_ADDRESS_INFO **AddressList  OPTIONAL 
)

Build a array of EFI_IP6_ADDRESS_INFO to be returned to the caller. The number of EFI_IP6_ADDRESS_INFO is also returned. If AddressList is NULL, only the address count is returned.

Parameters
[in]IpSbThe IP6 service binding instance.
[out]AddressCountThe number of returned addresses.
[out]AddressListThe pointer to the array of EFI_IP6_ADDRESS_INFO. This is an optional parameter.
Return values
EFI_SUCCESSThe address array is successfully build
EFI_OUT_OF_RESOURCESFailed to allocate the memory for the address info.
EFI_INVALID_PARAMETERAny input parameter is invalid.

Build a array of EFI_IP6_ADDRESS_INFO to be returned to the caller. The number of EFI_IP6_ADDRESS_INFO is also returned. If AddressList is NULL, only the address count is returned.

Parameters
[in]IpSbThe IP6 service binding instance.
[out]AddressCountThe number of returned addresses.
[out]AddressListThe pointer to the array of EFI_IP6_ADDRESS_INFO. This is an optional parameter.
Return values
EFI_SUCCESSThe address array successfully built.
EFI_OUT_OF_RESOURCESFailed to allocate the memory for the address info.
EFI_INVALID_PARAMETERAny input parameter is invalid.

Definition at line 29 of file Ip6Common.c.

◆ Ip6CopyAddressByPrefix()

VOID Ip6CopyAddressByPrefix ( OUT EFI_IPv6_ADDRESS Dest,
IN EFI_IPv6_ADDRESS Src,
IN UINT8  PrefixLength 
)

Copy the PrefixLength bits from Src to Dest.

Parameters
[out]DestA pointer to the buffer to copy to.
[in]SrcA pointer to the buffer to copy from.
[in]PrefixLengthThe number of bits to copy.

Definition at line 593 of file Ip6Common.c.

◆ Ip6CreateInterfaceID()

UINT8 * Ip6CreateInterfaceID ( IN OUT IP6_SERVICE IpSb)

This function converts MAC address to 64 bits interface ID according to RFC4291 and returns the interface ID. Currently only 48-bit MAC address is supported by this function.

Parameters
[in,out]IpSbThe IP6 service binding instance.
Return values
NULLThe operation fails.
Returns
Pointer to the generated interface ID.

Definition at line 142 of file Ip6Common.c.

◆ Ip6CreateLinkLocalAddr()

EFI_IPv6_ADDRESS * Ip6CreateLinkLocalAddr ( IN OUT IP6_SERVICE IpSb)

This function creates link-local address from interface identifier. The interface identifier is normally created from MAC address. It might be manually configured by administrator if the link-local address created from MAC address is a duplicate address.

Parameters
[in,out]IpSbThe IP6 service binding instance.
Return values
NULLIf the operation fails.
Returns
The generated Link Local address, in network order.

Definition at line 200 of file Ip6Common.c.

◆ Ip6CreateSNMulticastAddr()

VOID Ip6CreateSNMulticastAddr ( IN EFI_IPv6_ADDRESS Ip6Addr,
OUT EFI_IPv6_ADDRESS MulticastAddr 
)

Compute the solicited-node multicast address for an unicast or anycast address, by taking the low-order 24 bits of this address, and appending those bits to the prefix FF02:0:0:0:0:1:FF00::/104.

Parameters
Ip6AddrThe unicast or anycast address, in network order.
MulticastAddrThe generated solicited-node multicast address, in network order.

Compute the solicited-node multicast address for an unicast or anycast address, by taking the low-order 24 bits of this address, and appending those bits to the prefix FF02:0:0:0:0:1:FF00::/104.

Parameters
[in]Ip6AddrThe unicast or anycast address, in network order.
[out]MulticastAddrThe generated solicited-node multicast address, in network order.

Definition at line 291 of file Ip6Common.c.

◆ Ip6GetMulticastMac()

EFI_STATUS Ip6GetMulticastMac ( IN EFI_MANAGED_NETWORK_PROTOCOL Mnp,
IN EFI_IPv6_ADDRESS Multicast,
OUT EFI_MAC_ADDRESS Mac 
)

Get the MAC address for a multicast IP address. Call Mnp's McastIpToMac to find the MAC address instead of hard-coding the NIC to be Ethernet.

Parameters
[in]MnpThe Mnp instance to get the MAC address.
[in]MulticastThe multicast IP address to translate.
[out]MacThe buffer to hold the translated address.
Return values
EFI_SUCCESSThe multicast IP is successfully translated to a multicast MAC address.
OtherThe address is not converted because an error occurred.

Get the MAC address for a multicast IP address. Call Mnp's McastIpToMac to find the MAC address instead of hard-coding the NIC to be Ethernet.

Parameters
[in]MnpThe Mnp instance to get the MAC address.
[in]MulticastThe multicast IP address to translate.
[out]MacThe buffer to hold the translated address.
Return values
EFI_SUCCESSThe multicast IP successfully translated to a multicast MAC address.
OtherThe address is not converted because an error occurred.

Definition at line 635 of file Ip6Common.c.

◆ Ip6IsOneOfSetAddress()

BOOLEAN Ip6IsOneOfSetAddress ( IN IP6_SERVICE IpSb,
IN EFI_IPv6_ADDRESS Address,
OUT IP6_INTERFACE **Interface  OPTIONAL,
OUT IP6_ADDRESS_INFO **AddressInfo  OPTIONAL 
)

Check whether the incoming IPv6 address is one of the maintained address in the IP6 service binding instance.

Parameters
[in]IpSbPoints to a IP6 service binding instance
[in]AddressThe IP6 address to be checked.
[out]InterfaceIf not NULL, output the IP6 interface which maintains the Address.
[out]AddressInfoIf not NULL, output the IP6 address information of the Address.
Return values
TRUEYes, it is one of the maintained addresses.
FALSENo, it is not one of the maintained addresses.

Check whether the incoming IPv6 address is one of the maintained addresses in the IP6 service binding instance.

Parameters
[in]IpSbPoints to a IP6 service binding instance.
[in]AddressThe IP6 address to be checked.
[out]InterfaceIf not NULL, output the IP6 interface which maintains the Address.
[out]AddressInfoIf not NULL, output the IP6 address information of the Address.
Return values
TRUEYes, it is one of the maintained address.
FALSENo, it is not one of the maintained address.

Definition at line 504 of file Ip6Common.c.

◆ Ip6IsSNMulticastAddr()

BOOLEAN Ip6IsSNMulticastAddr ( IN EFI_IPv6_ADDRESS Ip6)

Check whether the incoming Ipv6 address is a solicited-node multicast address.

Parameters
[in]Ip6Ip6 address, in network order.
Return values
TRUEYes, solicited-node multicast address
FALSENo

Definition at line 471 of file Ip6Common.c.

◆ Ip6IsValidLinkAddress()

BOOLEAN Ip6IsValidLinkAddress ( IN IP6_SERVICE IpSb,
IN EFI_MAC_ADDRESS LinkAddress 
)

Check whether the incoming MAC address is valid.

Parameters
[in]IpSbPoints to a IP6 service binding instance.
[in]LinkAddressThe MAC address.
Return values
TRUEYes, it is valid.
FALSENo, it is not valid.

Definition at line 565 of file Ip6Common.c.

◆ Ip6NtohHead()

EFI_IP6_HEADER * Ip6NtohHead ( IN OUT EFI_IP6_HEADER Head)

Convert the multibyte field in IP header's byter order. In spite of its name, it can also be used to convert from host to network byte order.

Parameters
[in,out]HeadThe IP head to convert.
Returns
Point to the converted IP head.

Definition at line 659 of file Ip6Common.c.

◆ Ip6RemoveAddr()

EFI_STATUS Ip6RemoveAddr ( IN IP6_SERVICE *IpSb  OPTIONAL,
IN OUT LIST_ENTRY AddressList,
IN OUT UINT32 *  AddressCount,
IN EFI_IPv6_ADDRESS *Prefix  OPTIONAL,
IN UINT8  PrefixLength 
)

Remove the IPv6 address from the address list node points to IP6_ADDRESS_INFO.

This function removes the matching IPv6 addresses from the address list and adjusts the address count of the address list. If IpSb is not NULL, this function calls Ip6LeaveGroup to see whether it should call Mnp->Groups() to remove the its solicited-node multicast MAC address from the filter list and sends out a Multicast Listener Done. If Prefix is NULL, all address in the address list will be removed. If Prefix is not NULL, the address that matching the Prefix with PrefixLength in the address list will be removed.

Parameters
[in]IpSbNULL or points to IP6 service binding instance.
[in,out]AddressListaddress list array
[in,out]AddressCountthe count of addresses in address list array
[in]PrefixNULL or an IPv6 address prefix
[in]PrefixLengththe length of Prefix
Return values
EFI_SUCCESSThe operation completed successfully.
EFI_NOT_FOUNDThe address matching the Prefix with PrefixLength cannot be found in address list.
EFI_INVALID_PARAMETERAny input parameter is invalid.

Remove the IPv6 address from the address list node points to IP6_ADDRESS_INFO.

This function removes the matching IPv6 addresses from the address list and adjusts the address count of the address list. If IpSb is not NULL, this function calls Ip6LeaveGroup to see whether it should call Mnp->Groups() to remove the its solicited-node multicast MAC address from the filter list and sends out a Multicast Listener Done. If Prefix is NULL, all address in the address list will be removed. If Prefix is not NULL, the address that matching the Prefix with PrefixLength in the address list will be removed.

Parameters
[in]IpSbNULL or points to IP6 service binding instance.
[in,out]AddressListAddress list array.
[in,out]AddressCountThe count of addresses in address list array.
[in]PrefixNULL or an IPv6 address prefix.
[in]PrefixLengthThe length of Prefix.
Return values
EFI_SUCCESSThe operation completed successfully.
EFI_NOT_FOUNDThe address matching the Prefix with PrefixLength cannot be found in the address list.
EFI_INVALID_PARAMETERAny input parameter is invalid.

Definition at line 411 of file Ip6Common.c.

◆ Ip6SetToAllNodeMulticast()

EFI_STATUS Ip6SetToAllNodeMulticast ( IN BOOLEAN  Router,
IN UINT8  Scope,
OUT EFI_IPv6_ADDRESS Ip6Addr 
)

Generate the multicast addresses identify the group of all IPv6 nodes or IPv6 routers defined in RFC4291.

All Nodes Addresses: FF01::1, FF02::1. All Router Addresses: FF01::2, FF02::2, FF05::2.

Parameters
[in]RouterIf TRUE, generate all routers addresses, else generate all node addresses.
[in]Scopeinterface-local(1), link-local(2), or site-local(5)
[out]Ip6AddrThe generated multicast address.
Return values
EFI_INVALID_PARAMETERAny input parameter is invalid.
EFI_SUCCESSThe address is generated.

Definition at line 103 of file Ip6Common.c.