Make DNS request for plat prefix detection network specific.
When plat prefix detection is done on a non-default network it
must use the network specific version of getaddrinfo() so the
plat prefix corresponds to the particular network. The network
is specified to clatd via a NetID command line argument.
Change-Id: I77a47b24e68c7786f790974f05787a40a4934af5
diff --git a/config.c b/config.c
index b82ac6c..3d39ff0 100644
--- a/config.c
+++ b/config.c
@@ -152,15 +152,16 @@
/* function: dns64_detection
* does dns lookups to set the plat subnet or exits on failure, waits forever for a dns response with a query backoff timer
+ * net_id - (optional) netId to use, NETID_UNSET indicates use of default network
*/
-void dns64_detection() {
+void dns64_detection(unsigned net_id) {
int backoff_sleep, status;
struct in6_addr tmp_ptr;
backoff_sleep = 1;
while(1) {
- status = plat_prefix(Global_Clatd_Config.plat_from_dns64_hostname,&tmp_ptr);
+ status = plat_prefix(Global_Clatd_Config.plat_from_dns64_hostname,net_id,&tmp_ptr);
if(status > 0) {
memcpy(&Global_Clatd_Config.plat_subnet, &tmp_ptr, sizeof(struct in6_addr));
return;
@@ -223,8 +224,10 @@
* file - filename to parse
* uplink_interface - interface to use to reach the internet and supplier of address space
* plat_prefix - (optional) plat prefix to use, otherwise follow config file
+ * net_id - (optional) netId to use, NETID_UNSET indicates use of default network
*/
-int read_config(const char *file, const char *uplink_interface, const char *plat_prefix) {
+int read_config(const char *file, const char *uplink_interface, const char *plat_prefix,
+ unsigned net_id) {
cnode *root = config_node("", "");
void *tmp_ptr = NULL;
@@ -277,7 +280,7 @@
if(!(Global_Clatd_Config.plat_from_dns64_hostname = config_item_str(root, "plat_from_dns64_hostname", DEFAULT_DNS64_DETECTION_HOSTNAME)))
goto failed;
- dns64_detection();
+ dns64_detection(net_id);
}
}