![]() |
![]() |
|
OpenThread
1.05.03.02
|
#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 } |
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 | |
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 | |
| NonCopyable & | operator= (const NonCopyable &)=delete |
| NonCopyable (void)=default | |
This class implements an IPv6 network interface.
| enum AddressEvent : bool |
| enum AddressOrigin : uint8_t |
This constructor initializes the network interface.
| [in] | aInstance | A reference to the OpenThread instance. |
Referenced by Netif::ExternalMulticastAddress::GetNext().
| void SetAddressCallback | ( | otIp6AddressCallback | aCallback, |
| void * | aCallbackContext | ||
| ) |
This method registers a callback to notify internal IPv6 address changes.
| [in] | aCallback | A pointer to a function that is called when an IPv6 address is added or removed. |
| [in] | aCallbackContext | A pointer to application-specific context. |
References Netif::mAddressCallback, and Netif::mAddressCallbackContext.
Referenced by Netif::ExternalMulticastAddress::GetNext().
|
inline |
This method returns the linked list of unicast addresses.
References Netif::AddUnicastAddress(), Netif::HasUnicastAddress(), Netif::mUnicastAddresses, and Netif::RemoveUnicastAddress().
| 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.
| [in] | aAddress | A 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().
| 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.
| [in] | aAddress | A 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().
| bool HasUnicastAddress | ( | const Address & | aAddress | ) | const |
This method indicates whether or not an address is assigned to the interface.
| [in] | aAddress | A reference to the unicast address. |
| TRUE | If aAddress is assigned to the network interface, |
| FALSE | If aAddress is not assigned to the network interface. |
References Netif::mUnicastAddresses.
Referenced by Netif::GetUnicastAddresses().
|
inline |
This method indicates whether or not a unicast address is assigned to the network interface.
| [in] | aAddress | A reference to the unicast address. |
| TRUE | If aAddress is assigned to the network interface, |
| FALSE | If 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().
| bool IsUnicastAddressExternal | ( | const UnicastAddress & | aAddress | ) | const |
This method indicates whether a unicast address is an external or internal address.
| [in] | aAddress | A reference to the unicast address. |
| TRUE | The address is an external address. |
| FALSE | The 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().
| 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.
| [in] | aAddress | A reference to the unicast address. |
| kErrorNone | Successfully added (or updated) the unicast address. |
| kErrorInvalidArgs | The address indicated by aAddress is an internal address. |
| kErrorNoBufs | The 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().
This method removes a external (to OpenThread) unicast address from the network interface.
| [in] | aAddress | A reference to the unicast address. |
| kErrorNone | Successfully removed the unicast address. |
| kErrorInvalidArgs | The address indicated by aAddress is an internal address. |
| kErrorNotFound | The 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().
| 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().
| bool IsMulticastSubscribed | ( | const Address & | aAddress | ) | const |
This method indicates whether or not the network interface is subscribed to a multicast address.
| [in] | aAddress | The multicast address to check. |
| TRUE | If the network interface is subscribed to aAddress. |
| FALSE | If the network interface is not subscribed to aAddress. |
References Netif::mMulticastAddresses.
Referenced by Netif::HasUnicastAddress(), and Netif::SubscribeExternalMulticast().
| void SubscribeAllRoutersMulticast | ( | void | ) |
This method subscribes the network interface to the link-local and realm-local all routers addresses.
SubscribeAllNodesMulticast() or its behavior is undefined. References ot::AsCoreType(), ot::AsNonConst(), Netif::MulticastAddress::GetNext(), Netif::kAddressAdded, ot::kEventIp6MulticastSubscribed, Netif::kLinkLocalAllNodesMulticastAddress, Netif::kLinkLocalAllRoutersMulticastAddress, Netif::kOriginThread, Netif::kRealmLocalAllRoutersMulticastAddress, Netif::mAddressCallback, Netif::mAddressCallbackContext, Netif::mMulticastAddresses, LinkedListEntry< Type >::SetNext(), SuccessOrAssert, and VerifyOrExit.
Referenced by Netif::HasUnicastAddress().
| void UnsubscribeAllRoutersMulticast | ( | void | ) |
This method unsubscribes the network interface to the link-local and realm-local all routers address.
References ot::AsCoreType(), ot::AsNonConst(), Netif::MulticastAddress::GetNext(), Netif::kAddressRemoved, ot::kEventIp6MulticastUnsubscribed, Netif::kLinkLocalAllNodesMulticastAddress, Netif::kLinkLocalAllRoutersMulticastAddress, Netif::kOriginThread, Netif::mAddressCallback, Netif::mAddressCallbackContext, Netif::mMulticastAddresses, LinkedListEntry< Type >::SetNext(), SuccessOrExit, and VerifyOrExit.
Referenced by ThreadNetif::Down(), and Netif::HasUnicastAddress().
|
inline |
This method returns the linked list of multicast addresses.
References Netif::IsMulticastAddressExternal(), Netif::mMulticastAddresses, Netif::SubscribeExternalMulticast(), Netif::SubscribeMulticast(), Netif::UnsubscribeAllExternalMulticastAddresses(), Netif::UnsubscribeExternalMulticast(), and Netif::UnsubscribeMulticast().
Referenced by Netif::ExternalMulticastAddress::Iterator::Iterator().
| bool IsMulticastAddressExternal | ( | const MulticastAddress & | aAddress | ) | const |
This method indicates whether a multicast address is an external or internal address.
| [in] | aAddress | A reference to the multicast address. |
| TRUE | The address is an external address. |
| FALSE | The 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().
| 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.
| [in] | aAddress | A reference to the multicast address. |
References Netif::kAddressAdded, ot::kEventIp6MulticastSubscribed, Netif::kOriginThread, Netif::mAddressCallback, Netif::mAddressCallbackContext, Netif::mMulticastAddresses, and SuccessOrExit.
Referenced by Netif::GetMulticastAddresses().
| 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.
| [in] | aAddress | A reference to the multicast address. |
References Netif::kAddressRemoved, ot::kEventIp6MulticastUnsubscribed, Netif::kOriginThread, Netif::mAddressCallback, Netif::mAddressCallbackContext, Netif::mMulticastAddresses, and SuccessOrExit.
Referenced by Netif::GetMulticastAddresses().
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.
| [in] | aAddress | A reference to the multicast address. |
| kErrorNone | Successfully subscribed to aAddress. |
| kErrorAlready | The multicast address is already subscribed. |
| kErrorInvalidArgs | The IP Address indicated by aAddress is an invalid multicast address. |
| kErrorRejected | The IP Address indicated by aAddress is an internal multicast address. |
| kErrorNoBufs | The 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().
This method unsubscribes the network interface to the external (to OpenThread) multicast address.
| [in] | aAddress | A reference to the multicast address. |
| kErrorNone | Successfully unsubscribed to the unicast address. |
| kErrorRejected | The address indicated by aAddress is an internal address. |
| kErrorNotFound | The 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().
| 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().
|
inline |
This method checks if multicast promiscuous mode is enabled on the network interface.
| TRUE | If the multicast promiscuous mode is enabled. |
| FALSE | If the multicast promiscuous mode is disabled. |
References Netif::mMulticastPromiscuous.
|
inline |
This method enables multicast promiscuous mode on the network interface.
| [in] | aEnabled | TRUE if Multicast Promiscuous mode is enabled, FALSE otherwise. |
References Netif::mMulticastPromiscuous.
|
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))
{ ... }
| [in] | aFilter | The IPv6 address type filter. |
ExternalMulticastAddress::Iterator::Builder instance.
|
inline |
This method indicates whether or not the network interfaces is subscribed to any external multicast address.
| TRUE | The network interface is subscribed to at least one external multicast address. |
| FALSE | The network interface is not subscribed to any external multicast address. |
References Netif::SubscribeAllNodesMulticast(), and Netif::UnsubscribeAllNodesMulticast().
|
protected |
This method subscribes the network interface to the realm-local all MPL forwarders, link-local, and realm-local all nodes address.
References ot::AsCoreType(), ot::AsNonConst(), Netif::MulticastAddress::GetNext(), Netif::kAddressAdded, ot::kEventIp6MulticastSubscribed, Netif::kLinkLocalAllNodesMulticastAddress, Netif::kOriginThread, Netif::mAddressCallback, Netif::mAddressCallbackContext, Netif::mMulticastAddresses, and VerifyOrExit.
Referenced by Netif::HasAnyExternalMulticastAddress(), and ThreadNetif::Up().
|
protected |
This method unsubscribes the network interface from the realm-local all MPL forwarders, link-local and realm-local all nodes address.
UnsubscribeAllRoutersMulticast() or its behavior is undefined References ot::AsCoreType(), ot::AsCoreTypePtr(), ot::AsNonConst(), Netif::MulticastAddress::GetNext(), Netif::kAddressRemoved, ot::kEventIp6MulticastUnsubscribed, Netif::kLinkLocalAllNodesMulticastAddress, Netif::kOriginThread, Netif::kRealmLocalAllRoutersMulticastAddress, Netif::mAddressCallback, Netif::mAddressCallbackContext, Netif::mMulticastAddresses, OT_ASSERT, LinkedListEntry< Type >::SetNext(), SuccessOrExit, and VerifyOrExit.
Referenced by ThreadNetif::Down(), and Netif::HasAnyExternalMulticastAddress().
|
friend |
|
friend |
|
private |
|
private |
Referenced by Netif::GetMulticastAddresses(), Netif::IsMulticastSubscribed(), Netif::SubscribeAllNodesMulticast(), Netif::SubscribeAllRoutersMulticast(), Netif::SubscribeExternalMulticast(), Netif::SubscribeMulticast(), Netif::UnsubscribeAllExternalMulticastAddresses(), Netif::UnsubscribeAllNodesMulticast(), Netif::UnsubscribeAllRoutersMulticast(), Netif::UnsubscribeExternalMulticast(), and Netif::UnsubscribeMulticast().
|
private |
Referenced by Netif::IsMulticastPromiscuousEnabled(), and Netif::SetMulticastPromiscuous().
|
private |
Referenced by Netif::AddUnicastAddress(), Netif::RemoveUnicastAddress(), Netif::SetAddressCallback(), Netif::SubscribeAllNodesMulticast(), Netif::SubscribeAllRoutersMulticast(), Netif::SubscribeMulticast(), Netif::UnsubscribeAllNodesMulticast(), Netif::UnsubscribeAllRoutersMulticast(), and Netif::UnsubscribeMulticast().
|
private |
Referenced by Netif::AddUnicastAddress(), Netif::RemoveUnicastAddress(), Netif::SetAddressCallback(), Netif::SubscribeAllNodesMulticast(), Netif::SubscribeAllRoutersMulticast(), Netif::SubscribeMulticast(), Netif::UnsubscribeAllNodesMulticast(), Netif::UnsubscribeAllRoutersMulticast(), and Netif::UnsubscribeMulticast().
|
private |
|
private |
|
staticprivate |
Referenced by Address::GetRealmLocalAllMplForwarders().
|
staticprivate |
Referenced by Address::GetLinkLocalAllNodesMulticast(), Netif::SubscribeAllNodesMulticast(), Netif::SubscribeAllRoutersMulticast(), Netif::UnsubscribeAllNodesMulticast(), and Netif::UnsubscribeAllRoutersMulticast().
|
staticprivate |
Referenced by Address::GetRealmLocalAllNodesMulticast().
|
staticprivate |
Referenced by Address::GetLinkLocalAllRoutersMulticast(), Netif::SubscribeAllRoutersMulticast(), Netif::SubscribeExternalMulticast(), and Netif::UnsubscribeAllRoutersMulticast().
|
staticprivate |
Referenced by Address::GetRealmLocalAllRoutersMulticast(), Netif::SubscribeAllRoutersMulticast(), and Netif::UnsubscribeAllNodesMulticast().