mirror of
https://github.com/espressif/openthread.git
synced 2026-08-10 04:37:47 +00:00
[dns-header] add common TXT record entry parsing API (#6157)
This commit adds a new public `ot` API for parsing an encoded DNS TXT record data into `TxtEntry` key/value pairs. It also updates the TXT data iterator model used for going through all TXT entries. The new iterator definition provides a small buffer to store the key string. This helps simplify the definition of `otDnsTxtEntry` to use null-terminated C string for the key. The new parsing APIs are used in CLI module. This commit also fixes an issue with `TxtEntry::AppendEntries()` using incorrect value for the key length. Finally, this commit adds a test covering the behavior of all `TxtEntry` related methods (encoding and parsing TXT data) in the unit test `test_dns`.
This commit is contained in:
@@ -106,7 +106,7 @@ class TestDnssd(thread_cert.TestCase):
|
||||
'weight': 1,
|
||||
'host': 'host1.default.service.arpa.',
|
||||
'address': client1_addrs,
|
||||
'txt_data': b'\x00',
|
||||
'txt_data': '',
|
||||
'srv_ttl': lambda x: x > 0,
|
||||
'txt_ttl': lambda x: x > 0,
|
||||
'aaaa_ttl': lambda x: x > 0,
|
||||
@@ -118,7 +118,7 @@ class TestDnssd(thread_cert.TestCase):
|
||||
'weight': 2,
|
||||
'host': 'host2.default.service.arpa.',
|
||||
'address': client2_addrs,
|
||||
'txt_data': b'\x00',
|
||||
'txt_data': '',
|
||||
'srv_ttl': lambda x: x > 0,
|
||||
'txt_ttl': lambda x: x > 0,
|
||||
'aaaa_ttl': lambda x: x > 0,
|
||||
|
||||
Reference in New Issue
Block a user