1
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
106
107
114
115
/* ... */
/* ... */
#include "lwip/err.h"
#include "lwip/def.h"
#include "lwip/sys.h"
#include "lwip/errno.h"
#if !NO_SYS
/* ... */
static const int err_to_errno_table[] = {
0,
ENOMEM,
ENOBUFS,
EWOULDBLOCK,
EHOSTUNREACH,
EINPROGRESS,
EINVAL,
EWOULDBLOCK,
EADDRINUSE,
EALREADY,
EISCONN,
ENOTCONN,
-1,
ECONNABORTED,
ECONNRESET,
ENOTCONN,
EIO
...};
int
err_to_errno(err_t err)
{
if ((err > 0) || (-err >= (err_t)LWIP_ARRAYSIZE(err_to_errno_table))) {
return EIO;
}if ((err > 0) || (-err >= (err_t)LWIP_ARRAYSIZE(err_to_errno_table))) { ... }
return err_to_errno_table[-err];
}{ ... }
#endif/* ... */
#ifdef LWIP_DEBUG
static const char *err_strerr[] = {
"Ok.",
"Out of memory error.",
"Buffer error.",
"Timeout.",
"Routing problem.",
"Operation in progress.",
"Illegal value.",
"Operation would block.",
"Address in use.",
"Already connecting.",
"Already connected.",
"Not connected.",
"Low-level netif error.",
"Connection aborted.",
"Connection reset.",
"Connection closed.",
"Illegal argument."
...};
/* ... */
const char *
lwip_strerr(err_t err)
{
if ((err > 0) || (-err >= (err_t)LWIP_ARRAYSIZE(err_strerr))) {
return "Unknown error.";
}if ((err > 0) || (-err >= (err_t)LWIP_ARRAYSIZE(err_strerr))) { ... }
return err_strerr[-err];
}lwip_strerr (err_t err) { ... }
/* ... */
#endif