mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #11735 from michalpasztamobica/dns_unittest_preparation
Dns unittest preparationpull/11775/head
commit
419556b84a
|
@ -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"
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue