Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] main from openthread:main #183

Merged
merged 10 commits into from
Apr 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion etc/cmake/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@ ot_option(OT_MESH_DIAG OPENTHREAD_CONFIG_MESH_DIAG_ENABLE "mesh diag")
ot_option(OT_MESSAGE_USE_HEAP OPENTHREAD_CONFIG_MESSAGE_USE_HEAP_ENABLE "heap allocator for message buffers")
ot_option(OT_MLE_LONG_ROUTES OPENTHREAD_CONFIG_MLE_LONG_ROUTES_ENABLE "MLE long routes extension (experimental)")
ot_option(OT_MLR OPENTHREAD_CONFIG_MLR_ENABLE "Multicast Listener Registration (MLR)")
ot_option(OT_MTD_NETDIAG OPENTHREAD_CONFIG_TMF_NETWORK_DIAG_MTD_ENABLE "TMF network diagnostics on MTDs")
ot_option(OT_MULTIPLE_INSTANCE OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE "multiple instances")
ot_option(OT_NAT64_BORDER_ROUTING OPENTHREAD_CONFIG_NAT64_BORDER_ROUTING_ENABLE "border routing NAT64")
ot_option(OT_NAT64_TRANSLATOR OPENTHREAD_CONFIG_NAT64_TRANSLATOR_ENABLE "NAT64 translator support")
ot_option(OT_NEIGHBOR_DISCOVERY_AGENT OPENTHREAD_CONFIG_NEIGHBOR_DISCOVERY_AGENT_ENABLE "neighbor discovery agent")
ot_option(OT_NETDATA_PUBLISHER OPENTHREAD_CONFIG_NETDATA_PUBLISHER_ENABLE "Network Data publisher")
ot_option(OT_NETDIAG_CLIENT OPENTHREAD_CONFIG_TMF_NETDIAG_CLIENT_ENABLE "Network Diagnostic client")
ot_option(OT_OTNS OPENTHREAD_CONFIG_OTNS_ENABLE "OTNS")
ot_option(OT_PING_SENDER OPENTHREAD_CONFIG_PING_SENDER_ENABLE "ping sender" ${OT_APP_CLI})
ot_option(OT_PLATFORM_NETIF OPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE "platform netif")
Expand Down Expand Up @@ -210,3 +210,17 @@ endif()
if(OT_POSIX_SETTINGS_PATH)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_POSIX_SETTINGS_PATH=${OT_POSIX_SETTINGS_PATH}")
endif()

#-----------------------------------------------------------------------------------------------------------------------
# Check removed/replaced options

macro(ot_removed_option name error)
# This macro checks for a remove option and emits an error
# if the option is set.
get_property(is_set CACHE ${name} PROPERTY VALUE SET)
if (is_set)
message(FATAL_ERROR "Removed option ${name} is set - ${error}")
endif()
endmacro()

ot_removed_option(OT_MTD_NETDIAG "- Use OT_NETDIAG_CLIENT instead - note that server function is always supported")
4 changes: 2 additions & 2 deletions etc/gn/openthread.gni
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ if (openthread_enable_core_config_args) {
# Enable MLE long routes extension (experimental, breaks Thread conformance]
openthread_config_mle_long_routes_enable = false

# Enable TMF network diagnostics on MTDs
openthread_config_tmf_network_diag_mtd_enable = false
# Enable TMF network diagnostics client
openthread_config_tmf_netdiag_client_enable = false

# Enable multiple instances
openthread_config_multiple_instance_enable = false
Expand Down
2 changes: 1 addition & 1 deletion examples/Makefile-simulation
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ JAM_DETECTION ?= 1
JOINER ?= 1
LINK_RAW ?= 1
MAC_FILTER ?= 1
MTD_NETDIAG ?= 1
NEIGHBOR_DISCOVERY_AGENT ?= 1
NETDATA_PUBLISHER ?= 1
NETDIAG_CLIENT ?= 1
PING_SENDER ?= 1
REFERENCE_DEVICE ?= 1
SERVICE ?= 1
Expand Down
8 changes: 7 additions & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ This page lists the available common switches with description. Unless stated ot
| MAC_FILTER | OT_MAC_FILTER | Enables support for the MAC filter. |
| MLE_LONG_ROUTES | OT_MLE_LONG_ROUTES | Enables the MLE long routes extension. **Note: Enabling this feature breaks conformance to the Thread Specification.** |
| MLR | OT_MLR | Enables Multicast Listener Registration feature for Thread 1.2. |
| MTD_NETDIAG | OT_MTD_NETDIAG | Enables the TMF network diagnostics on MTDs. |
| MULTIPLE_INSTANCE | OT_MULTIPLE_INSTANCE | Enables multiple OpenThread instances. |
| NAT64_BORDER_ROUTING | OT_NAT64_BORDER_ROUTING | Enables NAT64 border routing support for Border Router. |
| NAT64_TRANSLATOR | OT_NAT64_TRANSLATOR | Enables NAT64 translator for Border Router. |
| NETDATA_PUBLISHER | OT_NETDATA_PUBLISHER | Enables support for Thread Network Data publisher. |
| NETDIAG_CLIENT | OT_NETDIAG_CLIENT | Enables Network Diagnostics client functionality. |
| PING_SENDER | OT_PING_SENDER | Enables support for ping sender. |
| OTNS | OT_OTNS | Enables support for [OpenThread Network Simulator](https://github.com/openthread/ot-ns). Enable this switch if you are building OpenThread for OpenThread Network Simulator. |
| PLATFORM_UDP | OT_PLATFORM_UDP | Enables platform UDP support. |
Expand All @@ -73,3 +73,9 @@ This page lists the available common switches with description. Unless stated ot
| TREL | OT_TREL | Enables TREL radio link for Thread over Infrastructure feature. |
| UDP_FORWARD | OT_UDP_FORWARD | Enables support for UDP forward. Enable this switch on the Border Router device (running on the NCP design) with External Commissioning support to service Thread Commissioner packets on the NCP side. |
| UPTIME | OT_UPTIME | Enables support for tracking OpenThread instance's uptime. |

Removed or replaced switches:

| Makefile switch | CMake switch | Description |
| --- | --- | --- |
| MTD_NETDIAG | OT_MTD_NETDIAG | Use NEDIAG_CLIENT to enable client functionality. Server functionality is always supported. |
8 changes: 8 additions & 0 deletions examples/common-switches.mk
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ NAT64_BORDER_ROUTING ?= 0
NAT64_TRANSLATOR ?= 0
NEIGHBOR_DISCOVERY_AGENT ?= 0
NETDATA_PUBLISHER ?= 0
NETDIAG_CLIENT ?= 0
OTNS ?= 0
PING_SENDER ?= 1
PLATFORM_UDP ?= 0
Expand Down Expand Up @@ -286,6 +287,9 @@ ifeq ($(MLR),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_MLR_ENABLE=1
endif

# This config is removed but we still check and add the
# `OPENTHREAD_CONFIG_TMF_NETWORK_DIAG_MTD_ENABLE` so to
# get an error during build if `MTD_NETDIAG` is used.
ifeq ($(MTD_NETDIAG),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_TMF_NETWORK_DIAG_MTD_ENABLE=1
endif
Expand All @@ -302,6 +306,10 @@ ifeq ($(NETDATA_PUBLISHER),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_NETDATA_PUBLISHER_ENABLE=1
endif

ifeq ($(NETDIAG_CLIENT),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_TMF_NETDIAG_CLIENT_ENABLE=1
endif

ifeq ($(PING_SENDER),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_PING_SENDER_ENABLE=1
endif
Expand Down
2 changes: 1 addition & 1 deletion examples/platforms/simulation/diag.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static uint16_t sRawPowerSettingLength = 0;

void otPlatDiagModeSet(bool aMode) { sDiagMode = aMode; }

bool otPlatDiagModeGet() { return sDiagMode; }
bool otPlatDiagModeGet(void) { return sDiagMode; }

void otPlatDiagChannelSet(uint8_t aChannel) { OT_UNUSED_VARIABLE(aChannel); }

Expand Down
31 changes: 26 additions & 5 deletions include/openthread/dns_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,23 @@ typedef enum
OT_DNS_NAT64_DISALLOW = 2, ///< Do not allow NAT64 address translation during DNS client address resolution.
} otDnsNat64Mode;

/**
* This enumeration type represents the service resolution mode in an `otDnsQueryConfig`.
*
* This is only used during DNS client service resolution `otDnsClientResolveService()`. It determines which
* record types to query.
*
*/
typedef enum
{
OT_DNS_SERVICE_MODE_UNSPECIFIED = 0, ///< Mode is not specified. Use default service mode.
OT_DNS_SERVICE_MODE_SRV = 1, ///< Query for SRV record only.
OT_DNS_SERVICE_MODE_TXT = 2, ///< Query for TXT record only.
OT_DNS_SERVICE_MODE_SRV_TXT = 3, ///< Query for both SRV and TXT records in same message.
OT_DNS_SERVICE_MODE_SRV_TXT_SEPARATE = 4, ///< Query in parallel for SRV and TXT using separate messages.
OT_DNS_SERVICE_MODE_SRV_TXT_OPTIMIZE = 5, ///< Query for TXT/SRV together first, if fails then query separately.
} otDnsServiceMode;

/**
* This enumeration type represents the DNS transport protocol in an `otDnsQueryConfig`.
*
Expand All @@ -102,11 +119,12 @@ typedef enum
*/
typedef struct otDnsQueryConfig
{
otSockAddr mServerSockAddr; ///< Server address (IPv6 address/port). All zero or zero port for unspecified.
otSockAddr mServerSockAddr; ///< Server address (IPv6 addr/port). All zero or zero port for unspecified.
uint32_t mResponseTimeout; ///< Wait time (in msec) to rx response. Zero indicates unspecified value.
uint8_t mMaxTxAttempts; ///< Maximum tx attempts before reporting failure. Zero for unspecified value.
otDnsRecursionFlag mRecursionFlag; ///< Indicates whether the server can resolve the query recursively or not.
otDnsNat64Mode mNat64Mode; ///< Allow/Disallow NAT64 address translation during address resolution.
otDnsServiceMode mServiceMode; ///< Determines which records to query during service resolution.
otDnsTransportProto mTransportProto; ///< Select default transport protocol.
} otDnsQueryConfig;

Expand Down Expand Up @@ -420,7 +438,8 @@ otError otDnsBrowseResponseGetServiceInstance(const otDnsBrowseResponse *aRespon
* (note that it is a SHOULD and not a MUST requirement). This function tries to retrieve this info for a given service
* instance when available.
*
* - If no matching SRV record is found in @p aResponse, `OT_ERROR_NOT_FOUND` is returned.
* - If no matching SRV record is found in @p aResponse, `OT_ERROR_NOT_FOUND` is returned. In this case, no additional
* records (no TXT and/or AAAA) are read.
* - If a matching SRV record is found in @p aResponse, @p aServiceInfo is updated and `OT_ERROR_NONE` is returned.
* - If no matching TXT record is found in @p aResponse, `mTxtDataSize` in @p aServiceInfo is set to zero.
* - If TXT data length is greater than `mTxtDataSize`, it is read partially and `mTxtDataTruncated` is set to true.
Expand Down Expand Up @@ -550,8 +569,10 @@ otError otDnsServiceResponseGetServiceName(const otDnsServiceResponse *aResponse
*
* This function MUST only be used from `otDnsServiceCallback`.
*
* - If no matching SRV record is found in @p aResponse, `OT_ERROR_NOT_FOUND` is returned.
* - If a matching SRV record is found in @p aResponse, @p aServiceInfo is updated and `OT_ERROR_NONE` is returned.
* - If a matching SRV record is found in @p aResponse, @p aServiceInfo is updated.
* - If no matching SRV record is found, `OT_ERROR_NOT_FOUND` is returned unless the query config for this query
* used `OT_DNS_SERVICE_MODE_TXT` for `mServiceMode` (meaning the request was only for TXT record). In this case, we
* still try to parse the SRV record from Additional Data Section of response (in case server provided the info).
* - If no matching TXT record is found in @p aResponse, `mTxtDataSize` in @p aServiceInfo is set to zero.
* - If TXT data length is greater than `mTxtDataSize`, it is read partially and `mTxtDataTruncated` is set to true.
* - If no matching AAAA record is found in @p aResponse, `mHostAddress is set to all zero or unspecified address.
Expand All @@ -562,7 +583,7 @@ otError otDnsServiceResponseGetServiceName(const otDnsServiceResponse *aResponse
* @param[out] aServiceInfo A `ServiceInfo` to output the service instance information (MUST NOT be NULL).
*
* @retval OT_ERROR_NONE The service instance info was read. @p aServiceInfo is updated.
* @retval OT_ERROR_NOT_FOUND Could not find a matching SRV record in @p aResponse.
* @retval OT_ERROR_NOT_FOUND Could not find a required record in @p aResponse.
* @retval OT_ERROR_NO_BUFS The host name and/or TXT data could not fit in the given buffers.
* @retval OT_ERROR_PARSE Could not parse the records in the @p aResponse.
*
Expand Down
2 changes: 1 addition & 1 deletion include/openthread/instance.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ extern "C" {
* @note This number versions both OpenThread platform and user APIs.
*
*/
#define OPENTHREAD_API_VERSION (306)
#define OPENTHREAD_API_VERSION (308)

/**
* @addtogroup api-instance
Expand Down
2 changes: 2 additions & 0 deletions include/openthread/netdiag.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ extern "C" {
*
* @{
*
*
* Network Dianostics APIs require OPENTHREAD_CONFIG_TMF_NETDIAG_CLIENT_ENABLE.
*/

/**
Expand Down
2 changes: 1 addition & 1 deletion script/check-arm-build
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ build_nrf52840()
"-DOT_MAC_FILTER=ON"
"-DOT_MESSAGE_USE_HEAP=ON"
"-DOT_MLR=ON"
"-DOT_MTD_NETDIAG=ON"
"-DOT_NETDATA_PUBLISHER=ON"
"-DOT_NETDIAG_CLIENT=ON"
"-DOT_PING_SENDER=ON"
"-DOT_SERVICE=ON"
"-DOT_SLAAC=ON"
Expand Down
2 changes: 1 addition & 1 deletion script/check-scan-build
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ OT_BUILD_OPTIONS=(
"-DOT_LOG_LEVEL_DYNAMIC=ON"
"-DOT_MAC_FILTER=ON"
"-DOT_MESH_DIAG=ON"
"-DOT_MTD_NETDIAG=ON"
"-DOT_NAT64_BORDER_ROUTING=ON"
"-DOT_NAT64_TRANSLATOR=ON"
"-DOT_NEIGHBOR_DISCOVERY_AGENT=ON"
"-DOT_NETDIAG_CLIENT=ON"
"-DOT_PING_SENDER=ON"
"-DOT_PLATFORM=external"
"-DOT_RCP_RESTORATION_MAX_COUNT=2"
Expand Down
2 changes: 1 addition & 1 deletion script/check-simulation-build-autotools
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ build_all_features()
"-DOPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE=1"
"-DOPENTHREAD_CONFIG_SRP_CLIENT_ENABLE=1"
"-DOPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE=1"
"-DOPENTHREAD_CONFIG_TMF_NETWORK_DIAG_MTD_ENABLE=1"
"-DOPENTHREAD_CONFIG_TMF_NETDIAG_CLIENT_ENABLE=1"
"-DOPENTHREAD_CONFIG_UDP_FORWARD_ENABLE=1"
"-DOPENTHREAD_CONFIG_MAC_BEACON_PAYLOAD_PARSING_ENABLE=1"
"-DOPENTHREAD_CONFIG_MAC_OUTGOING_BEACON_PAYLOAD_ENABLE=1"
Expand Down
1 change: 0 additions & 1 deletion script/check-size
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ size_nrf52840_version()
"-DOT_LINK_RAW=ON"
"-DOT_MAC_FILTER=ON"
"-DOT_MESSAGE_USE_HEAP=ON"
"-DOT_MTD_NETDIAG=ON"
"-DOT_NETDATA_PUBLISHER=ON"
"-DOT_PING_SENDER=ON"
"-DOT_SERVICE=ON"
Expand Down
2 changes: 1 addition & 1 deletion script/cmake-build
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ OT_POSIX_SIM_COMMON_OPTIONS=(
"-DOT_JAM_DETECTION=ON"
"-DOT_JOINER=ON"
"-DOT_MAC_FILTER=ON"
"-DOT_MTD_NETDIAG=ON"
"-DOT_NEIGHBOR_DISCOVERY_AGENT=ON"
"-DOT_NETDATA_PUBLISHER=ON"
"-DOT_NETDIAG_CLIENT=ON"
"-DOT_PING_SENDER=ON"
"-DOT_REFERENCE_DEVICE=ON"
"-DOT_SERVICE=ON"
Expand Down
2 changes: 1 addition & 1 deletion script/make-pretty
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ OT_CLANG_TIDY_BUILD_OPTS=(
'-DOT_LINK_METRICS_SUBJECT=ON'
'-DOT_MAC_FILTER=ON'
'-DOT_MESH_DIAG=ON'
'-DOT_MTD_NETDIAG=ON'
'-DOT_NAT64_BORDER_ROUTING=ON'
'-DOT_NAT64_TRANSLATOR=ON'
'-DOT_NETDATA_PUBLISHER=ON'
'-DOT_NETDIAG_CLIENT=ON'
'-DOT_PING_SENDER=ON'
'-DOT_REFERENCE_DEVICE=ON'
'-DOT_SERVICE=ON'
Expand Down
32 changes: 29 additions & 3 deletions src/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1113,34 +1113,60 @@ Done

Get the default query config used by DNS client.

The config includes the server IPv6 address and port, response timeout in msec (wait time to rx response), maximum tx attempts before reporting failure, boolean flag to indicate whether the server can resolve the query recursively or not.
The config includes

- Server IPv6 address and port
- Response timeout in msec (wait time to rx response)
- Maximum tx attempts before reporting failure
- Boolean flag to indicate whether the server can resolve the query recursively or not.
- Service resolution mode which specifies which records to query. Possible options are:
- `srv` : Query for SRV record only.
- `txt` : Query for TXT record only.
- `srv_txt` : Query for both SRV and TXT records in the same message.
- `srv_txt_sep`: Query in parallel for SRV and TXT using separate messages.
- `srv_txt_opt`: Query for TXT/SRV together first, if it fails then query separately.
- Whether to allow/disallow NAT64 address translation during address resolution (requires `OPENTHREAD_CONFIG_DNS_CLIENT_NAT64_ENABLE`)
- Transport protocol UDP or TCP (requires `OPENTHREAD_CONFIG_DNS_CLIENT_OVER_TCP_ENABLE`)

```bash
> dns config
Server: [fd00:0:0:0:0:0:0:1]:1234
ResponseTimeout: 5000 ms
MaxTxAttempts: 2
RecursionDesired: no
ServiceMode: srv_txt_opt
Nat64Mode: allow
TransportProtocol: udp
Done
>
```

### dns config \[DNS server IP\] \[DNS server port\] \[response timeout (ms)\] \[max tx attempts\] \[recursion desired (boolean)\] \[transport protocol\]
### dns config \[DNS server IP\] \[DNS server port\] \[response timeout (ms)\] \[max tx attempts\] \[recursion desired (boolean)\] \[service mode]

Set the default query config.

Service mode specifies which records to query. Possible options are:

- `def` : Use default option.
- `srv` : Query for SRV record only.
- `txt` : Query for TXT record only.
- `srv_txt` : Query for both SRV and TXT records in the same message.
- `srv_txt_sep`: Query in parallel for SRV and TXT using separate messages.
- `srv_txt_opt`: Query for TXT/SRV together first, if it fails then query separately.

To set protocol effectively to tcp `OPENTHREAD_CONFIG_DNS_CLIENT_OVER_TCP_ENABLE` is required.

```bash
> dns config fd00::1 1234 5000 2 0 tcp
> dns config fd00::1 1234 5000 2 0 srv_txt_sep tcp
Done

> dns config
Server: [fd00:0:0:0:0:0:0:1]:1234
ResponseTimeout: 5000 ms
MaxTxAttempts: 2
RecursionDesired: no
ServiceMode: srv_txt_sep
Nat64Mode: allow
TransportProtocol: tcp
Done
```
Expand Down
Loading