OpenThread  1.05.03.02
Data Structures | Public Types | Public Member Functions | Protected Member Functions | Private Attributes | Static Private Attributes | Friends
Netif Class Reference

#include <netif.hpp>

+ Inheritance diagram for Netif:
+ Collaboration diagram for Netif:

Data Structures

class  ExternalMulticastAddress
 
class  MulticastAddress
 
class  UnicastAddress
 

Public Types

enum  AddressEvent : bool { kAddressRemoved = false, kAddressAdded = true }
 
enum  AddressOrigin : uint8_t { kOriginThread = OT_ADDRESS_ORIGIN_THREAD, kOriginSlaac = OT_ADDRESS_ORIGIN_SLAAC, kOriginDhcp6 = OT_ADDRESS_ORIGIN_DHCPV6, kOriginManual = OT_ADDRESS_ORIGIN_MANUAL }
 

Public Member Functions

Error AddExternalUnicastAddress (const UnicastAddress &aAddress)
 
void AddUnicastAddress (UnicastAddress &aAddress)
 
const LinkedList< MulticastAddress > & GetMulticastAddresses (void) const
 
const LinkedList< UnicastAddress > & GetUnicastAddresses (void) const
 
bool HasAnyExternalMulticastAddress (void) const
 
bool HasUnicastAddress (const Address &aAddress) const
 
bool HasUnicastAddress (const UnicastAddress &aAddress) const
 
bool IsMulticastAddressExternal (const MulticastAddress &aAddress) const
 
bool IsMulticastPromiscuousEnabled (void) const
 
bool IsMulticastSubscribed (const Address &aAddress) const
 
bool IsUnicastAddressExternal (const UnicastAddress &aAddress) const
 
ExternalMulticastAddress::Iterator::Builder IterateExternalMulticastAddresses (Address::TypeFilter aFilter=Address::kTypeAny)
 
 Netif (Instance &aInstance)
 
void RemoveAllExternalUnicastAddresses (void)
 
Error RemoveExternalUnicastAddress (const Address &aAddress)
 
void RemoveUnicastAddress (const UnicastAddress &aAddress)
 
void SetAddressCallback (otIp6AddressCallback aCallback, void *aCallbackContext)
 
void SetMulticastPromiscuous (bool aEnabled)
 
void SubscribeAllRoutersMulticast (void)
 
Error SubscribeExternalMulticast (const Address &aAddress)
 
void SubscribeMulticast (MulticastAddress &aAddress)
 
void UnsubscribeAllExternalMulticastAddresses (void)
 
void UnsubscribeAllRoutersMulticast (void)
 
Error UnsubscribeExternalMulticast (const Address &aAddress)
 
void UnsubscribeMulticast (const MulticastAddress &aAddress)
 
- Public Member Functions inherited from InstanceLocator
InstanceGetInstance (void) const
 
- Public Member Functions inherited from GetProvider< InstanceLocator >
Type & Get (void) const
 

Protected Member Functions

void SubscribeAllNodesMulticast (void)
 
void UnsubscribeAllNodesMulticast (void)
 
- Protected Member Functions inherited from InstanceLocator
 InstanceLocator (Instance &aInstance)
 
- Protected Member Functions inherited from GetProvider< InstanceLocator >
 GetProvider (void)=default
 

Private Attributes

otIp6AddressCallback mAddressCallback
 
void * mAddressCallbackContext
 
Pool< ExternalMulticastAddress, OPENTHREAD_CONFIG_IP6_MAX_EXT_MCAST_ADDRSmExtMulticastAddressPool
 
Pool< UnicastAddress, OPENTHREAD_CONFIG_IP6_MAX_EXT_UCAST_ADDRSmExtUnicastAddressPool
 
LinkedList< MulticastAddressmMulticastAddresses
 
bool mMulticastPromiscuous
 
LinkedList< UnicastAddressmUnicastAddresses
 

Static Private Attributes

static const otNetifMulticastAddress kLinkLocalAllNodesMulticastAddress
 
static const otNetifMulticastAddress kLinkLocalAllRoutersMulticastAddress
 
static const otNetifMulticastAddress kRealmLocalAllMplForwardersMulticastAddress
 
static const otNetifMulticastAddress kRealmLocalAllNodesMulticastAddress
 
static const otNetifMulticastAddress kRealmLocalAllRoutersMulticastAddress
 

Friends

class Address
 
class Ip6
 

Additional Inherited Members

- Private Member Functions inherited from NonCopyable
 NonCopyable (const NonCopyable &)=delete
 
NonCopyableoperator= (const NonCopyable &)=delete
 
 NonCopyable (void)=default
 

Detailed Description

This class implements an IPv6 network interface.

Member Enumeration Documentation

§ AddressEvent

enum AddressEvent : bool

This enumeration represent an address event (added or removed)

The boolean values are used for aIsAdded parameter in the call of otIp6AddressCallback.

Enumerator
kAddressRemoved 

Indicates that address was added.

kAddressAdded 

Indicates that address was removed.

§ AddressOrigin

enum AddressOrigin : uint8_t

This enumeration represents the address origin.

Enumerator
kOriginThread 

Thread assigned address (ALOC, RLOC, MLEID, etc)

kOriginSlaac 

SLAAC assigned address.

kOriginDhcp6 

DHCPv6 assigned address.

kOriginManual 

Manually assigned address.

Constructor & Destructor Documentation

§ Netif()

Netif ( Instance aInstance)
explicit

This constructor initializes the network interface.

Parameters
[in]aInstanceA reference to the OpenThread instance.

Referenced by Netif::ExternalMulticastAddress::GetNext().

Member Function Documentation

§ SetAddressCallback()

void SetAddressCallback ( otIp6AddressCallback  aCallback,
void *  aCallbackContext 
)

This method registers a callback to notify internal IPv6 address changes.

Parameters
[in]aCallbackA pointer to a function that is called when an IPv6 address is added or removed.
[in]aCallbackContextA pointer to application-specific context.

References Netif::mAddressCallback, and Netif::mAddressCallbackContext.

Referenced by Netif::ExternalMulticastAddress::GetNext().

§ GetUnicastAddresses()

const LinkedList<UnicastAddress>& GetUnicastAddresses ( void  ) const
inline

This method returns the linked list of unicast addresses.

Returns
The linked list of unicast addresses.

References Netif::AddUnicastAddress(), Netif::HasUnicastAddress(), Netif::mUnicastAddresses, and Netif::RemoveUnicastAddress().

§ AddUnicastAddress()

void AddUnicastAddress ( UnicastAddress aAddress)

This method adds a unicast address to the network interface.

This method is intended for addresses internal to OpenThread. The aAddress instance is directly added in the unicast address linked list.

If aAddress is already added, the call to AddUnicastAddress() with the same address will perform no action.

Parameters
[in]aAddressA reference to the unicast address.

References Netif::kAddressAdded, ot::kEventIp6AddressAdded, ot::kEventThreadRlocAdded, Netif::mAddressCallback, Netif::mAddressCallbackContext, otNetifAddress::mRloc, Netif::mUnicastAddresses, and SuccessOrExit.

Referenced by Netif::GetUnicastAddresses().

§ RemoveUnicastAddress()

void RemoveUnicastAddress ( const UnicastAddress aAddress)

This method removes a unicast address from the network interface.

This method is intended for addresses internal to OpenThread. The aAddress instance is removed from the unicast address linked list.

If aAddress is not in the list, the call to RemoveUnicastAddress() will perform no action.

Parameters
[in]aAddressA reference to the unicast address.

References Netif::kAddressRemoved, ot::kEventIp6AddressRemoved, ot::kEventThreadRlocRemoved, Netif::mAddressCallback, Netif::mAddressCallbackContext, otNetifAddress::mRloc, Netif::mUnicastAddresses, and SuccessOrExit.

Referenced by Netif::GetUnicastAddresses().

§ HasUnicastAddress() [1/2]

bool HasUnicastAddress ( const Address aAddress) const

This method indicates whether or not an address is assigned to the interface.

Parameters
[in]aAddressA reference to the unicast address.
Return values
TRUEIf aAddress is assigned to the network interface,
FALSEIf aAddress is not assigned to the network interface.

References Netif::mUnicastAddresses.

Referenced by Netif::GetUnicastAddresses().

§ HasUnicastAddress() [2/2]

bool HasUnicastAddress ( const UnicastAddress aAddress) const
inline

This method indicates whether or not a unicast address is assigned to the network interface.

Parameters
[in]aAddressA reference to the unicast address.
Return values
TRUEIf aAddress is assigned to the network interface,
FALSEIf aAddress is not assigned to the network interface.

References Netif::AddExternalUnicastAddress(), Netif::IsMulticastSubscribed(), Netif::IsUnicastAddressExternal(), Netif::mUnicastAddresses, Netif::RemoveAllExternalUnicastAddresses(), Netif::RemoveExternalUnicastAddress(), Netif::SubscribeAllRoutersMulticast(), and Netif::UnsubscribeAllRoutersMulticast().

§ IsUnicastAddressExternal()

bool IsUnicastAddressExternal ( const UnicastAddress aAddress) const

This method indicates whether a unicast address is an external or internal address.

Parameters
[in]aAddressA reference to the unicast address.
Return values
TRUEThe address is an external address.
FALSEThe address is not an external address (it is an OpenThread internal address).

References Netif::mExtUnicastAddressPool.

Referenced by Netif::AddExternalUnicastAddress(), Netif::HasUnicastAddress(), Netif::RemoveAllExternalUnicastAddresses(), and Netif::RemoveExternalUnicastAddress().

§ AddExternalUnicastAddress()

Error AddExternalUnicastAddress ( const UnicastAddress aAddress)

This method adds an external (to OpenThread) unicast address to the network interface.

For external address, the aAddress instance is not directly used (i.e., it can be temporary). It is copied into a local entry (allocated from an internal pool) before being added in the unicast address linked list. The maximum number of external addresses is specified by OPENTHREAD_CONFIG_IP6_MAX_EXT_UCAST_ADDRS.

Parameters
[in]aAddressA reference to the unicast address.
Return values
kErrorNoneSuccessfully added (or updated) the unicast address.
kErrorInvalidArgsThe address indicated by aAddress is an internal address.
kErrorNoBufsThe maximum number of allowed external addresses are already added.

References ExitNow, Netif::UnicastAddress::GetAddress(), Address::IsLinkLocal(), Address::IsMulticast(), Netif::IsUnicastAddressExternal(), Netif::kAddressAdded, ot::kErrorAlready, ot::kErrorInvalidArgs, ot::kErrorNoBufs, ot::kErrorNone, ot::kEventIp6AddressAdded, otNetifAddress::mAddressOrigin, Netif::mExtUnicastAddressPool, otNetifAddress::mPreferred, otNetifAddress::mPrefixLength, Netif::mUnicastAddresses, otNetifAddress::mValid, and VerifyOrExit.

Referenced by Netif::HasUnicastAddress().

§ RemoveExternalUnicastAddress()

Error RemoveExternalUnicastAddress ( const Address aAddress)

This method removes a external (to OpenThread) unicast address from the network interface.

Parameters
[in]aAddressA reference to the unicast address.
Return values
kErrorNoneSuccessfully removed the unicast address.
kErrorInvalidArgsThe address indicated by aAddress is an internal address.
kErrorNotFoundThe unicast address was not found.

References Netif::IsUnicastAddressExternal(), Netif::kAddressRemoved, ot::kErrorNone, ot::kErrorNotFound, ot::kErrorRejected, ot::kEventIp6AddressRemoved, Netif::mExtUnicastAddressPool, Netif::mUnicastAddresses, and VerifyOrExit.

Referenced by Netif::HasUnicastAddress(), and Netif::RemoveAllExternalUnicastAddresses().

§ RemoveAllExternalUnicastAddresses()

void RemoveAllExternalUnicastAddresses ( void  )

This method removes all the previously added external (to OpenThread) unicast addresses from the network interface.

References LinkedListEntry< Type >::GetNext(), IgnoreError(), Netif::IsUnicastAddressExternal(), Netif::mUnicastAddresses, and Netif::RemoveExternalUnicastAddress().

Referenced by ThreadNetif::Down(), and Netif::HasUnicastAddress().

§ IsMulticastSubscribed()

bool IsMulticastSubscribed ( const Address aAddress) const

This method indicates whether or not the network interface is subscribed to a multicast address.

Parameters
[in]aAddressThe multicast address to check.
Return values
TRUEIf the network interface is subscribed to aAddress.
FALSEIf the network interface is not subscribed to aAddress.

References Netif::mMulticastAddresses.

Referenced by Netif::HasUnicastAddress(), and Netif::SubscribeExternalMulticast().

§ SubscribeAllRoutersMulticast()

void SubscribeAllRoutersMulticast ( void  )

§ UnsubscribeAllRoutersMulticast()

void UnsubscribeAllRoutersMulticast ( void  )

§ GetMulticastAddresses()

const LinkedList<MulticastAddress>& GetMulticastAddresses ( void  ) const
inline

§ IsMulticastAddressExternal()

bool IsMulticastAddressExternal ( const MulticastAddress aAddress) const

This method indicates whether a multicast address is an external or internal address.

Parameters
[in]aAddressA reference to the multicast address.
Return values
TRUEThe address is an external address.
FALSEThe address is not an external address (it is an OpenThread internal address).

References Netif::mExtMulticastAddressPool.

Referenced by Netif::ExternalMulticastAddress::Iterator::AdvanceFrom(), Netif::GetMulticastAddresses(), Netif::UnsubscribeAllExternalMulticastAddresses(), and Netif::UnsubscribeExternalMulticast().

§ SubscribeMulticast()

void SubscribeMulticast ( MulticastAddress aAddress)

This method subscribes the network interface to a multicast address.

This method is intended for addresses internal to OpenThread. The aAddress instance is directly added in the multicast address linked list.

Parameters
[in]aAddressA reference to the multicast address.

References Netif::kAddressAdded, ot::kEventIp6MulticastSubscribed, Netif::kOriginThread, Netif::mAddressCallback, Netif::mAddressCallbackContext, Netif::mMulticastAddresses, and SuccessOrExit.

Referenced by Netif::GetMulticastAddresses().

§ UnsubscribeMulticast()

void UnsubscribeMulticast ( const MulticastAddress aAddress)

This method unsubscribes the network interface to a multicast address.

This method is intended for addresses internal to OpenThread. The aAddress instance is directly removed from the multicast address linked list.

Parameters
[in]aAddressA reference to the multicast address.

References Netif::kAddressRemoved, ot::kEventIp6MulticastUnsubscribed, Netif::kOriginThread, Netif::mAddressCallback, Netif::mAddressCallbackContext, Netif::mMulticastAddresses, and SuccessOrExit.

Referenced by Netif::GetMulticastAddresses().

§ SubscribeExternalMulticast()

Error SubscribeExternalMulticast ( const Address aAddress)

This method subscribes the network interface to the external (to OpenThread) multicast address.

For external address, the aAddress instance is not directly used (i.e., it can be temporary). It is copied into a local entry (allocated from an internal pool) before being added in the multicast address linked list. The maximum number of external addresses is specified by OPENTHREAD_CONFIG_IP6_MAX_EXT_MCAST_ADDRS.

Parameters
[in]aAddressA reference to the multicast address.
Return values
kErrorNoneSuccessfully subscribed to aAddress.
kErrorAlreadyThe multicast address is already subscribed.
kErrorInvalidArgsThe IP Address indicated by aAddress is an invalid multicast address.
kErrorRejectedThe IP Address indicated by aAddress is an internal multicast address.
kErrorNoBufsThe maximum number of allowed external multicast addresses are already added.

References ot::AsCoreType(), ot::AsNonConst(), Netif::MulticastAddress::GetNext(), Address::IsMulticast(), Netif::IsMulticastSubscribed(), Netif::kAddressAdded, ot::kErrorAlready, ot::kErrorInvalidArgs, ot::kErrorNoBufs, ot::kErrorNone, ot::kErrorRejected, ot::kEventIp6MulticastSubscribed, Netif::kLinkLocalAllRoutersMulticastAddress, Netif::kOriginManual, Netif::mExtMulticastAddressPool, Netif::mMulticastAddresses, and VerifyOrExit.

Referenced by Netif::GetMulticastAddresses().

§ UnsubscribeExternalMulticast()

Error UnsubscribeExternalMulticast ( const Address aAddress)

This method unsubscribes the network interface to the external (to OpenThread) multicast address.

Parameters
[in]aAddressA reference to the multicast address.
Return values
kErrorNoneSuccessfully unsubscribed to the unicast address.
kErrorRejectedThe address indicated by aAddress is an internal address.
kErrorNotFoundThe multicast address was not found.

References Netif::IsMulticastAddressExternal(), Netif::kAddressRemoved, ot::kErrorNone, ot::kErrorNotFound, ot::kErrorRejected, ot::kEventIp6MulticastUnsubscribed, Netif::kOriginManual, Netif::mExtMulticastAddressPool, Netif::mMulticastAddresses, and VerifyOrExit.

Referenced by Netif::GetMulticastAddresses(), and Netif::UnsubscribeAllExternalMulticastAddresses().

§ UnsubscribeAllExternalMulticastAddresses()

void UnsubscribeAllExternalMulticastAddresses ( void  )

This method unsubscribes the network interface from all previously added external (to OpenThread) multicast addresses.

References Netif::MulticastAddress::GetNext(), IgnoreError(), Netif::IsMulticastAddressExternal(), Netif::mMulticastAddresses, and Netif::UnsubscribeExternalMulticast().

Referenced by ThreadNetif::Down(), and Netif::GetMulticastAddresses().

§ IsMulticastPromiscuousEnabled()

bool IsMulticastPromiscuousEnabled ( void  ) const
inline

This method checks if multicast promiscuous mode is enabled on the network interface.

Return values
TRUEIf the multicast promiscuous mode is enabled.
FALSEIf the multicast promiscuous mode is disabled.

References Netif::mMulticastPromiscuous.

§ SetMulticastPromiscuous()

void SetMulticastPromiscuous ( bool  aEnabled)
inline

This method enables multicast promiscuous mode on the network interface.

Parameters
[in]aEnabledTRUE if Multicast Promiscuous mode is enabled, FALSE otherwise.

References Netif::mMulticastPromiscuous.

§ IterateExternalMulticastAddresses()

ExternalMulticastAddress::Iterator::Builder IterateExternalMulticastAddresses ( Address::TypeFilter  aFilter = Address::kTypeAny)
inline

This method enables range-based for loop iteration over external multicast addresses on the Netif that matches a given IPv6 address type filter.

This method should be used like follows: to iterate over all external multicast addresses

for (Ip6::Netif::ExternalMulticastAddress &addr : Get<ThreadNetif>().IterateExternalMulticastAddresses())
{ ... }

or to iterate over a subset of external multicast addresses determined by a given address type filter

for (Ip6::Netif::ExternalMulticastAddress &addr :
     Get<ThreadNetif>().IterateExternalMulticastAddresses(Ip6::Address::kTypeMulticastLargerThanRealmLocal))
{ ... }
Parameters
[in]aFilterThe IPv6 address type filter.
Returns
An ExternalMulticastAddress::Iterator::Builder instance.

§ HasAnyExternalMulticastAddress()

bool HasAnyExternalMulticastAddress ( void  ) const
inline

This method indicates whether or not the network interfaces is subscribed to any external multicast address.

Return values
TRUEThe network interface is subscribed to at least one external multicast address.
FALSEThe network interface is not subscribed to any external multicast address.

References Netif::SubscribeAllNodesMulticast(), and Netif::UnsubscribeAllNodesMulticast().

§ SubscribeAllNodesMulticast()

void SubscribeAllNodesMulticast ( void  )
protected

§ UnsubscribeAllNodesMulticast()

void UnsubscribeAllNodesMulticast ( void  )
protected

Friends And Related Function Documentation

§ Ip6

friend class Ip6
friend

§ Address

friend class Address
friend

Field Documentation

§ mUnicastAddresses

LinkedList<UnicastAddress> mUnicastAddresses
private

§ mMulticastAddresses

LinkedList<MulticastAddress> mMulticastAddresses
private

§ mMulticastPromiscuous

bool mMulticastPromiscuous
private

§ mAddressCallback

otIp6AddressCallback mAddressCallback
private

§ mAddressCallbackContext

void* mAddressCallbackContext
private

§ mExtUnicastAddressPool

§ mExtMulticastAddressPool

§ kRealmLocalAllMplForwardersMulticastAddress

const otNetifMulticastAddress kRealmLocalAllMplForwardersMulticastAddress
staticprivate
Initial value:
= {
{{{0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc}}},
nullptr}

Referenced by Address::GetRealmLocalAllMplForwarders().

§ kLinkLocalAllNodesMulticastAddress

const otNetifMulticastAddress kLinkLocalAllNodesMulticastAddress
staticprivate

§ kRealmLocalAllNodesMulticastAddress

const otNetifMulticastAddress kRealmLocalAllNodesMulticastAddress
staticprivate
Initial value:
= {
{{{0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}}},

Referenced by Address::GetRealmLocalAllNodesMulticast().

§ kLinkLocalAllRoutersMulticastAddress

const otNetifMulticastAddress kLinkLocalAllRoutersMulticastAddress
staticprivate
Initial value:
= {
{{{0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02}}},

Referenced by Address::GetLinkLocalAllRoutersMulticast(), Netif::SubscribeAllRoutersMulticast(), Netif::SubscribeExternalMulticast(), and Netif::UnsubscribeAllRoutersMulticast().

§ kRealmLocalAllRoutersMulticastAddress

const otNetifMulticastAddress kRealmLocalAllRoutersMulticastAddress
staticprivate
Initial value:
= {
{{{0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02}}},

Referenced by Address::GetRealmLocalAllRoutersMulticast(), Netif::SubscribeAllRoutersMulticast(), and Netif::UnsubscribeAllNodesMulticast().


The documentation for this class was generated from the following files:
© Copyright 1995-2022, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale