Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dns unittest preparation #11735

Merged
merged 2 commits into from
Oct 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions features/netsocket/nsapi_dns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include "mbed_shared_queues.h"
#include "events/EventQueue.h"
#include "OnboardNetworkStack.h"
Expand Down Expand Up @@ -63,7 +64,7 @@ enum dns_state {
};

struct DNS_QUERY {
int unique_id;
intptr_t unique_id;
nsapi_error_t status;
NetworkStack *stack;
char *host;
Expand Down Expand Up @@ -94,7 +95,7 @@ static void nsapi_dns_cache_reset();
static nsapi_error_t nsapi_dns_get_server_addr(NetworkStack *stack, uint8_t *index, uint8_t *total_attempts, uint8_t *send_success, SocketAddress *dns_addr, const char *interface_name);

static void nsapi_dns_query_async_create(void *ptr);
static nsapi_error_t nsapi_dns_query_async_delete(int unique_id);
static nsapi_error_t nsapi_dns_query_async_delete(intptr_t unique_id);
static void nsapi_dns_query_async_send(void *ptr);
static void nsapi_dns_query_async_timeout(void);
static void nsapi_dns_query_async_resp(DNS_QUERY *query, nsapi_error_t status, SocketAddress *address);
Expand Down Expand Up @@ -122,7 +123,7 @@ static SingletonPtr<PlatformMutex> dns_cache_mutex;
#endif

static uint16_t dns_message_id = 1;
static int dns_unique_id = 1;
static intptr_t dns_unique_id = 1;
static DNS_QUERY *dns_query_queue[DNS_QUERY_QUEUE_SIZE];
// Protects from several threads running asynchronous DNS
static SingletonPtr<PlatformMutex> dns_mutex;
Expand Down Expand Up @@ -638,6 +639,8 @@ void nsapi_dns_call_in_set(call_in_callback_cb_t callback)
void nsapi_dns_reset()
{
nsapi_dns_cache_reset();
dns_message_id = 1;
dns_unique_id = 1;
}

nsapi_error_t nsapi_dns_call_in(call_in_callback_cb_t cb, int delay, mbed::Callback<void()> func)
Expand Down Expand Up @@ -765,7 +768,7 @@ nsapi_value_or_error_t nsapi_dns_query_multiple_async(NetworkStack *stack, const

static void nsapi_dns_query_async_initiate_next(void)
{
int id = INT32_MAX;
intptr_t id = INTPTR_MAX;
DNS_QUERY *query = NULL;

// Trigger next query to start, find one that has been on queue longest
Expand Down Expand Up @@ -842,7 +845,7 @@ static void nsapi_dns_query_async_timeout(void)
dns_mutex->unlock();
}

nsapi_error_t nsapi_dns_query_async_cancel(int id)
nsapi_error_t nsapi_dns_query_async_cancel(nsapi_size_or_error_t id)
{
dns_mutex->lock();

Expand Down Expand Up @@ -874,7 +877,7 @@ static void nsapi_dns_query_async_create(void *ptr)
{
dns_mutex->lock();

int unique_id = reinterpret_cast<int>(ptr);
intptr_t unique_id = reinterpret_cast<intptr_t>(ptr);

DNS_QUERY *query = NULL;

Expand Down Expand Up @@ -940,7 +943,7 @@ static void nsapi_dns_query_async_create(void *ptr)

}

static nsapi_error_t nsapi_dns_query_async_delete(int unique_id)
static nsapi_error_t nsapi_dns_query_async_delete(intptr_t unique_id)
{
int index = -1;
DNS_QUERY *query = NULL;
Expand Down Expand Up @@ -1000,7 +1003,7 @@ static void nsapi_dns_query_async_send(void *ptr)
{
dns_mutex->lock();

int unique_id = reinterpret_cast<int>(ptr);
intptr_t unique_id = reinterpret_cast<intptr_t>(ptr);

DNS_QUERY *query = NULL;

Expand Down Expand Up @@ -1162,7 +1165,7 @@ static void nsapi_dns_query_async_response(void *ptr)
{
dns_mutex->lock();

int unique_id = reinterpret_cast<int>(ptr);
intptr_t unique_id = reinterpret_cast<intptr_t>(ptr);

DNS_QUERY *query = NULL;

Expand Down
2 changes: 1 addition & 1 deletion features/netsocket/nsapi_dns.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ nsapi_size_or_error_t nsapi_dns_query_multiple(S *stack, const char *host,
* @param id Unique id of the hostname translation operation
* @return 0 on success, negative error code on failure
*/
nsapi_error_t nsapi_dns_query_async_cancel(nsapi_error_t id);
nsapi_error_t nsapi_dns_query_async_cancel(nsapi_size_or_error_t id);

/** Set a call in callback
*
Expand Down