diff --git a/include/openthread/instance.h b/include/openthread/instance.h index c2e4dd173..00876c07e 100644 --- a/include/openthread/instance.h +++ b/include/openthread/instance.h @@ -53,7 +53,7 @@ extern "C" { * @note This number versions both OpenThread platform and user APIs. * */ -#define OPENTHREAD_API_VERSION (64) +#define OPENTHREAD_API_VERSION (65) /** * @addtogroup api-instance diff --git a/src/cli/README_SRP.md b/src/cli/README_SRP.md new file mode 100644 index 000000000..6d928676e --- /dev/null +++ b/src/cli/README_SRP.md @@ -0,0 +1,188 @@ +# OpenThread CLI - SRP (Service Registration Protocol) + +## Quick Start + +### Build with SRP Server & Client support + +Use the `SRP_SERVER=1 SERVICE=1 ECDSA=1` build switches to enable SRP Server API support, and the `SRP_CLIENT=1 ECDSA=1` build switches for SRP Client API support. + +Make simulation SRP Server & Client: + +```bash +./bootstrap +make -f examples/Makefile-simulation SRP_SERVER=1 SRP_CLIENT=1 SERVICE=1 ECDSA=1 +``` + +## Simulation Example + +### Start SRP Server + +Start the SRP Server node: + +```bash +./output/simulation/bin/ot-cli-ftd 1 +``` + +Setup a Thread network and start the SRP Server: + +```bash +> dataset init new +Done +> dataset +Active Timestamp: 1 +Channel: 22 +Channel Mask: 0x07fff800 +Ext PAN ID: 8d6ed7a05a28fb3b +Mesh Local Prefix: fded:5114:8263:1fe1::/64 +Master Key: 7fcbae4153cc2955c28440c15d4d4219 +Network Name: OpenThread-f7af +PAN ID: 0xf7af +PSKc: b658e40f174e3a11be149b302ef07a0f +Security Policy: 672, onrcb +Done +> dataset commit active +Done +> ifconfig up +Done +> thread start +Done +> state +leader +Done +>ipaddr +fded:5114:8263:1fe1:0:ff:fe00:fc00 +fded:5114:8263:1fe1:0:ff:fe00:c000 +fded:5114:8263:1fe1:68bc:ec03:c1ad:9325 +fe80:0:0:0:a8cd:6e23:df3d:4193 +Done +> srp server enable +Done +> netdata show +Prefixes: +Routes: +Services: +44970 5d c002 s 8400 +Done +``` + +The SRP Server listening UDP port which is `c002`(`49154`) is included in the Server Data (listed by the `netdata show` command). + +### Start SRP Client + +Start the SRP Client node: + +```bash +./output/simulation/bin/ot-cli-ftd 2 +``` + +Join the Thread Network and register a `_ipps._tcp` service: + +```bash +> dataset masterkey 7fcbae4153cc2955c28440c15d4d4219 +Done +> dataset commit active +Done +> ifconfig up +Done +> thread start +Done +> state +child +Done +> ipaddr +fded:5114:8263:1fe1:0:ff:fe00:c001 +fded:5114:8263:1fe1:44f9:cc06:4a2d:534 +fe80:0:0:0:38dd:fdf7:5fd:24e +Done +> srp client host name my-host +Done +> srp client host address fded:5114:8263:1fe1:44f9:cc06:4a2d:534 +Done +> srp client service add my-service _ipps._tcp 12345 +Done +srp client start fded:5114:8263:1fe1:68bc:ec03:c1ad:9325 49154 +Done +``` + +Make sure the SRP Server address & port are used for the `srp client start` command. + +### Verify the service status + +Check if the host and service has been successfully registered on the client node: + +```bash +> srp client host +name:"my-host", state:Registered, addrs:[fded:5114:8263:1fe1:44f9:cc06:4a2d:534] +Done +> srp client service +instance:"my-service", name:"_ipps._tcp", state:Registered, port:12345, priority:0, weight:0 +Done +``` + +Make sure it shows `state:Registered` for both host and service commands. + +Check the host & service on the server node: + +```bash +> srp server host +my-host.default.service.arpa. + deleted: false + addresses: [fded:5114:8263:1fe1:44f9:cc06:4a2d:534] +Done +> srp server service +my-service._ipps._tcp.default.service.arpa. + deleted: false + port: 12345 + priority: 0 + weight: 0 + TXT: 00 + host: my-host.default.service.arpa. + addresses: [fded:5114:8263:1fe1:44f9:cc06:4a2d:534] +Done +``` + +Make sure it shows `deleted: false` for both host and service commands. + +### Remove the service + +A service can be removed through the client node: + +```bash +> srp client service remove my-service _ipps._tcp +Done +``` + +Confirm on the server node that the service has been removed: + +```bash +> srp server service +my-service._ipps._tcp.default.service.arpa. + deleted: true +Done +``` + +The service entry is listed because the name of service is not removed. + +### Remove the host and service names + +A host and service, along with their names, can be removed through the client node: + +```bash +> srp client host remove 1 +Done +``` + +Confirm on the server node that no host or service entries are listed: + +```bash +> srp server host +Done +> srp server service +Done +> +``` + +## CLI Reference + +- [SRP Client CLI Reference](README_SRP_CLIENT.md) +- [SRP Server CLI Reference](README_SRP_SERVER.md)