net: dns: Set the address family and address length correctly
We need to set the resolved IP address family and length before calling the user callback so that callback does not need to figure out these values itself. Change-Id: I724909fc1707608ab8728231a0311795b6a313f3 Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
parent
c84eff0be4
commit
d31fa5b87c
1 changed files with 4 additions and 1 deletions
|
@ -415,10 +415,14 @@ static int dns_read(struct dns_resolve_context *ctx,
|
|||
address_size = DNS_IPV4_LEN;
|
||||
addr = (uint8_t *)&net_sin(&info->ai_addr)->sin_addr;
|
||||
info->ai_family = AF_INET;
|
||||
info->ai_addr.family = AF_INET;
|
||||
info->ai_addrlen = sizeof(struct sockaddr_in);
|
||||
} else if (ctx->queries[query_idx].query_type == DNS_QUERY_TYPE_AAAA) {
|
||||
address_size = DNS_IPV6_LEN;
|
||||
addr = (uint8_t *)&net_sin6(&info->ai_addr)->sin6_addr;
|
||||
info->ai_family = AF_INET6;
|
||||
info->ai_addr.family = AF_INET6;
|
||||
info->ai_addrlen = sizeof(struct sockaddr_in6);
|
||||
} else {
|
||||
ret = DNS_EAI_FAMILY;
|
||||
goto quit;
|
||||
|
@ -446,7 +450,6 @@ static int dns_read(struct dns_resolve_context *ctx,
|
|||
src = dns_msg.msg + dns_msg.response_position;
|
||||
|
||||
memcpy(addr, src, address_size);
|
||||
info->ai_addrlen = address_size;
|
||||
|
||||
ctx->queries[query_idx].cb(DNS_EAI_INPROGRESS, info,
|
||||
ctx->queries[query_idx].user_data);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue