openthread-br
0.3.0-72c0388
|
Go to the documentation of this file.
34 #ifndef OTBR_COMMON_TYPES_HPP_
35 #define OTBR_COMMON_TYPES_HPP_
39 #include <netinet/in.h>
52 #define IN6ADDR_ANY "::"
55 #define OTBR_IP6_ADDRESS_SIZE 16
56 #define OTBR_IP6_PREFIX_SIZE 8
57 #define OTBR_IP4_ADDRESS_SIZE 4
58 #define OTBR_NETWORK_KEY_SIZE 16
59 #define OTBR_PSKC_SIZE 16
101 static constexpr
char kSolicitedMulticastAddressPrefix[] =
"ff02::01:ff00:0";
102 static constexpr
char kLinkLocalAllNodesMulticastAddress[] =
"ff02::01";
132 m8[14] = aLocator >> 8;
133 m8[15] = aLocator & 0xff;
170 uint16_t
ToLocator(
void)
const {
return static_cast<uint16_t
>(m8[14] << 8 | m8[15]); }
211 bool IsLinkLocal(
void)
const {
return (m16[0] & bswap_16(0xffc0)) == bswap_16(0xfe80); }
220 bool IsLoopback(
void)
const {
return (m32[0] == 0 && m32[1] == 0 && m32[2] == 0 && m32[3] == htobe32(1)); }
230 static Ip6Address sLinkLocalAllNodesMulticastAddress =
FromString(kLinkLocalAllNodesMulticastAddress);
232 return sLinkLocalAllNodesMulticastAddress;
243 static Ip6Address sSolicitedMulticastAddressPrefix =
FromString(kSolicitedMulticastAddressPrefix);
245 return sSolicitedMulticastAddressPrefix;
266 void CopyTo(
struct sockaddr_in6 &aSockAddr)
const;
274 void CopyFrom(
const struct sockaddr_in6 &aSockAddr);
282 void CopyTo(
struct in6_addr &aIn6Addr)
const;
290 void CopyFrom(
const struct in6_addr &aIn6Addr);
323 void Set(
const otIp6Prefix &aPrefix);
337 void Clear(
void) { memset(
reinterpret_cast<void *
>(
this), 0,
sizeof(*
this)); }
397 static constexpr uint32_t kEmaFactorNumerator = 1;
398 static constexpr uint32_t kEmaFactorDenominator = 2;
400 static_assert(kEmaFactorNumerator > 0,
"kEmaFactorNumerator must be greater than 0");
401 static_assert(kEmaFactorDenominator > kEmaFactorNumerator,
402 "kEmaFactorDenominator must be greater than kEmaFactorNumerator");
417 #endif // OTBR_COMMON_TYPES_HPP_
bool IsValid(void) const
Definition: types.hpp:345
uint32_t mNotImplemented
The number of 'not implemented' responses.
Definition: types.hpp:389
Definition: types.hpp:354
uint32_t mInvalidState
The number of 'invalid state' responses.
Definition: types.hpp:392
std::string ToString(void) const
Definition: types.cpp:44
Ip6Address(uint16_t aLocator)
Definition: types.hpp:127
@ kSizePSKc
Size of PSKc.
Definition: types.hpp:94
uint32_t mDuplicated
The number of 'duplicated' responses.
Definition: types.hpp:388
uint16_t ToLocator(void) const
Definition: types.hpp:170
@ OTBR_ERROR_ERRNO
Error defined by errno.
Definition: types.hpp:74
@ OTBR_ERROR_DBUS
DBus error.
Definition: types.hpp:75
uint32_t mHostRegistrationEmaLatency
The EMA latency of host registrations in milliseconds.
Definition: types.hpp:409
uint32_t mSuccess
The number of successful responses.
Definition: types.hpp:385
@ OTBR_ERROR_INVALID_STATE
The target isn't in a valid state.
Definition: types.hpp:86
bool IsLoopback(void) const
Definition: types.hpp:220
Ip6Prefix(void)
Definition: types.hpp:315
uint32_t mUnknownError
The number of unknown error responses.
Definition: types.hpp:390
@ OTBR_ERROR_INFRA_LINK_CHANGED
The infrastructure link is changed.
Definition: types.hpp:87
MacAddress(void)
Definition: types.hpp:361
static otbrError FromString(const char *aStr, Ip6Address &aAddr)
Definition: types.cpp:89
@ OTBR_ERROR_PARSE
Parse error.
Definition: types.hpp:81
Ip6Address ToSolicitedNodeMulticastAddress(void) const
Definition: types.cpp:54
Ip6Address mPrefix
The IPv6 prefix.
Definition: types.hpp:347
static const Ip6Address & GetSolicitedMulticastAddressPrefix(void)
Definition: types.hpp:241
@ kSizeEui64
Size of Eui64.
Definition: types.hpp:97
bool IsLinkLocal(void) const
Definition: types.hpp:211
@ OTBR_ERROR_INVALID_ARGS
Invalid arguments error.
Definition: types.hpp:83
@ OTBR_ERROR_MDNS
mDNS error.
Definition: types.hpp:76
@ OTBR_ERROR_SMCROUTE
SMCRoute error.
Definition: types.hpp:79
std::string ToString(void) const
Definition: types.cpp:129
Ip6Address(void)
Definition: types.hpp:115
@ OTBR_ERROR_ABORTED
The operation is aborted.
Definition: types.hpp:85
uint32_t mServiceRegistrationEmaLatency
The EMA latency of service registrations in milliseconds.
Definition: types.hpp:410
bool IsUnspecified(void) const
Definition: types.hpp:195
uint32_t mInvalidArgs
The number of 'invalid arg' responses.
Definition: types.hpp:387
void CopyFrom(const struct sockaddr_in6 &aSockAddr)
Definition: types.cpp:72
@ OTBR_ERROR_DUPLICATED
Duplicated operation, resource or name.
Definition: types.hpp:84
uint32_t mAborted
The number of aborted responses.
Definition: types.hpp:391
void CopyTo(struct sockaddr_in6 &aSockAddr) const
Definition: types.cpp:65
void Clear(void)
Definition: types.hpp:337
@ OTBR_ERROR_NONE
No error.
Definition: types.hpp:72
@ OTBR_ERROR_OPENTHREAD
OpenThread error.
Definition: types.hpp:77
Definition: types.hpp:395
void Set(const otIp6Prefix &aPrefix)
Definition: types.cpp:107
otbrError
Definition: types.hpp:70
@ kSizeExtPanId
Size of Extended PAN ID.
Definition: types.hpp:96
@ kSizeNetworkName
Max size of Network Name.
Definition: types.hpp:95
@ OTBR_ERROR_REST
Rest Server error.
Definition: types.hpp:78
uint32_t mNotFound
The number of 'not found' responses.
Definition: types.hpp:386
@ OTBR_ERROR_NOT_IMPLEMENTED
Not implemented error.
Definition: types.hpp:82
std::string ToString(void) const
Definition: types.cpp:112
Definition: types.hpp:308
@ OTBR_ERROR_NOT_FOUND
Not found.
Definition: types.hpp:80
Definition: types.hpp:383
Definition: types.hpp:108
bool operator==(const Ip6Address &aOther) const
Definition: types.hpp:162
uint8_t mLength
The IPv6 prefix length (in bits).
Definition: types.hpp:348
uint32_t mHostResolutionEmaLatency
The EMA latency of host resolutions in milliseconds.
Definition: types.hpp:411
bool IsMulticast(void) const
Definition: types.hpp:203
uint32_t mServiceResolutionEmaLatency
The EMA latency of service resolutions in milliseconds.
Definition: types.hpp:412
@ kSizeExtAddr
Size of Extended Address.
Definition: types.hpp:98
bool operator<(const Ip6Address &aOther) const
Definition: types.hpp:152
static const Ip6Address & GetLinkLocalAllNodesMulticastAddress(void)
Definition: types.hpp:228