This class can contain 16 bit addresses. More...
#include "mac16-address.h"
Public Member Functions | |
| Mac16Address ()=default | |
| Mac16Address (const char *str) | |
| Mac16Address (uint16_t addr) | |
| Address | ConvertTo () const |
| uint16_t | ConvertToInt () const |
| void | CopyFrom (const uint8_t buffer[2]) |
| void | CopyTo (uint8_t buffer[2]) const |
| bool | IsBroadcast () const |
| Checks if the address is a broadcast address according to 802.15.4 scheme (i.e., 0xFFFF). | |
| bool | IsMulticast () const |
| Checks if the address is a multicast address according to RFC 4944 Section 9 (i.e., if its first 3 bits are 100). | |
| operator Address () const | |
| constexpr std::strong_ordering | operator<=> (const Mac16Address &other) const =default |
| Spaceship comparison operator. | |
Static Public Member Functions | |
| static Mac16Address | Allocate () |
| Allocate a new Mac16Address. | |
| static Mac16Address | ConvertFrom (const Address &address) |
| static Mac16Address | GetBroadcast () |
| static Mac16Address | GetMulticast (Ipv6Address address) |
| Returns the multicast address associated with an IPv6 address according to RFC 4944 Section 9. | |
| static bool | IsMatchingType (const Address &address) |
| static void | ResetAllocationIndex () |
| Reset the Mac16Address allocation index. | |
Static Private Member Functions | |
| static uint8_t | GetType () |
| Return the Type of address. | |
Private Attributes | |
| std::array< uint8_t, 2 > | m_address {} |
| Address value. | |
Static Private Attributes | |
| static uint64_t | m_allocationIndex = 0 |
| Address allocation index. | |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const Mac16Address &address) |
| Stream insertion operator. | |
| std::istream & | operator>> (std::istream &is, Mac16Address &address) |
| Stream extraction operator. | |
This class can contain 16 bit addresses.
Definition at line 34 of file mac16-address.h.
|
default |
References Mac16Address().
Referenced by Mac16Address(), Allocate(), ConvertFrom(), GetBroadcast(), GetMulticast(), operator<<, operator<=>(), and operator>>.
| ns3::Mac16Address::Mac16Address | ( | const char * | str | ) |
| str | a string representing the new Mac16Address |
The format of the string is "xx:xx"
Definition at line 29 of file mac16-address.cc.
References m_address, NS_ASSERT_MSG, and NS_LOG_FUNCTION.
| ns3::Mac16Address::Mac16Address | ( | uint16_t | addr | ) |
| addr | The 16 bit unsigned integer used to create a Mac16Address object. |
Create a Mac16Address from an 16 bit unsigned integer.
Definition at line 43 of file mac16-address.cc.
References m_address, and NS_LOG_FUNCTION.
|
static |
Allocate a new Mac16Address.
Definition at line 104 of file mac16-address.cc.
References Mac16Address(), m_allocationIndex, NS_LOG_FUNCTION_NOARGS, ResetAllocationIndex(), and ns3::Simulator::ScheduleDestroy().
|
static |
| address | a polymorphic address |
This function performs a type check and asserts if the type of the input address is not compatible with an Mac16Address.
Definition at line 78 of file mac16-address.cc.
References Mac16Address(), GetType(), m_address, NS_ASSERT, and NS_LOG_FUNCTION.
Referenced by ns3::Ipv6Address::MakeAutoconfiguredAddress(), ns3::Ipv6Address::MakeAutoconfiguredLinkLocalAddress(), ns3::Ipv6AddressHelper::NewAddress(), ns3::SixLowPanMesh::Print(), ns3::SixLowPanNetDevice::ReceiveFromDevice(), ns3::lrwpan::LrWpanNetDevice::Send(), and ns3::lrwpan::LrWpanNetDevice::SetAddress().
| Address ns3::Mac16Address::ConvertTo | ( | ) | const |
Convert an instance of this class to a polymorphic Address instance.
Definition at line 88 of file mac16-address.cc.
References GetType(), m_address, and NS_LOG_FUNCTION.
Referenced by operator Address().
| uint16_t ns3::Mac16Address::ConvertToInt | ( | ) | const |
Convert an instance of this class to a 16 bit unsigned integer.
Definition at line 95 of file mac16-address.cc.
References m_address.
Referenced by ns3::zigbee::ZigbeeNwk::FindNextHop(), ns3::zigbee::ZigbeeNwk::McpsDataIndication(), and ns3::zigbee::ZigbeeNwk::ReceiveMulticastMemberFrame().
| void ns3::Mac16Address::CopyFrom | ( | const uint8_t | buffer[2] | ) |
| buffer | address in network order |
Copy the input address to our internal buffer.
Definition at line 51 of file mac16-address.cc.
References m_address, and NS_LOG_FUNCTION.
Referenced by AssociateIndication(), ns3::LrWpanHelper::CreateAssociatedPan(), ns3::SixLowPanNetDevice::Get16MacFrom48Mac(), GetMulticast(), ns3::ReadFrom(), ns3::lrwpan::LrWpanNetDevice::Send(), and ns3::lrwpan::LrWpanNetDevice::SetAddress().
| void ns3::Mac16Address::CopyTo | ( | uint8_t | buffer[2] | ) | const |
| buffer | address in network order |
Copy the internal address to the input buffer.
Definition at line 58 of file mac16-address.cc.
References m_address, and NS_LOG_FUNCTION.
Referenced by ns3::lrwpan::LrWpanNetDevice::BuildPseudoMacAddress(), ns3::Ipv6Address::MakeAutoconfiguredAddress(), ns3::Ipv6Address::MakeAutoconfiguredLinkLocalAddress(), and ns3::WriteTo().
|
static |
Definition at line 137 of file mac16-address.cc.
References Mac16Address(), and NS_LOG_FUNCTION_NOARGS.
Referenced by LrWpanAckTestCase::DoRun(), ns3::lrwpan::LrWpanNetDevice::GetBroadcast(), ns3::MockNetDevice::GetBroadcast(), and ns3::zigbee::ZigbeeNwk::SendRREQ().
|
static |
Returns the multicast address associated with an IPv6 address according to RFC 4944 Section 9.
An IPv6 packet with a multicast destination address (DST), consisting of the sixteen octets DST[1] through DST[16], is transmitted to the following 802.15.4 16-bit multicast address:
0 1 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |1 0 0|DST[15]* | DST[16] | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Here, DST[15]* refers to the last 5 bits in octet DST[15], that is, bits 3-7 within DST[15]. The initial 3-bit pattern of "100" follows the 16-bit address format for multicast addresses (Section 12).
| address | base IPv6 address |
Definition at line 146 of file mac16-address.cc.
References Mac16Address(), CopyFrom(), and NS_LOG_FUNCTION.
Referenced by LrWpanAckTestCase::DoRun(), ns3::lrwpan::LrWpanNetDevice::GetMulticast(), ns3::MockNetDevice::GetMulticast(), and ns3::MockNetDevice::GetMulticast().
|
staticprivate |
Return the Type of address.
Definition at line 128 of file mac16-address.cc.
References NS_LOG_FUNCTION_NOARGS, and ns3::Address::Register().
Referenced by ConvertFrom(), ConvertTo(), and IsMatchingType().
| bool ns3::Mac16Address::IsBroadcast | ( | ) | const |
Checks if the address is a broadcast address according to 802.15.4 scheme (i.e., 0xFFFF).
Definition at line 165 of file mac16-address.cc.
References m_address, and NS_LOG_FUNCTION.
Referenced by LrWpanDataIfsTestCase::DataReceivedDev0(), LrWpanDataIfsTestCase::DataReceivedDev1(), ns3::lrwpan::LrWpanMac::McpsDataRequest(), ns3::lrwpan::LrWpanMac::PdDataIndication(), ns3::SixLowPanNetDevice::ReceiveFromDevice(), ns3::zigbee::ZigbeeNwk::ReceiveMulticastNonMemberFrame(), and ns3::lrwpan::LrWpanMac::RemoveFirstTxQElement().
|
static |
| address | address to test |
Definition at line 65 of file mac16-address.cc.
References GetType(), and NS_LOG_FUNCTION.
Referenced by ns3::MockNetDevice::GetBroadcast(), ns3::MockNetDevice::GetMulticast(), ns3::MockNetDevice::GetMulticast(), ns3::Ipv6Address::MakeAutoconfiguredAddress(), ns3::Ipv6Address::MakeAutoconfiguredLinkLocalAddress(), ns3::Ipv6AddressHelper::NewAddress(), ns3::SixLowPanNetDevice::ReceiveFromDevice(), ns3::lrwpan::LrWpanNetDevice::SetAddress(), ns3::SixLowPanMesh::SetFinalDst(), and ns3::SixLowPanMesh::SetOriginator().
| bool ns3::Mac16Address::IsMulticast | ( | ) | const |
Checks if the address is a multicast address according to RFC 4944 Section 9 (i.e., if its first 3 bits are 100).
Definition at line 172 of file mac16-address.cc.
References m_address, and NS_LOG_FUNCTION.
Referenced by ns3::lrwpan::LrWpanMac::McpsDataRequest(), ns3::lrwpan::LrWpanMac::PdDataIndication(), ns3::SixLowPanNetDevice::ReceiveFromDevice(), and ns3::lrwpan::LrWpanMac::RemoveFirstTxQElement().
| ns3::Mac16Address::operator Address | ( | ) | const |
Convert an instance of this class to a polymorphic Address instance.
Definition at line 71 of file mac16-address.cc.
References ConvertTo().
|
constexprdefault |
Spaceship comparison operator.
All the other comparison operators are automatically generated from this one.
| other | address to compare to this one |
References Mac16Address().
|
static |
Reset the Mac16Address allocation index.
This function resets (to zero) the global integer that is used for unique address allocation. It is automatically called whenever
is called. It may also be optionally called by user code if there is a need to force a reset of this allocation index.
Definition at line 121 of file mac16-address.cc.
References m_allocationIndex, and NS_LOG_FUNCTION_NOARGS.
Referenced by Allocate().
|
friend |
Stream insertion operator.
| os | the stream |
| address | the address |
Definition at line 180 of file mac16-address.cc.
References Mac16Address().
|
friend |
Stream extraction operator.
| is | the stream |
| address | the address |
Definition at line 197 of file mac16-address.cc.
References Mac16Address(), and v.
|
private |
Address value.
Definition at line 205 of file mac16-address.h.
Referenced by Mac16Address(), Mac16Address(), ConvertFrom(), ConvertTo(), ConvertToInt(), CopyFrom(), CopyTo(), IsBroadcast(), and IsMulticast().
|
staticprivate |
Address allocation index.
Definition at line 204 of file mac16-address.h.
Referenced by Allocate(), ns3::Mac16AddressValue::Copy(), and ResetAllocationIndex().