IPv6
此模块包含可控制 IPv6 通信的函数。
总结
枚举 |
|
---|---|
anonymous enum{
|
枚举 互联网协议编号。 |
anonymous enum{
|
枚举 IPv6 地址来源。 |
anonymous enum{
|
枚举 ECN 状态,以 IP 标头表示。 |
类型定义符 |
|
---|---|
otBorderRoutingCounters
|
typedefstruct otBorderRoutingCounters
此结构表示通过边界路由转发的数据包的计数器。 |
otIp6Address
|
typedefstruct otIp6Address
此结构表示 IPv6 地址。 |
otIp6AddressCallback)(const otIp6AddressInfo *aAddressInfo, bool aIsAdded, void *aContext)
|
typedefvoid(*
添加或移除内部 IPv6 地址时,系统会调用此函数指针。 |
otIp6AddressComponents
|
typedefstruct otIp6AddressComponents
此结构表示 IPv6 地址的组成部分。 |
otIp6AddressInfo
|
typedefstruct otIp6AddressInfo
|
otIp6InterfaceIdentifier
|
typedefstruct otIp6InterfaceIdentifier
此结构表示 IPv6 地址的接口标识符。 |
otIp6NetworkPrefix
|
typedefstruct otIp6NetworkPrefix
此结构表示 IPv6 地址的网络前缀(地址的最高 64 位)。 |
otIp6Prefix
|
typedefstruct otIp6Prefix
此结构表示 IPv6 前缀。 |
otIp6ReceiveCallback)(otMessage *aMessage, void *aContext)
|
typedefvoid(*
收到 IPv6 数据报时,系统会调用此函数指针。 |
otIp6RegisterMulticastListenersCallback)(void *aContext, otError aError, uint8_t aMlrStatus, const otIp6Address *aFailedAddresses, uint8_t aFailedAddressNum)
|
typedefvoid(*
此函数指针会针对 otIp6RegisterMulticastListeners 的结果进行调用。 |
otIp6SlaacPrefixFilter)(otInstance *aInstance, const otIp6Prefix *aPrefix)
|
typedefbool(*
此函数指针可让用户过滤前缀,并且不允许根据前缀添加 SLAAC 地址。 |
otMessageInfo
|
typedefstruct otMessageInfo
此结构表示本地和对等 IPv6 套接字地址。 |
otNetifAddress
|
typedefstruct otNetifAddress
此结构表示 IPv6 网络接口单播地址。 |
otNetifMulticastAddress
|
typedefstruct otNetifMulticastAddress
此结构表示 IPv6 网络接口多播地址。 |
otPacketsAndBytes
|
typedefstruct otPacketsAndBytes
此结构表示数据包和字节的计数器。 |
otSockAddr
|
typedefstruct otSockAddr
此结构表示 IPv6 套接字地址。 |
变量 |
|
---|---|
OT_TOOL_PACKED_END
|
函数 |
|
---|---|
otIp6AddUnicastAddress(otInstance *aInstance, const otNetifAddress *aAddress)
|
将网络接口地址添加到 Thread 接口。
|
otIp6AddUnsecurePort(otInstance *aInstance, uint16_t aPort)
|
此函数将端口添加到允许的不安全端口列表中。
|
otIp6AddressFromString(const char *aString, otIp6Address *aAddress)
|
此函数会将人类可读的 IPv6 地址字符串转换为二进制表示法。
|
otIp6AddressToString(const otIp6Address *aAddress, char *aBuffer, uint16_t aSize)
|
void
此函数将指定的 IPv6 地址转换为人类可读的字符串。
|
otIp6ArePrefixesEqual(const otIp6Prefix *aFirst, const otIp6Prefix *aSecond)
|
bool
测试两个 IPv6 前缀是否相同。
|
otIp6GetBorderRoutingCounters(otInstance *aInstance)
|
const otBorderRoutingCounters *
获取边界路由计数器。
|
otIp6GetMulticastAddresses(otInstance *aInstance)
|
const otNetifMulticastAddress *
获取订阅 Thread 接口的 IPv6 多播地址列表。
|
otIp6GetPrefix(const otIp6Address *aAddress, uint8_t aLength, otIp6Prefix *aPrefix)
|
void
此方法会从
aAddress 获取带有 aLength 的前缀。 |
otIp6GetUnicastAddresses(otInstance *aInstance)
|
const otNetifAddress *
获取分配给 Thread 接口的 IPv6 地址列表。
|
otIp6GetUnsecurePorts(otInstance *aInstance, uint8_t *aNumEntries)
|
const uint16_t *
此函数会返回指向不安全端口列表的指针。
|
otIp6IsAddressEqual(const otIp6Address *aFirst, const otIp6Address *aSecond)
|
bool
测试两个 IPv6 地址是否相同。
|
otIp6IsAddressUnspecified(const otIp6Address *aAddress)
|
bool
此函数可指明给定 IPv6 地址是否为未指定地址。
|
otIp6IsEnabled(otInstance *aInstance)
|
bool
指示 IPv6 接口是否已启用。
|
otIp6IsMulticastPromiscuousEnabled(otInstance *aInstance)
|
bool
检查 Thread 接口上是否启用了多播混杂模式。
|
otIp6IsReceiveFilterEnabled(otInstance *aInstance)
|
bool
此函数指示在通过 otIp6SetReceiveCallback() 中指定的回调传送 IPv6 数据图时,是否过滤掉了线程控制流量。
|
otIp6IsSlaacEnabled(otInstance *aInstance)
|
bool
此函数用于指示 SLAAC 模块是否已启用。
|
otIp6NewMessage(otInstance *aInstance, const otMessageSettings *aSettings)
|
分配用于发送 IPv6 消息的新消息缓冲区。
|
otIp6NewMessageFromBuffer(otInstance *aInstance, const uint8_t *aData, uint16_t aDataLength, const otMessageSettings *aSettings)
|
分配一个新的消息缓冲区,并将 IPv6 数据报写入消息缓冲区中,以便发送 IPv6 消息。
|
otIp6PrefixFromString(const char *aString, otIp6Prefix *aPrefix)
|
此函数会将人类可读的 IPv6 前缀字符串转换为二进制表示法。
|
otIp6PrefixMatch(const otIp6Address *aFirst, const otIp6Address *aSecond)
|
uint8_t
此函数返回两个 IPv6 地址的前缀匹配长度(位)。
|
otIp6PrefixToString(const otIp6Prefix *aPrefix, char *aBuffer, uint16_t aSize)
|
void
此函数将指定的 IPv6 前缀转换为直观易懂的字符串。
|
otIp6ProtoToString(uint8_t aIpProto)
|
const char *
此函数可将指定的 IP 协议编号转换为直观易懂的字符串。
|
otIp6RegisterMulticastListeners(otInstance *aInstance, const otIp6Address *aAddresses, uint8_t aAddressNum, const uint32_t *aTimeout, otIp6RegisterMulticastListenersCallback aCallback, void *aContext)
|
此函数将多播监听器注册到主骨干路由器。
|
otIp6RemoveAllUnsecurePorts(otInstance *aInstance)
|
void
此函数从允许的不安全端口列表中移除所有端口。
|
otIp6RemoveUnicastAddress(otInstance *aInstance, const otIp6Address *aAddress)
|
从 Thread 接口移除网络接口地址。
|
otIp6RemoveUnsecurePort(otInstance *aInstance, uint16_t aPort)
|
此函数从允许的不安全端口列表中移除端口。
|
otIp6ResetBorderRoutingCounters(otInstance *aInstance)
|
void
重置边界路由计数器。
|
otIp6SelectSourceAddress(otInstance *aInstance, otMessageInfo *aMessageInfo)
|
此函数用于执行 OpenThread 源地址选择。
|
otIp6Send(otInstance *aInstance, otMessage *aMessage)
|
此函数通过 Thread 接口发送 IPv6 数据报。
|
otIp6SetAddressCallback(otInstance *aInstance, otIp6AddressCallback aCallback, void *aCallbackContext)
|
void
此函数会注册一个回调,以通知内部 IPv6 地址更改。
|
otIp6SetEnabled(otInstance *aInstance, bool aEnabled)
|
调高或调低 IPv6 接口。
|
otIp6SetMeshLocalIid(otInstance *aInstance, const otIp6InterfaceIdentifier *aIid)
|
此函数设置 Mesh Local IID(用于测试)。
|
otIp6SetMulticastPromiscuousEnabled(otInstance *aInstance, bool aEnabled)
|
void
在 Thread 接口上启用或停用多播混杂模式。
|
otIp6SetReceiveCallback(otInstance *aInstance, otIp6ReceiveCallback aCallback, void *aCallbackContext)
|
void
此函数注册一个回调,以提供收到的 IPv6 数据报。
|
otIp6SetReceiveFilterEnabled(otInstance *aInstance, bool aEnabled)
|
void
此函数设置当通过 otIp6SetReceiveCallback() 中指定的回调传送 IPv6 数据图时,是否过滤掉线程控制流量。
|
otIp6SetSlaacEnabled(otInstance *aInstance, bool aEnabled)
|
void
此函数可启用/停用 SLAAC 模块。
|
otIp6SetSlaacPrefixFilter(otInstance *aInstance, otIp6SlaacPrefixFilter aFilter)
|
void
此函数设置 SLAAC 模块过滤器处理程序。
|
otIp6SockAddrToString(const otSockAddr *aSockAddr, char *aBuffer, uint16_t aSize)
|
void
此函数可将指定的 IPv6 套接字地址转换为直观易懂的字符串。
|
otIp6SubscribeMulticastAddress(otInstance *aInstance, const otIp6Address *aAddress)
|
将 Thread 接口订阅到网络接口多播地址。
|
otIp6UnsubscribeMulticastAddress(otInstance *aInstance, const otIp6Address *aAddress)
|
退订网络接口多播地址的 Thread 接口。
|
结构体 |
|
---|---|
otBorderRoutingCounters |
此结构表示通过边界路由转发的数据包的计数器。 |
otIp6Address |
此结构表示 IPv6 地址。 |
otIp6AddressComponents |
此结构表示 IPv6 地址的组成部分。 |
otIp6AddressInfo |
此结构表示 IPv6 地址信息。 |
otIp6InterfaceIdentifier |
此结构表示 IPv6 地址的接口标识符。 |
otIp6NetworkPrefix |
此结构表示 IPv6 地址的网络前缀(地址的最高 64 位)。 |
otIp6Prefix |
此结构表示 IPv6 前缀。 |
otMessageInfo |
此结构表示本地和对等 IPv6 套接字地址。 |
otNetifAddress |
此结构表示 IPv6 网络接口单播地址。 |
otNetifMulticastAddress |
此结构表示 IPv6 网络接口多播地址。 |
otPacketsAndBytes |
此结构表示数据包和字节的计数器。 |
otSockAddr |
此结构表示 IPv6 套接字地址。 |
联合体 |
|
---|---|
otIp6InterfaceIdentifier: |
枚举
匿名枚举
anonymous enum
互联网协议编号。
属性 | |
---|---|
OT_IP6_PROTO_DST_OPTS
|
IPv6 的目标选项。 |
OT_IP6_PROTO_FRAGMENT
|
IPv6 的 Fragment 标头。 |
OT_IP6_PROTO_HOP_OPTS
|
IPv6 跃点选项。 |
OT_IP6_PROTO_ICMP6
|
适用于 IPv6 的 ICMP。 |
OT_IP6_PROTO_IP6
|
IPv6 封装。 |
OT_IP6_PROTO_NONE
|
IPv6 没有 Next 标头。 |
OT_IP6_PROTO_ROUTING
|
IPv6 的路由标头。 |
OT_IP6_PROTO_TCP
|
传输控制协议。 |
OT_IP6_PROTO_UDP
|
用户数据报。 |
匿名枚举
anonymous enum
IPv6 地址来源。
属性 | |
---|---|
OT_ADDRESS_ORIGIN_DHCPV6
|
分配的 DHCPv6 地址。 |
OT_ADDRESS_ORIGIN_MANUAL
|
手动分配的地址。 |
OT_ADDRESS_ORIGIN_SLAAC
|
分配有 SLAAC 的地址。 |
OT_ADDRESS_ORIGIN_THREAD
|
线程分配的地址(ALOC、RLOC、MLEID 等) |
匿名枚举
anonymous enum
ECN 状态,以 IP 标头表示。
属性 | |
---|---|
OT_ECN_CAPABLE_0
|
增强型转化(0) |
OT_ECN_CAPABLE_1
|
增强型转化(1) |
OT_ECN_MARKED
|
遇到拥塞 (CE) |
OT_ECN_NOT_CAPABLE
|
非增强型转化。 |
类型定义符
otBorderRoutingCounters
struct otBorderRoutingCounters otBorderRoutingCounters
此结构表示通过边界路由转发的数据包的计数器。
otIp6AddressCallback
void(* otIp6AddressCallback)(const otIp6AddressInfo *aAddressInfo, bool aIsAdded, void *aContext)
添加或移除内部 IPv6 地址时,系统会调用此函数指针。
详细说明 | |||||||
---|---|---|---|---|---|---|---|
参数 |
|
otIp6AddressInfo
struct otIp6AddressInfo otIp6AddressInfo
otIp6InterfaceIdentifier
struct otIp6InterfaceIdentifier otIp6InterfaceIdentifier
此结构表示 IPv6 地址的接口标识符。
otIp6ReceiveCallback
void(* otIp6ReceiveCallback)(otMessage *aMessage, void *aContext)
收到 IPv6 数据报时,系统会调用此函数指针。
详细说明 | |||||
---|---|---|---|---|---|
参数 |
|
otIp6RegisterMulticastListenersCallback
void(* otIp6RegisterMulticastListenersCallback)(void *aContext, otError aError, uint8_t aMlrStatus, const otIp6Address *aFailedAddresses, uint8_t aFailedAddressNum)
此函数指针会针对 otIp6RegisterMulticastListeners
的结果进行调用。
详细说明 | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
参数 |
|
otIp6RegisterMulticastListeners
otIp6SlaacPrefixFilter
bool(* otIp6SlaacPrefixFilter)(otInstance *aInstance, const otIp6Prefix *aPrefix)
此函数指针可让用户过滤前缀,并且不允许根据前缀添加 SLAAC 地址。
otIp6SetSlaacPrefixFilter()
可用于设置过滤器处理程序。当 SLAAC 模块即将要根据前缀添加 SLAAC 地址时,就会调用过滤器处理程序。其布尔值返回值决定了是否过滤(不添加)地址。
详细说明 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回值 |
|
变量
OT_TOOL_PACKED_END
OT_TOOL_PACKED_BEGIN struct otIp6InterfaceIdentifier OT_TOOL_PACKED_END
函数
otIp6AddUnicastAddress
otError otIp6AddUnicastAddress( otInstance *aInstance, const otNetifAddress *aAddress )
将网络接口地址添加到 Thread 接口。
传入的实例 aAddress
由 Thread 接口复制。Thread 接口仅支持固定数量的外部添加的单播地址。请参阅OPENTHREAD_CONFIG_IP6_MAX_EXT_UCAST_ADDRS
。
详细说明 | |||||||
---|---|---|---|---|---|---|---|
参数 |
|
||||||
返回值 |
|
otIp6AddUnsecurePort
otError otIp6AddUnsecurePort( otInstance *aInstance, uint16_t aPort )
此函数将端口添加到允许的不安全端口列表中。
详细说明 | |||||||
---|---|---|---|---|---|---|---|
参数 |
|
||||||
返回值 |
|
otIp6AddressFromString
otError otIp6AddressFromString( const char *aString, otIp6Address *aAddress )
此函数会将人类可读的 IPv6 地址字符串转换为二进制表示法。
详细说明 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回值 |
|
otIp6AddressToString
void otIp6AddressToString( const otIp6Address *aAddress, char *aBuffer, uint16_t aSize )
此函数将指定的 IPv6 地址转换为人类可读的字符串。
IPv6 地址字符串的格式为 16 个十六进制值,并用“:”(即“%x:%x:%x:...:%x”)。
如果生成的字符串不适合 aBuffer
(在其 aSize
字符内),则字符串会被截断,但输出的字符串始终以 null 终止。
详细说明 | |||||||
---|---|---|---|---|---|---|---|
参数 |
|
otIp6ArePrefixesEqual
bool otIp6ArePrefixesEqual( const otIp6Prefix *aFirst, const otIp6Prefix *aSecond )
测试两个 IPv6 前缀是否相同。
详细说明 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回值 |
|
otIp6GetBorderRoutingCounters
const otBorderRoutingCounters * otIp6GetBorderRoutingCounters( otInstance *aInstance )
获取边界路由计数器。
此函数需要启用构建时功能 OPENTHREAD_CONFIG_IP6_BR_COUNTERS_ENABLE
。
详细说明 | |||
---|---|---|---|
参数 |
|
||
返回 |
指向边界路由计数器的指针。
|
otIp6GetMulticastAddress
const otNetifMulticastAddress * otIp6GetMulticastAddresses( otInstance *aInstance )
获取订阅 Thread 接口的 IPv6 多播地址列表。
详细说明 | |||
---|---|---|---|
参数 |
|
||
返回 |
指向第一个网络接口多播地址的指针。
|
otIp6GetPrefix
void otIp6GetPrefix( const otIp6Address *aAddress, uint8_t aLength, otIp6Prefix *aPrefix )
此方法会从 aAddress
获取带有 aLength
的前缀。
详细说明 | |||||||
---|---|---|---|---|---|---|---|
参数 |
|
otIp6GetUnicastAddress
const otNetifAddress * otIp6GetUnicastAddresses( otInstance *aInstance )
获取分配给 Thread 接口的 IPv6 地址列表。
详细说明 | |||
---|---|---|---|
参数 |
|
||
返回 |
指向第一个网络接口地址的指针。
|
otIp6GetUnsecurePorts
const uint16_t * otIp6GetUnsecurePorts( otInstance *aInstance, uint8_t *aNumEntries )
此函数会返回指向不安全端口列表的指针。
详细说明 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回 |
指向不安全端口列表的指针。
|
otIp6IsAddressEqual
bool otIp6IsAddressEqual( const otIp6Address *aFirst, const otIp6Address *aSecond )
测试两个 IPv6 地址是否相同。
详细说明 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回值 |
|
otIp6IsAddressUnspecified
bool otIp6IsAddressUnspecified( const otIp6Address *aAddress )
此函数可指明给定 IPv6 地址是否为未指定地址。
详细说明 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回值 |
|
otIp6IsEnabled
bool otIp6IsEnabled( otInstance *aInstance )
指示 IPv6 接口是否已启用。
详细说明 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回值 |
|
otIp6IsMulticastPromiscuousEnabled
bool otIp6IsMulticastPromiscuousEnabled( otInstance *aInstance )
检查 Thread 接口上是否启用了多播混杂模式。
详细说明 | |||
---|---|---|---|
参数 |
|
otIp6SetMulticastPromiscuousEnabled
otIp6IsReceiveFilterEnabled
bool otIp6IsReceiveFilterEnabled( otInstance *aInstance )
此函数指示在通过 otIp6SetReceiveCallback() 中指定的回调传送 IPv6 数据图时,是否过滤掉了线程控制流量。
详细说明 | |||
---|---|---|---|
参数 |
|
||
返回 |
如果线程控制流量被过滤掉,则为 TRUE,否则为 FALSE。
|
otIp6SetReceiveCallback
otIp6SetReceiveFilterEnabled
otIp6IsSlaacEnabled
bool otIp6IsSlaacEnabled( otInstance *aInstance )
此函数用于指示 SLAAC 模块是否已启用。
此函数需要启用构建时功能 OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE
。
详细说明 | |||||
---|---|---|---|---|---|
返回值 |
|
otIp6NewMessage
otMessage * otIp6NewMessage( otInstance *aInstance, const otMessageSettings *aSettings )
分配用于发送 IPv6 消息的新消息缓冲区。
详细说明 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回 |
在消息缓冲区不可用或参数无效时,指向消息缓冲区或 NULL 的指针。
|
otMessageFree
otIp6NewMessageFromBuffer
otMessage * otIp6NewMessageFromBuffer( otInstance *aInstance, const uint8_t *aData, uint16_t aDataLength, const otMessageSettings *aSettings )
分配一个新的消息缓冲区,并将 IPv6 数据报写入消息缓冲区中,以便发送 IPv6 消息。
详细说明 | |||||||||
---|---|---|---|---|---|---|---|---|---|
参数 |
|
||||||||
返回 |
指向消息或 NULL 的指针(如果 IPv6 标头格式错误或消息缓冲区不足)。
|
otMessageFree
otIp6PrefixFromString
otError otIp6PrefixFromString( const char *aString, otIp6Prefix *aPrefix )
此函数会将人类可读的 IPv6 前缀字符串转换为二进制表示法。
aString
参数应为格式如下的字符串:
是 IPv6 地址,
是前缀长度。
详细说明 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回值 |
|
otIp6PrefixMatch
uint8_t otIp6PrefixMatch( const otIp6Address *aFirst, const otIp6Address *aSecond )
此函数返回两个 IPv6 地址的前缀匹配长度(位)。
详细说明 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回 |
前缀匹配长度(以位为单位)。
|
otIp6PrefixToString
void otIp6PrefixToString( const otIp6Prefix *aPrefix, char *aBuffer, uint16_t aSize )
此函数将指定的 IPv6 前缀转换为直观易懂的字符串。
IPv6 地址字符串的格式为“%x:%x:%x:...[::]/plen”。
如果生成的字符串不适合 aBuffer
(在其 aSize
字符内),则字符串会被截断,但输出的字符串始终以 null 终止。
详细说明 | |||||||
---|---|---|---|---|---|---|---|
参数 |
|
otIp6ProtoToString
const char * otIp6ProtoToString( uint8_t aIpProto )
此函数可将指定的 IP 协议编号转换为直观易懂的字符串。
详细说明 | |||
---|---|---|---|
参数 |
|
||
返回 |
一个表示
aIpProto 的字符串。 |
otIp6RegisterMulticastListeners
otError otIp6RegisterMulticastListeners( otInstance *aInstance, const otIp6Address *aAddresses, uint8_t aAddressNum, const uint32_t *aTimeout, otIp6RegisterMulticastListenersCallback aCallback, void *aContext )
此函数将多播监听器注册到主骨干路由器。
注意:仅在同时启用了 OPENTHREAD_CONFIG_TMF_PROXY_MLR_ENABLE
和 OPENTHREAD_CONFIG_COMMISSIONER_ENABLE
时可用)
详细说明 | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
参数 |
|
||||||||||||
返回值 |
|
otIp6RegisterMulticastListenersCallback
otIp6RemoveAllUnsecurePorts
void otIp6RemoveAllUnsecurePorts( otInstance *aInstance )
此函数从允许的不安全端口列表中移除所有端口。
详细说明 | |||
---|---|---|---|
参数 |
|
otIp6RemoveUnicastAddress
otError otIp6RemoveUnicastAddress( otInstance *aInstance, const otIp6Address *aAddress )
从 Thread 接口移除网络接口地址。
详细说明 | |||||||
---|---|---|---|---|---|---|---|
参数 |
|
||||||
返回值 |
|
otIp6RemoveUnsecurePort
otError otIp6RemoveUnsecurePort( otInstance *aInstance, uint16_t aPort )
此函数从允许的不安全端口列表中移除端口。
详细说明 | |||||||
---|---|---|---|---|---|---|---|
参数 |
|
||||||
返回值 |
|
otIp6ResetBorderRoutingCounters
void otIp6ResetBorderRoutingCounters( otInstance *aInstance )
重置边界路由计数器。
详细说明 | |||
---|---|---|---|
参数 |
|
otIp6SelectSourceAddress
otError otIp6SelectSourceAddress( otInstance *aInstance, otMessageInfo *aMessageInfo )
此函数用于执行 OpenThread 源地址选择。
详细说明 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回值 |
|
OTIP6 发送
otError otIp6Send( otInstance *aInstance, otMessage *aMessage )
此函数通过 Thread 接口发送 IPv6 数据报。
调用者在进行此通话时转移 aMessage
的所有权。处理完成后(包括返回 OT_ERROR_NONE
以外的值时),OpenThread 将释放 aMessage
。
详细说明 | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
参数 |
|
||||||||||||
返回值 |
|
otIp6SetAddressCallback
void otIp6SetAddressCallback( otInstance *aInstance, otIp6AddressCallback aCallback, void *aCallbackContext )
此函数会注册一个回调,以通知内部 IPv6 地址更改。
详细说明 | |||||||
---|---|---|---|---|---|---|---|
参数 |
|
otIp6SetEnabled
otError otIp6SetEnabled( otInstance *aInstance, bool aEnabled )
调高或调低 IPv6 接口。
可调用以启用或停用 IPv6 通信。
详细说明 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回值 |
|
otIp6SetMeshLocalIid
otError otIp6SetMeshLocalIid( otInstance *aInstance, const otIp6InterfaceIdentifier *aIid )
此函数设置 Mesh Local IID(用于测试)。
仅当 OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
处于启用状态时才可用。
详细说明 | |||||
---|---|---|---|---|---|
参数 |
|
||||
返回值 |
|
otIp6SetMulticastPromiscuousEnabled
void otIp6SetMulticastPromiscuousEnabled( otInstance *aInstance, bool aEnabled )
在 Thread 接口上启用或停用多播混杂模式。
详细说明 | |||||
---|---|---|---|---|---|
参数 |
|
otIp6IsMulticastPromiscuousEnabled
otIp6SetReceiveCallback
void otIp6SetReceiveCallback( otInstance *aInstance, otIp6ReceiveCallback aCallback, void *aCallbackContext )
此函数注册一个回调,以提供收到的 IPv6 数据报。
默认情况下,此回调不会传递线程控制流量。如需更改线程控制流量过滤器设置,请参阅 otIp6SetReceiveFilterEnabled()。
详细说明 | |||||||
---|---|---|---|---|---|---|---|
参数 |
|
otIp6IsReceiveFilterEnabled
otIp6SetReceiveFilterEnabled
otIp6SetReceiveFilterEnabled
void otIp6SetReceiveFilterEnabled( otInstance *aInstance, bool aEnabled )
此函数设置当通过 otIp6SetReceiveCallback() 中指定的回调传送 IPv6 数据图时,是否过滤掉线程控制流量。
详细说明 | |||||
---|---|---|---|---|---|
参数 |
|
otIp6SetReceiveCallback
otIsReceiveIp6FilterEnabled
otIp6SetSlaacEnabled
void otIp6SetSlaacEnabled( otInstance *aInstance, bool aEnabled )
此函数可启用/停用 SLAAC 模块。
此函数需要启用构建时功能 OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE
。
启用 SLAAC 模块后,SLAAC 地址(基于网络数据中的网格前缀)会添加到接口中。如果停用 SLAAC 模块,系统会移除之前添加的任何 SLAAC 地址。
详细说明 | |||||
---|---|---|---|---|---|
参数 |
|
otIp6SetSlaacPrefixFilter
void otIp6SetSlaacPrefixFilter( otInstance *aInstance, otIp6SlaacPrefixFilter aFilter )
此函数设置 SLAAC 模块过滤器处理程序。
此函数需要启用构建时功能 OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE
。
当 SLAAC 即将根据前缀添加 SLAAC 地址时,由过滤器处理程序调用以决定是否添加该地址。
NULL 过滤器处理程序会停用过滤功能,并允许添加所有 SLAAC 地址。
如果未调用此函数,SLAAC 模块使用的默认过滤条件将是 NULL(停用过滤)。
详细说明 | |||||
---|---|---|---|---|---|
参数 |
|
otIp6SockAddrToString
void otIp6SockAddrToString( const otSockAddr *aSockAddr, char *aBuffer, uint16_t aSize )
此函数可将指定的 IPv6 套接字地址转换为直观易懂的字符串。
IPv6 套接字地址字符串的格式为 [address
]:port
,其中 address
显示为 16 个十六进制值,以 :
分隔,port
是十进制格式的端口号,例如“[%x:%x:...:%x]:%u”。
如果生成的字符串不适合 aBuffer
(在其 aSize
字符内),则字符串会被截断,但输出的字符串始终以 null 终止。
详细说明 | |||||||
---|---|---|---|---|---|---|---|
参数 |
|
otIp6SubscribeMulticastAddress
otError otIp6SubscribeMulticastAddress( otInstance *aInstance, const otIp6Address *aAddress )
将 Thread 接口订阅到网络接口多播地址。
传入的实例 aAddress
将由 Thread 接口复制。Thread 接口仅支持固定数量的外部添加的多播地址。请参阅OPENTHREAD_CONFIG_IP6_MAX_EXT_MCAST_ADDRS
。
详细说明 | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
参数 |
|
||||||||||
返回值 |
|
otIp6UnsubscribeMulticastAddress
otError otIp6UnsubscribeMulticastAddress( otInstance *aInstance, const otIp6Address *aAddress )
退订网络接口多播地址的 Thread 接口。
详细说明 | |||||||
---|---|---|---|---|---|---|---|
参数 |
|
||||||
返回值 |
|
宏
OT_IP6_ADDRESS_SIZE
OT_IP6_ADDRESS_SIZE 16
IPv6 地址的大小(字节)
OT_IP6_ADDRESS_STRING_SIZE
OT_IP6_ADDRESS_STRING_SIZE 40
IPv6 地址的字符串表示法的推荐大小。
OT_IP6_IID_SIZE
OT_IP6_IID_SIZE 8
IPv6 接口标识符的大小(字节)
OT_IP6_MAX_MLR_ADDRESSES
OT_IP6_MAX_MLR_ADDRESSES 15
多播监听器注册支持的 IPv6 地址数上限。
OT_IP6_PREFIX_BITSIZE
OT_IP6_PREFIX_BITSIZE (OT_IP6_PREFIX_SIZE * 8)
IPv6 前缀(位)的大小
OT_IP6_PREFIX_SIZE
OT_IP6_PREFIX_SIZE 8
IPv6 前缀(字节)的大小
OT_IP6_PREFIX_STRING_SIZE
OT_IP6_PREFIX_STRING_SIZE 45
IPv6 前缀的字符串表示法的推荐大小。
OT_IP6_SOCK_ADDR_STRING_SIZE
OT_IP6_SOCK_ADDR_STRING_SIZE 48
IPv6 套接字地址的字符串表示法的推荐大小。
资源
OpenThread API 参考主题源自源代码,可在 GitHub 上获取。 如需了解详情或为我们的文档贡献内容,请参阅资源。