mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2026-08-10 17:43:39 +08:00
api_msg.c, err.h, err.c, sockets.c, dns.c, dns.h: replace "enum dns_result" by err_t type. Add a new err_t code "ERR_INPROGRESS".
This commit is contained in:
@@ -1063,22 +1063,10 @@ do_dns_found(const char *name, struct ip_addr *ipaddr, void *arg)
|
||||
void
|
||||
do_gethostbyname(void *arg)
|
||||
{
|
||||
DNS_RESULT res;
|
||||
struct dns_api_msg *msg = (struct dns_api_msg*)arg;
|
||||
|
||||
res = dns_gethostbyname(msg->name, msg->addr, do_dns_found, msg);
|
||||
if (res != DNS_QUERY_QUEUED) {
|
||||
/* If not queued, return to app thread directly */
|
||||
if (res == DNS_COMPLETE) {
|
||||
/* name was already in octet notation or cached */
|
||||
*msg->err = ERR_OK;
|
||||
} else if (res == DNS_ERR_MEM) {
|
||||
/* memory allocation error */
|
||||
*msg->err = ERR_MEM;
|
||||
} else {
|
||||
/* some error occurred */
|
||||
*msg->err = ERR_ARG;
|
||||
};
|
||||
*msg->err = dns_gethostbyname(msg->name, msg->addr, do_dns_found, msg);
|
||||
if (*msg->err != ERR_INPROGRESS) {
|
||||
/* on error or immediate success, wake up the application
|
||||
* task waiting in netconn_gethostbyname */
|
||||
sys_sem_signal(msg->sem);
|
||||
|
||||
@@ -41,20 +41,21 @@
|
||||
#ifdef LWIP_DEBUG
|
||||
|
||||
static const char *err_strerr[] = {
|
||||
"Ok.", /* ERR_OK 0 */
|
||||
"Out of memory error.", /* ERR_MEM -1 */
|
||||
"Buffer error.", /* ERR_BUF -2 */
|
||||
"Routing problem.", /* ERR_RTE -3 */
|
||||
"Connection aborted.", /* ERR_ABRT -4 */
|
||||
"Connection reset.", /* ERR_RST -5 */
|
||||
"Connection closed.", /* ERR_CLSD -6 */
|
||||
"Not connected.", /* ERR_CONN -7 */
|
||||
"Illegal value.", /* ERR_VAL -8 */
|
||||
"Illegal argument.", /* ERR_ARG -9 */
|
||||
"Address in use.", /* ERR_USE -10 */
|
||||
"Low-level netif error.", /* ERR_IF -11 */
|
||||
"Already connected.", /* ERR_ISCONN -12 */
|
||||
"Timeout." /* ERR_TIMEOUT -13 */
|
||||
"Ok.", /* ERR_OK 0 */
|
||||
"Out of memory error.", /* ERR_MEM -1 */
|
||||
"Buffer error.", /* ERR_BUF -2 */
|
||||
"Routing problem.", /* ERR_RTE -3 */
|
||||
"Connection aborted.", /* ERR_ABRT -4 */
|
||||
"Connection reset.", /* ERR_RST -5 */
|
||||
"Connection closed.", /* ERR_CLSD -6 */
|
||||
"Not connected.", /* ERR_CONN -7 */
|
||||
"Illegal value.", /* ERR_VAL -8 */
|
||||
"Illegal argument.", /* ERR_ARG -9 */
|
||||
"Address in use.", /* ERR_USE -10 */
|
||||
"Low-level netif error.", /* ERR_IF -11 */
|
||||
"Already connected.", /* ERR_ISCONN -12 */
|
||||
"Timeout.", /* ERR_TIMEOUT -13 */
|
||||
"Operation in progress." /* ERR_INPROGRESS -14 */
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -124,20 +124,21 @@ static sys_sem_t selectsem;
|
||||
/** Table to quickly map an lwIP error (err_t) to a socket error
|
||||
* by using -err as an index */
|
||||
static const int err_to_errno_table[] = {
|
||||
0, /* ERR_OK 0 No error, everything OK. */
|
||||
ENOMEM, /* ERR_MEM -1 Out of memory error. */
|
||||
ENOBUFS, /* ERR_BUF -2 Buffer error. */
|
||||
EHOSTUNREACH, /* ERR_RTE -3 Routing problem. */
|
||||
ECONNABORTED, /* ERR_ABRT -4 Connection aborted. */
|
||||
ECONNRESET, /* ERR_RST -5 Connection reset. */
|
||||
ESHUTDOWN, /* ERR_CLSD -6 Connection closed. */
|
||||
ENOTCONN, /* ERR_CONN -7 Not connected. */
|
||||
EINVAL, /* ERR_VAL -8 Illegal value. */
|
||||
EIO, /* ERR_ARG -9 Illegal argument. */
|
||||
EADDRINUSE, /* ERR_USE -10 Address in use. */
|
||||
-1, /* ERR_IF -11 Low-level netif error */
|
||||
-1, /* ERR_ISCONN -12 Already connected. */
|
||||
ETIMEDOUT /* ERR_TIMEOUT -13 Timeout */
|
||||
0, /* ERR_OK 0 No error, everything OK. */
|
||||
ENOMEM, /* ERR_MEM -1 Out of memory error. */
|
||||
ENOBUFS, /* ERR_BUF -2 Buffer error. */
|
||||
EHOSTUNREACH, /* ERR_RTE -3 Routing problem. */
|
||||
ECONNABORTED, /* ERR_ABRT -4 Connection aborted. */
|
||||
ECONNRESET, /* ERR_RST -5 Connection reset. */
|
||||
ESHUTDOWN, /* ERR_CLSD -6 Connection closed. */
|
||||
ENOTCONN, /* ERR_CONN -7 Not connected. */
|
||||
EINVAL, /* ERR_VAL -8 Illegal value. */
|
||||
EIO, /* ERR_ARG -9 Illegal argument. */
|
||||
EADDRINUSE, /* ERR_USE -10 Address in use. */
|
||||
-1, /* ERR_IF -11 Low-level netif error */
|
||||
-1, /* ERR_ISCONN -12 Already connected. */
|
||||
ETIMEDOUT, /* ERR_TIMEOUT -13 Timeout */
|
||||
EINPROGRESS /* ERR_INPROGRESS -14 Operation in progress */
|
||||
};
|
||||
|
||||
#define ERR_TO_ERRNO_TABLE_SIZE \
|
||||
|
||||
Reference in New Issue
Block a user