[border-agent] use ephemeral port (#6450)

This commit changes border agent service to use ephemeral port by
default. This change makes it easier to support multiple Thread
interfaces on a single host.
This commit is contained in:
Yakun Xu
2021-04-20 22:32:07 -07:00
committed by GitHub
parent e3b971e497
commit 8467a3d522
19 changed files with 112 additions and 11 deletions
+3
View File
@@ -167,4 +167,7 @@ expect_line "Done"
send "diag start\n"
expect ": InvalidState"
send "ba port\n"
expect "Done"
dispose_all
@@ -232,13 +232,16 @@ class TestDnssdServerOnBr(thread_cert.TestCase):
dp_instance_name = f'{network_name}._meshcop._udp.default.service.arpa.'
dp_hostname = lambda x: x.endswith('.default.service.arpa.')
def check_border_agent_port(port):
return 0 < port <= 65535
dig_result = self.nodes[DIGGER].dns_dig(server_addr, dp_service_name, 'PTR')
self._assert_dig_result_matches(
dig_result, {
'QUESTION': [(dp_service_name, 'IN', 'PTR'),],
'ANSWER': [(dp_service_name, 'IN', 'PTR', dp_instance_name),],
'ADDITIONAL': [
(dp_instance_name, 'IN', 'SRV', 0, 0, config.BORDER_AGENT_UDP_PORT, dp_hostname),
(dp_instance_name, 'IN', 'SRV', 0, 0, check_border_agent_port, dp_hostname),
(dp_instance_name, 'IN', 'TXT', lambda txt: (isinstance(txt, dict) and txt.get(
'nn') == network_name and 'xp' in txt and 'tv' in txt and 'dd' in txt)),
],
@@ -258,7 +261,7 @@ class TestDnssdServerOnBr(thread_cert.TestCase):
self._assert_dig_result_matches(
dig_result, {
'QUESTION': [(dp_instance_name, 'IN', 'SRV'),],
'ANSWER': [(dp_instance_name, 'IN', 'SRV', 0, 0, config.BORDER_AGENT_UDP_PORT, dp_hostname),],
'ANSWER': [(dp_instance_name, 'IN', 'SRV', 0, 0, check_border_agent_port, dp_hostname),],
'ADDITIONAL': [(dp_instance_name, 'IN', 'TXT', lambda txt: (isinstance(txt, dict) and txt.get(
'nn') == network_name and 'xp' in txt and 'tv' in txt and 'dd' in txt)),],
})
@@ -269,7 +272,7 @@ class TestDnssdServerOnBr(thread_cert.TestCase):
'QUESTION': [(dp_instance_name, 'IN', 'TXT'),],
'ANSWER': [(dp_instance_name, 'IN', 'TXT', lambda txt: (isinstance(txt, dict) and txt.get(
'nn') == network_name and 'xp' in txt and 'tv' in txt and 'dd' in txt)),],
'ADDITIONAL': [(dp_instance_name, 'IN', 'SRV', 0, 0, config.BORDER_AGENT_UDP_PORT, dp_hostname),],
'ADDITIONAL': [(dp_instance_name, 'IN', 'SRV', 0, 0, check_border_agent_port, dp_hostname),],
})
if dp_ip6_address is not None:
-2
View File
@@ -144,8 +144,6 @@ LEADER_NOTIFY_SED_BY_CHILD_UPDATE_REQUEST = True
THREAD_VERSION_1_1 = 2
THREAD_VERSION_1_2 = 3
BORDER_AGENT_UDP_PORT = 49191
def create_default_network_data_prefix_sub_tlvs_factories():
return {