[dnssd] implement DNS-SD Discovery Proxy (#6191)

This commit implements DNS-SD Discovery Proxy.
- Implemented DNS-SD Discovery Proxy functionalities - OT part
- Fixed an memory issue of NameCompressInfo (introduced in #6155 , but
  somehow revealed by this commit)

Some implementation details:
- Discovery Proxy subscribes to services/service instances/hosts
  through callbacks set by a public OT API. It is up to the platform
  mDNS implementation to collect service instance/host information and
  notify OT via a public OT API.
- Discovery Proxy can handle DNS browsing of one service or DNS
  resolving of one service instance/host. We leave browsing multiple
  services or resolving multiple service instances/hosts for future
  enhancements if necessary.
This commit is contained in:
Simon Lin
2021-04-08 18:21:23 -07:00
committed by GitHub
parent e43cd4bb07
commit 5a39566f81
21 changed files with 1184 additions and 279 deletions
+17
View File
@@ -293,11 +293,28 @@ class OtbrDocker:
record[1] = int(record[1])
if record[3] == 'SRV':
record[4], record[5], record[6] = map(int, [record[4], record[5], record[6]])
elif record[3] == 'TXT':
record[4:] = [self.__parse_dns_dig_txt(record[4:])]
dig_result[section].append(tuple(record))
return dig_result
def __parse_dns_dig_txt(self, txt_entries):
# Example txt_entries:
# ['"nn=OpenThread"', '"xp=\\000\\013\\184\\000\\000\\000\\000\\000"', '"tv=1.2.0"', '"dd=\\022n\\010\\000\\000\\000\\000\\001"']
txt = {}
for entry in txt_entries:
assert entry.startswith('"') and entry.endswith('"')
entry = entry[1:-1]
if entry == "":
continue
k, v = entry.split('=')
txt[k] = v
return txt
def _setup_sysctl(self):
self.bash(f'sysctl net.ipv6.conf.{self.ETH_DEV}.accept_ra=2')
self.bash(f'sysctl net.ipv6.conf.{self.ETH_DEV}.accept_ra_rt_info_max_plen=64')